Skip to content

Serve every installed variant of a video model and pick one per request - #834

Draft
zaiyang-zhang wants to merge 17 commits into
incoai:mainfrom
zaiyang-zhang:pr/h3-17-switch-variant
Draft

zaiyang-zhang wants to merge 17 commits into
incoai:mainfrom
zaiyang-zhang:pr/h3-17-switch-variant

Conversation

@zaiyang-zhang

@zaiyang-zhang zaiyang-zhang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #833; review the last commit only.

A video model's server now serves every installed variant of its model, and a request's model picks one.

The server holds the assembly of the --model selection, which the launcher installs as before, and then each other installed selection of the same repository in the models root. Each is checked without hashing and held until the server exits; nothing is installed for them. A request's model (OWNER/REPO:VARIANT) or its variant picks one; a request that names neither gets --model's variant. Each job's engine starts on its variant's assembly. /v1/models lists the variants after --model and its aliases, with the input each takes in input_modalities, and a variant that is not installed is refused with the command that installs it. The video object's model is now always REPO:VARIANT (MiniMaxAI/MiniMax-H3:pika-6), whatever name the request used. Language-model serving is unchanged.

The trial page gets a variant menu from /v1/models. Variants that are not installed are shown greyed with their splash install command, and the inputs shown (frames or references) follow the variant chosen.

Tests. Two tests: a request's model reaches the engine on that variant's assembly, and the server reads, holds and skips selection links as described. CPU gates pass. On an M5 Pro one server held pika-6 and pika-ref2va-6; from the page, a clip on pika-6, one on pika-ref2va-6 with a reference and one back on pika-6 each ran on the variant chosen.

🤖 Generated with Claude Code


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

zaiyang-zhang and others added 17 commits November 24, 2026 15:56
The video DiT's Metal kernels under runtime/metal/kernels/video: window
attention, the linear branch, Video Sparse Attention, the QKFIX blocks,
run-time LoRA, the int8 GEMMs and their producers, with their host / kernel
structs under runtime/metal/abi/video. QuantFormat.h defines QUANT_VIDEO_W8,
the video weights' int8 format, outside kQuantFormats. The Makefile compiles
every kernel under kernels/video into splash.metallib. THIRD_PARTY_NOTICES
gains the MiniMax H3, OpenVDN and FastVideo notices.

Nothing calls these kernels until the engine process lands. No test lands
with this part; their test, one DiT block on synthetic weights
(video_synthetic_metal_test.mm), lands with the engine process.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The rest of the video model's kernels: the video VAE's decoder and encoder,
the audio VAE, the TAEH3 preview decoder, request preparation, the layout
check, and the text encoder's attention and vision tower, with their ABI
headers. The preparation kernels compile without fast math, as MLX's do.
THIRD_PARTY_NOTICES gains the BigVGAN, MLX and TAEH3 notices.

The text encoder Metal test lands with them: text_encoder_metal_test.mm
checks the text encoder's attention kernels against a CPU reference, and
dev/native.mk builds it and runs it in test-engine-metal. Nothing else calls
these kernels until the engine process lands.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
runtime/video/metal records the video engine's dispatches and holds the
device's constants; runtime/video/ops adds the DiT's operators (the int8
GEMMs with run-time LoRA, window and sparse attention and their tables,
QKFIX, the linear branch, patch I/O, request preparation, the row layout)
and the clip geometry. MetalBackend gains exact grids (dispatchThreads),
with a test in metal_backend_test.mm.

The Makefile builds libsplash-video.a with the video flags, records them in
the build identity and links the archive into splash, with the AVFoundation,
CoreMedia and CoreVideo frameworks its later mp4 writer uses, though nothing
references them yet. check_architecture gains the video ops and video metal
layers; THIRD_PARTY_NOTICES gains the minimax-h3-mlx notice.

Nothing calls these operators until the engine process lands. Their tests
come later: the sparse-attention tables' with the weights loading, the
synthetic DiT block and the canvas tables with the engine process.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The operators that decode latents into frames and sound and encode a
request's keyframes and references: the video VAE's decoder and encoder, the
audio VAE's decoder and encoder, the TAEH3 preview decoder and the text
encoder's vision tower. They join libsplash-video.a.

Nothing calls them until the engine process lands, and no test lands with
this part.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
runtime/video/model reads the converted DiT, VAE, audio, preview and text
encoder weights, the FastH3 layout and run-time adapters, streams the DiT's
block weights and plans its activations; it prepares a request's inputs
(text rows, adaLN tables, RoPE, noise, latents and Ref2VA references) and
tabulates the adaLN tables. check_architecture gains the video model layer;
THIRD_PARTY_NOTICES gains the Qwen3-VL notice.

Two CPU tests land with it, built against libsplash-video.a and run in
test-engine-cpu: the timestep-embedding test (video_temb_test.mm, the adaLN
tables' time embedder against an fp64 reference) and the
sparse-attention-table test (video_vsa_table_test.mm, FastH3's tile map and
schedules, with FastVideoTiles.hpp). Nothing else calls this code until the
engine process lands.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The video engine and its server speak a stream of their own beside the
engine protocol: runtime/video/protocol/VideoProtocol.{hpp,cpp} on the
engine's side and server/video_protocol.py on the server's. A frame has
the engine protocol's 16-byte header with the magic "SPLV" and the
stream's own version, 1, so a frame sent to the wrong engine fails at its
header with BadMagic, either way. The server sends VideoRequest (0x0007)
and Cancel (0x0002); the engine sends VideoReady (0x010D: its concurrent
requests and prompt tokens), VideoProgress (0x010B), VideoOutput (0x010C),
Error (0x0105) and, in place of VideoReady, StartFailed (0x0109). Cancel,
Error and StartFailed are the engine protocol's payloads and go through
its public codec on both sides. A VideoRequest names its DiT
(validDitName, valid_dit_name; FastH3.hpp's ditDirectory comment names
wire::validDitName), carries its keyframes and Ref2VA references, and may
reach 4 GiB, the stream's own bound.

dev/tests/engine/video_protocol_golden.txt pins the bytes both codecs
agree on: video_protocol_test.cpp checks the C++ codec against it, and an
SPLV frame in the engine protocol's parser and an SPLH frame in its own
both fail at the magic; test_video_protocol.py (with video_peer.py) does
the same for the Python codec. dev/native.mk builds and runs
video-protocol as it does the protocol test, on the CPU and under both
sanitizers. check_architecture gains the video protocol layer, on the
engine and shared layers; the release package ships video_protocol.py;
docs/validate.md names the stream's version pair.

The engine protocol is untouched: runtime/engine, server/protocol.py and
their tests and golden are upstream's, at version 13, and
ENGINE_LINE_BUDGET stays 30,105. Nothing speaks the stream until the
engine process (part 7) and the server (part 9).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
VideoRuntime serves an h3-video assembly on the video protocol's stream:
it announces VideoReady with its prompt bound
(TextEncoder::kMaximumPresentationTokens), or sends StartFailed in its
place, and runs each VideoRequest through its stages (text encoding,
preparation, denoising, preview, decoding, audio decoding and the mp4),
each a PipelineStage; the stages take their phases and outputs from
video/protocol. runtime/main.mm starts it for serve-native of a video
model directory, and its video-adaln command tabulates the adaLN tables of
a DiT whose name wire::validDitName accepts. check_architecture gains the
video, video stages and video pipeline layers, which use the video
protocol, and startup may use the video layer.

The remaining native tests and tools join dev/native.mk: the synthetic DiT
block (test-engine-metal), the canvas tables (test-engine-cpu), video-golden
and video-ref2va-layout. docs/video.md describes the engine, its stream
(Video protocol), its run-time adapters, reference rows and native tests,
with its figure, and docs/internals.md lists runtime/video and points from
the native protocol to the video stream.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
splash install MiniMaxAI/MiniMax-H3[:VARIANT] installs a model as serve
does and starts nothing; the variants are vdn-8, vdn-50, fasth3-8, fasth3-4,
pika-6 and pika-ref2va-6 (install/families.py, H3). The recipes h3.py and
fasth3.py convert the release and the variant's companion repository into
the engine's images as they read them (conversion.py, video.py), and --spec
FILE installs another checkpoint of the DiT as a variant from a JSON spec.
Every source is read at the commit H3.revisions pins: the release, each
shipped variant's companion, the text encoder, the four-step student and
TAEH3; the record names the commits read, and a spec's repository without
a pin follows its default branch. video.py checks a variant's DiT name
with the video protocol's valid_dit_name. assembly.py, hub.py, local.py,
models.py and upstream.py take the derived entries, unbuffered range
reads, local video directories and --spec; the shell completions complete
install and its --spec file; the release package ships the new installer
modules.

The installer's tests land with it: test_video.py (with a FormatTest that
holds the converters' constants to QuantFormat.h, and tests that every
shipped source is pinned and is read and recorded at its pin),
test_fasth3.py, test_h3_merge.py, and install's cases in test_launcher.py
and test_completion.py; so do docs/video.md's installation sections,
docs/models.md, docs/internals.md's QUANT_VIDEO_W8 and the Pika H3 Flex
notice.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A video model's server answers OpenAI's video API at /v1/videos
(server/videos.py): it checks a request, puts its keyframes on the canvas
(server/images.py), normalizes its Ref2VA references (server/references.py)
and runs the clip on the engine, on the video protocol's stream. The engine
starts when it sends VideoReady; a start that fails before the engine runs
as the video engine says why in the engine protocol, which the server reads
for a StartFailed or an Error and otherwise refuses as an engine that
serves no video model. server.py starts the video app for a video model,
and its body reader takes the content types a route accepts. splash
generate runs one clip, as a job of a running server or on its own engine,
and the completions offer it. install/families.py gains H3's server-only
fields. The video protocol's request comments name images.keyframe and
references.normalize, and test_fasth3.py checks that a variant installed
from a spec is served as a shipped one is.

A presentation, with keyframes or references, holds at most 2,048 text
rows (Pika H3 Flex's MAX_TEXT_TOKENS, which its encode_text applies to
both) and, with its vision rows, at most the bound VideoReady announces,
so a 1344x768 clip from a first and a last frame keeps all 2,048 text
rows.

DELETE of a queued job removes it before it reaches the engine; DELETE of
a running job cancels it on the engine, and the worker clears a cancel
that arrives after the clip, so it never cancels the next job. Tests
delete a queued job, a running job and a job as its clip arrives,
through the fake engine's hold mode.

PyAV decodes reference video and audio. It is optional and not shipped:
dev/requirements.txt pins it, the release requirements leave it out
(test_package.py), and a request that needs it without it is refused with
the command that installs it. The release package ships the server's video
modules; README.md, docs/video.md (API, canvases, the server's presentations,
server and real-weight tests) and docs/README.md describe them, dev/Makefile
adds the real-weight video tests, and THIRD_PARTY_NOTICES gains the
reference-decoding sentence of the Pika H3 Flex notice and the diffusers and
PyAV notices.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A Cancel stopped a request only at a denoising step or stage boundary, so a
cancelled 768p VDN-8 job kept the GPU and the SSD readers busy for the rest
of its step. Dit::forward now asks an optional cancelled predicate before
each block: it waits for the block in flight and throws Cancelled; the
request's Dit owns its weight stream, so the reads ahead stop as the Dit is
destroyed. VaeDecoder::decode asks the same before each temporal clip,
waits for the clip in flight and reports the cancel in DecodeStats, and
DecodingStage throws Cancelled. Both wait themselves rather than leave it
to the ticket's destructor, so that a GPU fault during a cancel still ends
the engine. The documents, the comments and generate's status line say
where a cancel now takes effect.

From incoai#810, with these changes: the cancelled forward no longer
hands its stream slots back (that started a read the Dit's destruction then
stopped), decode's predicate is required, and the synthetic DiT test is
left as it was.

Co-authored-by: Wenqi Ye <164997876+Qiqi723@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… starts

Three refusals that came late, or not at all, now come before the first
download of MiniMax-H3, and an installation whose files this Mac already
holds needs no network.

A Mac below Apple GPU family 10 was refused only as the video engine
started, after the variant was downloaded and converted. `device-check
video` applies the video engine's rule after the engine's own, from the
function the engine's start uses, and the launcher runs it for a selection
of MiniMax-H3.

A first installation needed the Hub's listing to key its converted entry,
although the key names only each source file's content ID, which a Hub
cache snapshot's blobs carry in their names. With neither the Hub nor an
installation, the sources' cached snapshots at their pins now key the
entry; a snapshot without a file the conversion reads is refused, naming
the file. An installation with the Hub reads some sources by range and
leaves them out of the cache (a variant's adapter among them), so this is
for a Mac whose cache another tool filled with the repositories' files. TAEH3, the preview decoder's source, is on GitHub and in no Hub
cache: a conversion now copies the preview decoder a converted entry of
this Mac holds (by its files' SHA-256) and reads TAEH3 from GitHub only
where there is none, saying so if it cannot. It converts the preview
decoder first, so that this refusal too comes before the long units.

The downloads reserved no room for what followed them and the conversion
checked none. An installation is now refused first where a volume has no
room for the files still to download, the text encoder's trimmed shards
and the converted entry. The entry's size is a measured one, known for
pika-6 and pika-ref2va-6; for the other variants the check counts the
downloads and the encoder's shards only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two runs could be compared stage by stage only from the arrays a devtool
keeps to files. The prep now logs the first 12 hex digits of the SHA-256
of the text states the DiT is conditioned on and of the video and audio
noise, and the denoising logs those of the final video and audio latents,
each on a line of its own next to the stage's existing line.

The digests read memory that is already on the CPU when they are taken:
the prep's outputs after it returns and the latents after the last update
step. No computation, GPU command, wait or read-back changes, and no
existing log line does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The quoted-token tests also serve every model installed in the checkout,
reading the family of each assembly under install/models/.resolved that
has a tokenizer. assembly.family is None for an assembly that is not a
chat model's, such as a MiniMax-H3 video installation, and each test then
failed on None.chat_format. Such an assembly is now skipped; the chat
models installed beside it are still served.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
POST /v1/videos read a multipart/form-data text field with
get_content(), which takes a part that declares no charset as ASCII.
A browser's FormData sends its fields that way, as UTF-8 bytes with no
charset, so every non-ASCII character of a prompt arrived as U+FFFD.

A text field is now decoded from its bytes by its declared charset, or
else as UTF-8; bytes that are not of that charset, or a charset Python
does not know, are refused with a 400 that names the field.

A Chinese prompt is now tested on each way a request comes in: JSON
and a browser's form to /v1/videos, and splash generate with and
without a file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A video model's server answers / with server/video.html, as a language
model's answers it with the chat page: public, and gone with --no-webui.
The page writes a prompt, takes a first and last frame or Ref2VA
references by drop or pick, and the duration, size, seed and audio; it
shows the server's clips queued, running, done, failed or cancelled,
cancels them, and plays and downloads each mp4 as a blob. It calls the
/v1/videos routes alone, with the API key as the chat page sends it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A video model's server now keeps the Mac from idle sleep while a job's
engine runs, as a language model's engine does while it serves a request:
caffeinate -i from the engine's start until the request ends, and none
with --allow-idle-sleep, which the video server ignored before.

splash serve of a video model names, in one warning, the options it was
given that set how a language model is served and that its server
ignores. splash generate prints the jobs queued ahead of its clip, the
engine's start, and from the denoising's second reading the time left at
the rate so far; with no server on the port it refuses a video or audio
reference before it installs anything when the server's Python has no
PyAV. That refusal and the server's name the install command and that it
must be run again after an upgrade, which brings a Python of its own. A
request without references to a references variant is told that one from
the prompt or keyframes takes the default variant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A video model's server holds the assembly of every installed variant of
its model in the models root: the --model selection's, which the launcher
installs as before, then each other selection link of the repository,
checked without hashing and held until the server exits; nothing is
installed for them. A request's model, OWNER/REPO:VARIANT, or its variant
picks one; a request naming neither takes --model's variant, or the first
served one of its kind (references or not). Each job's engine starts on
its variant's assembly. /v1/models lists the variants after --model and
its aliases, each with the input it takes, and a variant not served is
refused with the command that installs it.

The trial page picks the variant from /v1/models: the served ones, and
the other MiniMax-H3 variants greyed with their splash install command;
its inputs, frames or references, follow the variant chosen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant