Archived
radiance 1.8.0
- video: MiniMax-H3 and FastVideo's FastH3 8-Step V2, a video with its stereo soundtrack from text on OpenAI's /v1/videos, block fp8 on two cards - music: MiniMax-Music3, songs from lyrics and a description on /v1/audio/speech - speech: Breeze-TTS-2 on /v1/audio/speech and vLLM-Omni's realtime WebSocket - runtime LoRA adapters beside the base model, picked per request by `model` (baKon, #105) - several agent streams keep their cached history: --checkpoint-slots auto, the new default, sizes the snapshot store by --max-num-seqs (#108) - the Swift 1.5 27B W4 releases convert and serve: compressed-tensors AWQ and GPTQ int4, AutoRound, ModelOpt NVFP4 (#110) - the image's host tests pass where perf_event_open is refused, as in BuildKit's sandbox (#106) - plugin ABI 21: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
91127395ee
commit
7a7707a955
179 files changed
+37542
-1892
No files matched your search
@@ -19,6 +19,9 @@ plugin claims.
|
||||
| `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint (the 26B-A4B MoE and the dense sizes without per-layer embeddings) with z-lab's DFlash drafter; routed experts bf16 or block fp8 |
|
||||
| `arch/qwenimage21` | `qwenimage21` | *(empty)* | Qwen-Image 2.1 and 2.1-Turbo, an image generator, from the diffusers pipeline directory; DiT and text encoder bf16 or block fp8 |
|
||||
| `arch/qwen3asr_bf16` | `qwen3asr` | *(empty)* | Qwen3-ASR: a Whisper-style audio encoder over a dense Qwen3 decoder, speech to text |
|
||||
| `arch/minimaxmusic3` | `minimaxmusic3` | *(empty)* | MiniMax-Music3, songs from a description and lyrics: a Qwen3-8B frame model, a depth decoder, a flow-matching DiT and a DAC vocoder, from the diffusers pipeline directory, bf16 |
|
||||
| `arch/breeze` | `breeze` | *(empty)* | Breeze-TTS-2, speech from text and a description of the voice: a T5Gemma 2 text encoder, a Qwen3 backbone with a 16-codebook depth decoder and the Qwen3-TTS 12 Hz codec, from the release directory, bf16, one card |
|
||||
| `arch/minimaxh3` | `minimaxh3` | *(empty)* | MiniMax-H3, a video with its stereo soundtrack from text: Qwen3-VL-32B's language model as the text encoder, a 33B single-stream diffusion transformer, a tiled ViT video decoder and a BigVGAN audio decoder, from the diffusers pipeline directory; linears block fp8 (`data/recipes/minimax-h3-fp8.recipe`) |
|
||||
|
||||
The traps below are readings that are wrong without any error: the model produces fluent output.
|
||||
|
||||
@@ -640,3 +643,258 @@ clips at their pauses (docs/GUIDE.md §5.14). Against transformers on LibriSpeec
|
||||
test-other clips, the encoder's rows are within 1.1-1.3% relative L2 of the bf16 reference's; on
|
||||
the one clip where they differed by 5%, the reference itself was 5.3% from a float32 run of the
|
||||
same model and this engine 0.8%. The transcripts match word for word.
|
||||
|
||||
---
|
||||
|
||||
# `minimaxmusic3`: MiniMax-Music3, songs
|
||||
|
||||
`arch/minimaxmusic3` declares an audio generator (`rad_declare_audio_generator`), which makes the
|
||||
program a four-pass one the engine drives through `core/gen/audio_driver.h`: PROMPT runs the
|
||||
language model over prompt chunks, FRAME samples one frame of every song in flight and runs the
|
||||
language model over its embedding, WINDOW steps the denoiser over a window of frames, VOCODE plays
|
||||
a finished window. A song is a lane; up to four are made at once. It is served on
|
||||
`/v1/audio/speech` ([GUIDE §5.15](GUIDE.md)), bf16 on one card or two. The checkpoint is the
|
||||
diffusers pipeline directory, read as one.
|
||||
|
||||
```
|
||||
LM Qwen3-8B with its embedding and head adapted to music codes: 36 layers of 4096 (32 x 128,
|
||||
8 kv heads), theta 1e6. Two branches a song, conditional and unconditional. Each frame's
|
||||
first code: one of 16384 semantic codes (ids 151675..) or the end of the song (151670),
|
||||
from u + 1.5 (c - u); the candidates are the top 50 of c, of which the top 50 of the
|
||||
guided logits are drawn
|
||||
depth 4 layers of 4096, 16 heads of 256, SwiGLU 6144, learned positions: the frame's other
|
||||
seven codes (1024 each) one at a time, each with the same guidance, the sequence
|
||||
recomputed whole at every step. The next LM input is the eight codes' embeddings summed,
|
||||
times 8^-0.5
|
||||
cond the frame's hidden planes mixed by softmax(learned logits), scaled; a window's rows
|
||||
through a 3-tap conv to 2048 channels, resampled nearest to 441/128 latents a frame
|
||||
DiT 36 layers of 2048 (32 x 64), LayerNorm with affine, SwiGLU 16384 with biases, RoPE over
|
||||
the first 32 of 64 dims; input [latent 128 | zeros 128 | cond 2048] plus a 1x1-conv
|
||||
residual, the timestep token prepended, non-causal. 30 Euler steps at t = i / 30,
|
||||
guidance 1.7 against an all-zero conditioning
|
||||
windows 200 frames, a new one every 100; each binds its first 172 latents to its predecessor's
|
||||
vocoder DAC's decoder: the latent's two 64-channel halves as two streams (left, right), four
|
||||
transposed convolutions (8, 8, 4, 2), dilated residual units with snake; 512 samples a
|
||||
latent, 44.1 kHz stereo
|
||||
```
|
||||
|
||||
Traps:
|
||||
|
||||
- **The randomness is radiance's.** Each pick draws `rad_philox_uniform_s(seed, 2^32 + frame,
|
||||
sub-step)` by inverse CDF in descending guided logit (ties to the lower index), and window k's
|
||||
noise is `rad_philox_normal_s(seed, 1 + k, row * 128 + c)` (`abi/rad_philox.h`). Parity against
|
||||
diffusers means handing diffusers the same picks and noise, which a NumPy port of the streams
|
||||
does.
|
||||
- **The unconditional prompt is the conditional one with its middle blanked**: its first token and
|
||||
last two kept, every token between them the filler 151654, so both branches have one length.
|
||||
An empty or shortened prompt is a different guidance and still sings.
|
||||
- **The first frame after the prompt is consumed, not played**: it only moves the language model
|
||||
past the prompt, and no conditioning row is stored for it.
|
||||
- **The DiT's positions start at the timestep token**: position 0 is that token and the latents
|
||||
follow from 1. Starting the latents at 0 shifts every rotation by one and the song still plays.
|
||||
- **A window's join runs in one order**: its head is set from the previous window's kept tail
|
||||
first, and only then is the next window's tail taken from the joined latent. The other order
|
||||
binds a window to its own tail, and the song drops in level for a moment at every join.
|
||||
- **The model card says 32 kHz; the vocoder plays 44.1 kHz** (512 samples a latent), as diffusers'
|
||||
port and its config do.
|
||||
- **Under tensor parallelism, a fused projection's stacked bias is cut per part**: a rank-1
|
||||
`[value | gate]` vector holds its share of each half, as the matrix it goes with does. A
|
||||
contiguous slice of the stack runs and is 5-6% off in every DiT velocity.
|
||||
|
||||
Against diffusers' own pipeline in bf16, from the same picks and noise: with radiance's codes
|
||||
teacher-forced into the reference, the language model's last hidden row is 1.55% from the
|
||||
reference's (relative L2; the reference is 1.27% from itself across bf16 and f32), the window
|
||||
conditioning 1.33% (1.10%), a DiT step's velocity 1.3% (1.8%). At one card a 4 s song is 29.0 dB
|
||||
SNR from the reference's audio, against 28.7 dB between the reference's own attention kernels; at
|
||||
two cards a 12 s song of two windows is 26.3 dB (32.0), and the 4 s song 20.8 dB, one passage of it
|
||||
having taken another turn, which a rounding-level change makes in the reference too. A pick is chaotic: with the same history,
|
||||
the reference and radiance choose differently at 318 of 808 sub-steps, and the reference chooses
|
||||
differently from itself across precisions at 314.
|
||||
|
||||
---
|
||||
|
||||
# `breeze`: Breeze-TTS-2, speech
|
||||
|
||||
`arch/breeze` declares an audio generator in its chunked form (`rad_declare_audio_generator` with
|
||||
`voc_chunk`): PROMPT runs the text encoder and the backbone over both branches' whole prompts,
|
||||
FRAME samples one frame of every speech in flight and runs the backbone over its embedding, VOCODE
|
||||
plays a lane's newest frames, four at most, as soon as they are made. It is served on
|
||||
`/v1/audio/speech` and `/v1/audio/speech/stream` ([GUIDE §5.15](GUIDE.md)), bf16 on one card. The
|
||||
checkpoint is the release directory; its codec, in `audio_tokenizer/`, is read with it.
|
||||
|
||||
```
|
||||
text T5Gemma 2's text encoder in Gemma 3 1B's shape: 26 layers of 1152, 4 query heads over one
|
||||
KV head of 256 (q/k RMS-normed, scale 1/16), sandwich RMS norms with a (1 + w) gain,
|
||||
gelu-tanh GLU 6912, the embedding times 34.0 (bf16 of sqrt 1152). BIDIRECTIONAL over the
|
||||
whole prompt: sliding layers see 255 keys behind and 256 ahead (theta 1e4); layers 5,
|
||||
11, 17 and 23 see everything (theta 1e6, positions divided by 8). Final norm, then
|
||||
1152 -> 2048
|
||||
backbone Qwen3: 28 layers of 2048, 16 heads over 8 KV heads of 128, q/k norms, theta 1e6, eps
|
||||
1e-6. Its prompt rows ARE the encoder's projection; a frame's input is the bf16 of the
|
||||
f32 sum of its 16 codes' rows of one table [16 x 2051, 2048]. Head 2052: 2048 codes,
|
||||
three never drawn, the end of the speech
|
||||
depth 12 layers of 1024, 8 heads over 2 KV heads of 128, Llama 3's rotary (theta 5e5, factor
|
||||
32, original length 16, low 1/512, high 1/128), no q/k norms: position 0 is the
|
||||
backbone's hidden state, position p code p - 1's row of the table, both through one
|
||||
2048 -> 1024 projection; 15 heads, one a codebook
|
||||
sampling u + g (c - u) against an unconditional prompt without the voice description (g 1, the
|
||||
default: none); top 50 at temperature 0.9; the first code also takes a repetition penalty
|
||||
of 1.1 over the speech's earlier first codes
|
||||
codec the Qwen3-TTS 12 Hz tokenizer's decoder: EMA codebooks (the first code's, the other
|
||||
fifteen's) projected 256 -> 512 and summed; a causal conv k3 to 1024; 8 layers of 512
|
||||
(16 heads of 64, rotary at the frame's index, causal over 72 frames, layer scales);
|
||||
twice a transposed conv k2 s2 and a ConvNeXt block (causal depthwise k7, LayerNorm,
|
||||
exact GELU over 4096); a causal conv k7 to 1536; four blocks of SnakeBeta, a causal
|
||||
transposed conv (8, 5, 4, 3) and three residual units (dilations 1, 3, 9); SnakeBeta and
|
||||
a conv k7 to one channel: 1920 samples a frame, 24 kHz mono
|
||||
```
|
||||
|
||||
Traps (each still speaks, wrongly):
|
||||
|
||||
- **The backbone's configuration is `backbone_config`.** The top level's Llama 3 rotary at theta
|
||||
5e5 and eps 1e-5 belong to a native backbone the release does not build; the Qwen3 backbone runs
|
||||
at theta 1e6 and eps 1e-6.
|
||||
- **The backbone never embeds text.** Every prompt row is the encoder's output projected; the
|
||||
checkpoint's `embed_text_tokens` (0.5B parameters) is unused, and so is the Mimi codec in the
|
||||
main file.
|
||||
- **The encoder reads the whole prompt at once**, so a prompt is never split across passes
|
||||
(`prompt_whole`), and its sliding window is lopsided: transformers' mask at 512 sees 255 keys
|
||||
behind and 256 ahead. A symmetric window differs on prompts over 256 tokens.
|
||||
- **The depth heads are stored (in, out)**, `[15, 1024, 2051]`, and are transposed at convert
|
||||
(`RAD_MAP_TRANSPOSE`); the codec's codebooks are EMA sums, divided by their usage at convert
|
||||
(`RAD_MAP_EMA`).
|
||||
- **A frame's sixteen embeddings are summed in f32 and rounded once**, as torch sums a bf16 tensor;
|
||||
rounding after each would move every backbone input.
|
||||
- **The codec's first two transposed convolutions have a kernel of one stride**, the four after
|
||||
them of two, all causal: the full output's last rows dropped, no padding in front.
|
||||
- **The reference's streaming codec is not a reference.** Its 72-slot KV ring shifts with an
|
||||
overlapping in-place copy that races on the GPU: three identical decodes agree at 20-26 dB.
|
||||
Compare against the offline decode, which radiance's chunks reproduce: every codec layer is
|
||||
causal, so a chunk decoded again over the 85 frames its outputs reach back to is exact. The
|
||||
reference's own codec decoded on radiance's schedule is 117 dB from its whole decode (f32
|
||||
rounding); with 60 frames of context it is 30 dB.
|
||||
|
||||
Against BreezeBlue's eager reference in bf16, teacher-forced with radiance's codes (a CPU run):
|
||||
the backbone's hidden rows are 1.04% from the reference's (relative L2, median over the prompt and
|
||||
72 frames; the reference is 0.94% from itself across bf16 and f32). The reference would have drawn
|
||||
another code at 323 of 1168 picks, all near-ties: the code radiance drew had a median 0.998 of
|
||||
the reference's own pick's probability, and the first code differed once in 73 frames. Through
|
||||
the codec alone, radiance's bf16 audio is 38.4 dB SNR from the reference's f32 decode of the same
|
||||
codes. Whisper large-v3 transcribes radiance's speech word for word.
|
||||
|
||||
---
|
||||
|
||||
# `minimaxh3`: MiniMax-H3, video with sound
|
||||
|
||||
`arch/minimaxh3` declares a video generator (`rad_declare_video_generator`), which makes the
|
||||
program a four-pass one the engine drives through `core/gen/video_driver.h`: VCOND runs the text
|
||||
encoder and the refiner over the prompt and computes every step's modulation, VSTEP is one
|
||||
denoising step of one request's packed sequence, ADECODE plays the soundtrack, VDECODE decodes
|
||||
one temporal chunk of frames. A request is a lane; two hold state at once (one denoising, one
|
||||
conditioned and waiting). It is served on `/v1/videos` ([GUIDE §5.16](GUIDE.md)), block fp8 on two
|
||||
cards with `--vision-tower-placement ram`. The checkpoint is the diffusers pipeline directory,
|
||||
read as one; only workflow t2va is served.
|
||||
|
||||
```
|
||||
text Qwen3-VL-32B's language model: 64 layers of 5120 (64 q / 8 kv heads of 128, ff 25600,
|
||||
eps 1e-6, theta 5e6, interleaved M-RoPE, which is NeoX for text). The conditioning is
|
||||
the hidden state AFTER LAYER 50, before any norm; layers 50..63 are never read and the
|
||||
container leaves them out. The prompt is tokenised as written, no template, no special
|
||||
tokens
|
||||
refiner context_embedder 5120 -> 5376 (bias), two plain pre-norm blocks over the prompt (full
|
||||
attention, no rotary, q/k RMS norms), a final RMSNorm
|
||||
DiT 50 blocks of 5376 (56 heads of 128), SwiGLU 14336, RMSNorm eps 1e-5, no biases, one
|
||||
packed sequence [text | soundtrack ch0 | soundtrack ch1 | video] under full attention.
|
||||
Each row is modulated by its modality (0 video, 1 text, 2 audio) at its timestep (text
|
||||
rows take the video's): six vectors a block from Linear(silu(temb), 3 x 6 x 5376).
|
||||
norm_out's shift and scale are per timestep. Video latents 24 channels in 1x2x2 patches
|
||||
(96 values a row, proj_in f32), the soundtrack's 32 channels a row (f32). Guidance-
|
||||
distilled: one forward a step
|
||||
rotary 3 axes (time, row, column), 16 frequencies each (theta 1e4) over the first 96 of 128
|
||||
dims, rotate-half pairs (i, i + 48); f32 positions
|
||||
schedule per modality: sigma = s x / (1 + (s - 1) x) over linspace(1, 0, N) (N grid points, N - 1
|
||||
evaluations), shift 12 for the video and 3 for the soundtrack; t = 1 - sigma; x0 =
|
||||
x + (1 - t) v, then x' = r x + (1 - r) x0 with r = sigma_next / sigma
|
||||
video ViT decoder, 36 layers of 2048 (32 heads of 64), f32 residual, RMSNorm, q/k RMS norms
|
||||
VAE without weights, rotary 8/8/8 over 48 of 64 dims (theta 100, angles 2 pi (2 (i + .5) /
|
||||
n - 1)), layer scales, SwiGLU 8192 with biases, 4 registers and a zero token a tile.
|
||||
A token is a latent: 4 frames x 16 x 16 pixels. Tiles of 16 x 16 latents, overlap 4 at
|
||||
least; chunks of 7 latent frames every 5. Pixels come out ImageNet-normalised
|
||||
audio dec_in_proj 32 -> 2048, BigVGAN: conv_pre k7 to 1024, 7 transposed convolutions (5 5 2 2
|
||||
VAE 2 2 2), each followed by the mean of three AMP blocks (k 3/7/11, dilations 1/3/5) with
|
||||
anti-aliased SnakeBeta (x2 up, x2 down, 12-tap Kaiser filters); conv_post k7 to one
|
||||
channel, clamped. 800 samples a latent, 32 kHz, each stereo channel its own sequence
|
||||
length 24 fps; a video of n chunks is 17 n + 5 frames over 5 n + 2 latent frames, n 7..20
|
||||
(5.17 to 14.4 s); the soundtrack is round-half-even(frames x 40 / 24) latents a channel
|
||||
```
|
||||
|
||||
Traps:
|
||||
|
||||
- **The feed-forward's value half comes first** in the checkpoint (`[value | gate]`, out =
|
||||
`value * silu(gate)`), in the DiT, the refiner and the video decoder alike. The halves are
|
||||
swapped at convert into the `[gate | value]` that `silu_mul` reads.
|
||||
- **The modulation gate has no tanh**, and the residual is `h += gate * branch`. The timestep
|
||||
embedding reads t in [0, 1] as it is, not scaled to 1000.
|
||||
- **The grid's second half is linspace's from the end**: torch computes `linspace(1, 0, N)` half
|
||||
from each end in f32, which `gen::video_schedule` reproduces.
|
||||
- **The packed rows' positions are f64 rounded to f32**: a latent frame spans 5/3 x (1, 4, 4, 4,
|
||||
4)[i mod 5] time units from `n_text`, the spatial axes are each side's latents over the square
|
||||
root of the frame's area, centred on the unit interval, times 32, and the soundtrack's two
|
||||
channels sit at the two ends of the width axis.
|
||||
- **A tile is blended with its neighbours as they were decoded**: the vertical blend reads the
|
||||
original tile above, and the horizontal blend the original tile to the left, not the blended
|
||||
ones. Chunks keep frames [3, 20) of their 28 and blend their last 5 linearly into the next
|
||||
chunk's first 5.
|
||||
|
||||
Tensor parallel: the text encoder, refiner and DiT blocks split by heads and feed-forward width.
|
||||
A block's three modulation projections split by rows, three of the six vectors a rank, and
|
||||
VCOND writes every step's modulation into the lane once a request, so the 13B modulation
|
||||
parameters and the text encoder (RAD_ACCESS_PER_REQUEST) live in pinned host memory under
|
||||
`--vision-tower-placement ram`. Each step gathers its row of the table across the ranks. The video
|
||||
decoder is replicated and splits its tiles between the ranks, gathering the decoded pixels; the
|
||||
audio decoder runs whole on each.
|
||||
|
||||
Against diffusers' pipeline in bf16 from the same noise, a 256 x 256 clip of 4 grid points: the
|
||||
fp8 text encoder's conditioning is 4.15% from the reference's (relative L2). With radiance's
|
||||
conditioning given to both, the first evaluation's velocity is 5.4% (video) and 4.3% (soundtrack)
|
||||
from the reference's, at slope 0.99 and cosine 0.9985; the reference itself, with radiance's
|
||||
block-fp8 rounding emulated on the same linears, is 6.8% and 4.6% from its own bf16 and shows the
|
||||
same per-channel bias. Fed the same latents, the video decoder is 36.9 dB PSNR from the
|
||||
reference's frames (H.264 included) and the audio decoder 51.0 dB SNR from its samples. The same
|
||||
seed gives the same latents, run to run.
|
||||
|
||||
Attention precision: the DiT's attention takes its scores in int8 (the keys quantised per row and
|
||||
head by `quant_act_i8g`, the query inside the op) and its P.V in fp8 (the values quantised per
|
||||
column by `quant_cols_fp8`, the weights `e4m3(448 p)` against an exactly tracked row max), so both
|
||||
halves run on the 8-bit matrix instruction. Along an exact trajectory in diffusers (256 x 256), the
|
||||
int8 scores move the velocity 1.9-5.9% and the fp8 P.V another 1-3 points, where exact f32
|
||||
softmax and SDPA's bf16 flash kernel already differ by 1.7-4.4%; finished clips keep their shot,
|
||||
motion and detail.
|
||||
|
||||
## FastH3: eight trained steps with video sparse attention
|
||||
|
||||
FastVideo's FastH3 releases (FastVideo/FastVideo-FastH3-8-Step-V2) are the same denoiser distilled
|
||||
(DMD2) to eight evaluations with video sparse attention, and name both in their
|
||||
`fastvideo_inference.json`, which the converter reads under `fastvideo_inference.` keys. The
|
||||
plugin takes from it:
|
||||
|
||||
```
|
||||
schedule the trained timesteps 999 874 749 624 500 375 250 125 over a 1000-step clock, each
|
||||
shifted per modality (10 for the video, checked against scheduler_config.json, 3 for the
|
||||
soundtrack), then 0: nine grid points, eight evaluations, no other count
|
||||
(RadVideoGenDecl::rungs)
|
||||
attention VIDEO_SPARSE_ATTN_H3 at sparsity 0.8 and 64-row tiles: the prompt's and the
|
||||
soundtrack's rows in 64-row chunks of their own (dense: their queries see every key, and
|
||||
every query sees them), the video's patches in 4 x 4 x 4 boxes of (time, row, column);
|
||||
a video query tile keeps the ceil(0.2 V) video tiles of best mean-q . mean-k score, per
|
||||
head. A fourth projection beside q, k and v (attn.to_gate_compress, appended to the
|
||||
fused qkv) gates in an attention over the tiles' means: vsa_select, then attn_vsa
|
||||
(docs/OPS.md)
|
||||
name served as `fastvideo-fasth3-8-step-v2`
|
||||
```
|
||||
|
||||
Its text encoder and both decoders are MiniMax-H3's files byte for byte, so a container of the base
|
||||
model supplies them (`--reuse`, the transformer's tensors listed as `--changed`; see the recipe's
|
||||
header). The distilled model's first evaluation moves 21-23% under any perturbation (the reference
|
||||
itself between bf16 and emulated fp8, or with the fp8 text encoder's conditioning), so its per-step
|
||||
numbers against the reference say little; radiance's frames and the reference's agree by eye.
|
||||
@@ -138,6 +138,10 @@ the cards the engine runs on.
|
||||
| `qwen-image-2.1.yaml` | `qwen-image-2.1-fp8.rad` | Qwen-Image 2.1 as block fp8 on two cards: OpenAI's images API, generation and edits |
|
||||
| `qwen-image-2.1-turbo.yaml` | `qwen-image-2.1-turbo-fp8.rad` | Qwen-Image 2.1 Turbo, the same in 8 steps |
|
||||
| `qwen3-asr-1.7b.yaml` | `Qwen3-ASR-1.7B-hf/` (the checkpoint) | Qwen3-ASR 1.7B: `/v1/audio/transcriptions` and live `/v1/realtime`, on one card (`RADIANCE_GPU`) |
|
||||
| `minimax-h3.yaml` | `minimax-h3-fp8.rad` | MiniMax-H3 as block fp8: video with its stereo soundtrack on `/v1/videos`, two cards and about 39 GiB of pinned host memory |
|
||||
| `fasth3.yaml` | `fasth3-8-step-v2-fp8.rad` | FastVideo's FastH3 8-Step V2, the same in eight steps |
|
||||
| `minimax-music3.yaml` | `minimax-music3-bf16.rad` | MiniMax-Music3 in bf16: songs from lyrics and a description on `/v1/audio/speech` |
|
||||
| `breeze-tts2.yaml` | `breeze-tts2-bf16.rad` | Breeze-TTS-2 in bf16: speech on `/v1/audio/speech` and live over `/v1/audio/speech/stream`, on one card (`RADIANCE_GPU`) |
|
||||
|
||||
The container names are the files the README's model table downloads or converts.
|
||||
|
||||
|
||||
+273
-25
@@ -276,6 +276,8 @@ and runs.
|
||||
| `embgemma2` | EmbeddingGemma 2, an embedding model (§5.6) |
|
||||
| `qwenimage21` | Qwen-Image 2.1 and 2.1-Turbo, an image model (§5.6) |
|
||||
| `qwen3asr_bf16` | Qwen3-ASR, speech to text from the checkpoint as it ships (§5.14) |
|
||||
| `minimaxmusic3` | MiniMax-Music3, songs from a description and lyrics (§5.15) |
|
||||
| `breeze` | Breeze-TTS-2, speech from text and an optional description of the voice (§5.15) |
|
||||
|
||||
**4. Falling back to the reference library is fatal.** If any op resolves to `libref`, the engine
|
||||
refuses to start and names the ops, because serving from it is orders of magnitude slower with nothing
|
||||
@@ -389,6 +391,16 @@ rad-convert /srv/models/Qwen/Qwen-Image-2.1 -o qwen-image-2.1-fp8.rad \
|
||||
--recipe data/recipes/qwen-image-2.1-fp8.recipe
|
||||
rad-convert /srv/models/Qwen/Qwen-Image-2.1-Turbo -o qwen-image-2.1-turbo-fp8.rad \
|
||||
--recipe data/recipes/qwen-image-2.1-fp8.recipe
|
||||
|
||||
# MiniMax-Music3, songs (§5.15): the diffusers pipeline directory is the checkpoint (language model,
|
||||
# depth decoder, condition encoder, DiT, vocoder, tokenizer); bf16 throughout (21 GB, one card or two)
|
||||
rad-convert /srv/models/MiniMaxAI/MiniMax-Music3 -o minimax-music3-bf16.rad \
|
||||
--recipe data/recipes/minimax-music3-bf16.recipe
|
||||
|
||||
# Breeze-TTS-2, speech (§5.15): the release directory, its codec in audio_tokenizer/ read with it;
|
||||
# bf16 (6 GB, one card)
|
||||
rad-convert /srv/models/BreezeBlue/Breeze-TTS-2 -o breeze-tts2-bf16.rad \
|
||||
--recipe data/recipes/breeze-tts2-bf16.recipe
|
||||
```
|
||||
|
||||
A checkpoint directory's `model.safetensors.index.json` decides which shard each tensor is read
|
||||
@@ -409,18 +421,21 @@ dequantisation where the architecture's kernels read another form, and NVFP4 alw
|
||||
| `quark`, MXFP4 weights (fp4, per_group 32, e8m0) | `fp4_e2m1*e8m0[1x32]` | byte for byte: the same codes and exponents. A checkpoint of this form is also served as it stands (§3.4) |
|
||||
| `paroquant_mxfp4` (z-lab's ParoQuant on the MXFP4 grid: `format mxfp4`, `mxfp4_block 32`, `group_size 128`) | `fp4_e2m1*e8m0[1x32]/givens` | the codes and exponents byte for byte, plus the learned rotation as the encoding's `givens` tables: per checkpoint tensor the Givens pairs (made whole-row columns), angles and `1 / channel_scales`, a fused gate\|up or qkv\|z carrying one set a part. Convert-time only (the tables are built, not mapped); served by the rotating activation quantiser `givens_dense_quant` and the MXFP4 GEMM (docs/OPS.md). Its fp8 heads and embedding (one f32 scale a row) are read exactly, for a recipe's `cast`/`rtn` rule |
|
||||
| `paroquant`, `format int5-bitplane` (bits 5, group 128) and z-lab's plain `paroquant` (bits 4, group 128) | `u5*f16[1x128]-u8[1x128]/givens` and `u4*f16[1x128]-u8[1x128]/givens` | the AWQ-packed low nibbles (plus the fifth-bit plane) re-laid as a code bit stream along K, the f16 scales and integer zero points transposed to `[N, K/128]`, and the rotation as the `givens` tables above. Convert-time only; served by `givens_rotate` and `gemm_nt_q` at `w5a16` / `w4a16_asym` over an f16 activation (docs/OPS.md) |
|
||||
| `compressed-tensors`, `format: pack-quantized` with every config group 4-bit `int` weights, `symmetric`, `strategy: group`, not `dynamic`, no `actorder` and no `input_activations` (e.g. Google's Gemma 4 QAT w4a16-ct) | `i4*<scale>[1xG]`, G the groups' one group size | `X.weight_packed` (int32 `[N, K/8]`, eight codes a word from the low bits, offset 8) made signed, beside `X.weight_scale` (`[N, K/G]`, f16, bf16 or f32) as shipped. A zero point is refused by name, and an `X.weight_shape` must state the codes' `[N, K]`. Convert-time only; `data/recipes/gemma4-31b-dense-w4a8.recipe` re-quantises the group-32 release to the group-128 grid the w4a8 kernels read |
|
||||
| `auto-round` with `packing_format: auto_round:auto_gptq`, and `gptq` (v1) | `i4*bf16[1x128]` or `i8*bf16[1x128]` | the GPTQ-packed codes transposed and made signed, the f16 scales rounded to bf16. Symmetric, group 128 or a multiple of it (per channel included), no act-order. Convert-time only, because the scales are not served as shipped |
|
||||
| `compressed-tensors`, `format: pack-quantized` with every config group 4-bit `int` weights, `strategy: group`, not `dynamic`, no `input_activations`, `actorder` none, `static` or `weight` (e.g. Google's Gemma 4 QAT w4a16-ct, ukisai's Swift 1.5 27B INT4) | `i4*<scale>[1xG]`, G the groups' one group size | `X.weight_packed` (int32 `[N, K/8]`, eight codes a word from the low bits, offset 8) made signed, beside `X.weight_scale` (`[N, K/G]`, f16, bf16 or f32) as shipped. Act-order `static`/`weight` keeps each group's columns together and reads as none; `group`/`dynamic` reorders the groups and is refused by name, as is an `X.weight_g_idx` that moves a column. An `X.weight_shape` must state the codes' `[N, K]`. Convert-time only; `data/recipes/gemma4-31b-dense-w4a8.recipe` re-quantises the group-32 release to the group-128 grid the w4a8 kernels read, `data/recipes/q38-27b-w4a16.recipe` serves a group-128 one at its own numbers |
|
||||
| the same with `symmetric: false` (W4A16_ASYM, as llm-compressor's AWQ writes it; e.g. ukisai's Swift 1.5 27B W4A16-AWQ) | `u4*<scale>[1xG]-u4[1xG]` | the stored nibbles as the codes and `X.weight_zero_point` (int32 `[N/8, G]`, eight zero points a word along N, offset 8) as the zero plane, so `(u - z) * s` is compressed-tensors' `(q - zero_point) * scale` bit for bit |
|
||||
| `auto-round` with `packing_format: auto_round:auto_gptq`, and `gptq` (v1) | `i4*bf16[1x128]` or `i8*bf16[1x128]` | the GPTQ-packed codes transposed and made signed, the f16 scales rounded to bf16 (the routed-expert GEMMs' scale). Symmetric, group 128 or a multiple of it (per channel included), no act-order. Convert-time only, because the scales are not served as shipped; an `import` rule keeps them in their shipped f16 (`data/recipes/q38-27b-w4a16.recipe`) |
|
||||
| `compressed-tensors` with an `nvfp4-pack-quantized` config group (`weights`: 4-bit float, group 16) | `fp4_e2m1*f32[1x16]` | the packed e2m1 codes beside an f32 scale per 16 of K, `weight_scale / weight_global_scale`: the global scale is a divisor, as compressed-tensors' dequantise and vLLM read it. Each piece keeps its own global, so a fused gate\|up reads both exactly. No kernel serves NVFP4, so every NVFP4 weight takes a recipe rule (`data/recipes/q38-27b-nvfp4-df2.recipe` makes it MXFP4) |
|
||||
| `compressed-tensors` whose config groups are all `float-quantized` with 8-bit `float` weights | `fp8_e4m3*<scale>[1x*]` or `[RxC]` | nothing is imported: each `X.weight` reads stock as FP8 with `X.weight_scale` beside it, one scale a row (`[N, 1]` or `[N]`, the channel strategy) or a block plane; a per-tensor scale is refused at the weight. The quantisation is still the tool's, so the family's quantised plugin serves it |
|
||||
| `compressed-tensors` whose config groups are all `float-quantized` with 8-bit `float` weights | `fp8_e4m3*<scale>[1x*]` or `[RxC]` | nothing is imported: each `X.weight` reads stock as FP8 with `X.weight_scale` beside it, one scale a row (`[N, 1]` or `[N]`, the channel strategy) or a block plane; a per-tensor scale (`[1]`) is written once a row, so it is imported rather than byte for byte. The quantisation is still the tool's, so the family's quantised plugin serves it |
|
||||
| `modelopt` (NVIDIA ModelOpt) with `quant_algo` `NVFP4`, `FP8`, or `MIXED_PRECISION` whose `quantized_layers` are each NVFP4 (group 16) or FP8 (e.g. ukisai's Swift 1.5 27B NVFP4) | NVFP4: `fp4_e2m1*f32[1x16]`; FP8: `fp8_e4m3*f32[1x*]` | NVFP4: `X.weight` (U8 `[N, K/2]`, the even k in the low nibble) beside an f32 scale per 16 of K, `float(X.weight_scale) * X.weight_scale_2`: ModelOpt's second level multiplies, where compressed-tensors' global scale divides. FP8: `X.weight` E4M3 with its one f32 `X.weight_scale`, written once a row. `X.input_scale` (a static activation scale) is not read: activations are quantised from their own values. Any other algorithm is refused by name. No kernel serves NVFP4, and none an FP8 scale per tensor, so both take recipe rules (`data/recipes/q38-27b-modelopt-nvfp4.recipe`) |
|
||||
|
||||
The width is read per tensor, so a release mixing int4 experts with int8 projections imports both.
|
||||
A mixed-precision release (NVFP4 MLPs beside FP8 or bf16 linears, the usual NVFP4 layout) reads
|
||||
every weight by its own form: a weight without `X.weight_packed` is not NVFP4 and reads stock, its
|
||||
`float-quantized` FP8 with the per-row (`[N, 1]`) or block scale beside it. A compressed-tensors
|
||||
release whose groups are all `float-quantized` FP8 reads the same way, with nothing to import.
|
||||
What an import cannot read (an asymmetric zero point, an act-order index, a group under 128, a
|
||||
missing or zero global scale, a compressed-tensors format not listed here) is refused by name. The release's `quantization_config` names the tool, not a served
|
||||
What an import cannot read (a GPTQ zero point other than the symmetric one, an act-order index
|
||||
that reorders groups, a GPTQ group under 128, a missing or zero global scale, a format or
|
||||
algorithm not listed here) is refused by name. The release's `quantization_config` names the tool, not a served
|
||||
form, so it is kept as `imported_quantization_config.*`, and the model is served by its family's
|
||||
quantised plugin (`qwen35_fp8` for Qwen3.8-27B, `qwen4exp_fp8` for Flash-Next).
|
||||
|
||||
@@ -430,8 +445,17 @@ the source, so one recipe covers a mixed release in one pass. NVFP4 to MXFP4 rou
|
||||
scales per 16 to a power of two per 32), so it loses more than MXFP4 made from the bf16 original:
|
||||
against the block-fp8 Qwen3.8-27B on the same four documents, unsloth's NVFP4 release made MXFP4
|
||||
scores mean KL 0.287 and top-1 agreement 87.5%, AMD's calibrated Quark MXFP4 container 0.206 and
|
||||
89.3%. Prefer the Quark container unless you need that particular checkpoint. The recipes of
|
||||
record:
|
||||
89.3%. Prefer the Quark container unless you need that particular checkpoint.
|
||||
|
||||
Where the kernels read the release's own numbers in another spelling, a recipe's `import` rule
|
||||
(rad-convert's own, docs/TOOLS.md) writes them so instead of quantising again. An int4 W4A16
|
||||
release reaches the 4-bit GEMMs that way, `blk.*.weight import codes=u4 zero=u4 scale=f16`: u4
|
||||
codes, an f16 scale and a u4 zero point per 128 of K, a symmetric grid's codes made unsigned under a
|
||||
zero of 8. Every code and zero point is the release's and every scale is exact in f16 except a bf16
|
||||
scale below f16's normal range (2^-14), which rounds; rad-convert reports how many did. Qwen3.8-27B
|
||||
serves them on `gemm_nt_q` at `w4a16_asym` over the input cast to f16 up to 64 rows a step and at
|
||||
`w4a8i8_asym` over an int8 activation with a scale per (row, 128) above (docs/OPS.md). The recipes
|
||||
of record:
|
||||
|
||||
```sh
|
||||
# AMD's Quark AWQ-MXFP4 Qwen3.8-27B with the DFlash2 drafter
|
||||
@@ -451,6 +475,17 @@ rad-convert /srv/models/Launch80/Qwen3.8-27B-PARO-int5 --draft-model /srv/models
|
||||
rad-convert /srv/models/unsloth/Qwen3.8-27B-NVFP4 --draft-model /srv/models/z-lab/Qwen3.8-27B-DFlash2 \
|
||||
--recipe data/recipes/q38-27b-nvfp4-df2.recipe -o q38-27b-nvfp4-df2.rad
|
||||
|
||||
# An int4 W4A16 Qwen3.8-27B (compressed-tensors AWQ or GPTQ, AutoRound's auto_gptq; here ukisai's
|
||||
# Swift 1.5 W4A16-AWQ, and its INT4 and W4A16-AutoRound the same way): the shipped grids on the
|
||||
# 4-bit GEMMs, the head block fp8
|
||||
rad-convert /srv/models/ukisai/Swift-1.5-Qwen3.8-27b-W4A16-AWQ \
|
||||
--recipe data/recipes/q38-27b-w4a16.recipe -o swift15-27b-w4a16-awq.rad
|
||||
|
||||
# An NVIDIA ModelOpt NVFP4 Qwen3.8-27B (ukisai's Swift 1.5 NVFP4): the FP8 projections' codes kept
|
||||
# as block fp8, the NVFP4 MLPs made MXFP4, the NVFP4 head block fp8
|
||||
rad-convert /srv/models/ukisai/Swift-1.5-Qwen3.8-27b-NVFP4 \
|
||||
--recipe data/recipes/q38-27b-modelopt-nvfp4.recipe -o swift15-27b-nvfp4.rad
|
||||
|
||||
# An AutoRound int4 Qwen3.8-Flash-Next: its experts imported, its int4 projections made int8
|
||||
rad-convert /srv/models/ukisai/Swift-1.5-Qwen3.8-Flash-Next-W4A16-AutoRound \
|
||||
--recipe data/recipes/qwen4exp-autoround-i8-hc8m.recipe -o swift-autoround.rad
|
||||
@@ -1030,6 +1065,32 @@ hit. Snapshots never take VRAM: each is copied to host memory after the step tha
|
||||
back before the step that resumes from it. `/sessions` shows what is stored, where, and whether the
|
||||
linear half is served.
|
||||
|
||||
**How many snapshots.** The snapshot store (`--checkpoint-slots`) is shared by every conversation,
|
||||
running or not, and a conversation without a snapshot under its next prompt reuses nothing. With
|
||||
`auto`, the default, each of `--max-num-seqs` gets what `--checkpoint-policy` keeps for one
|
||||
`--max-model-len` conversation plus one for the checkpoint its running turn writes: geometric
|
||||
backoff keeps 9 for a 200K-token conversation at the default 2048-token interval, so 10 a sequence,
|
||||
80 at `--max-num-seqs 8`. The store is pinned for the life of the server, so `auto` takes at most an
|
||||
eighth of host memory (and never less than 8 slots where the host can pin them), and never more than
|
||||
the host can pin after the host pools, the host tier and the activation arenas. The startup log says
|
||||
what it chose; Flash-Next at `--tp 2 --max-num-seqs 8` on a host with 128 GB of RAM:
|
||||
|
||||
```
|
||||
checkpoint slots: auto: 80 linear-state snapshot(s) of 113.50 MiB in pinned host memory (8.87 GiB),
|
||||
none of it on the card; 10 a sequence for --max-num-seqs 8: geometric-backoff keeps 9 for a
|
||||
200000-token session at a 2048-token interval, and one more for a running turn
|
||||
```
|
||||
|
||||
A line that says `held to an eighth of host memory`, or (a warning) `held to what the host can
|
||||
pin`, means the store is smaller than the policy wants; `--checkpoint-slots N` sets the count
|
||||
outright. An agent client with subagents keeps more
|
||||
conversations alive than it runs at once: a parent waits while its subagent runs, and in a store
|
||||
much smaller than `auto`'s the subagent's snapshots displace the parent's, whose next turn then
|
||||
prefills its whole history again. `radiance:prefix_hit_cut_tokens_total` counts the prompt tokens
|
||||
the attention cache held and admission computed again for want of a snapshot, and
|
||||
`radiance:prefix_cache_ckpt_evictions_by_reason_total{reason="store_full"}` the snapshots a full
|
||||
store gave up; `scripts/agentreplay.py` drives that workload against a server.
|
||||
|
||||
### 4.9 Request defaults
|
||||
|
||||
Each default applies only to a request that does not name the field.
|
||||
@@ -1136,10 +1197,13 @@ radiance --model base.rad --lora mytune=/adapters/mytune --lora other=/adapters/
|
||||
```
|
||||
|
||||
Each request picks one by `model`: `"model": "mytune"` runs with that adapter, the served model's
|
||||
own name (or no name) runs the base. Requests for different adapters and for the base share one
|
||||
batch. The base weights are never touched, whatever their encoding; each targeted GEMM is followed
|
||||
by `y += scale * B(A x)` in bf16 adapter weights and f32 accumulation, on every rank before the
|
||||
all-reduce, so it works at any `--tp`.
|
||||
own name (or no name) runs the base, and any other name is a 404 that lists what is served.
|
||||
Requests for different adapters and for the base share one batch. The base weights are never
|
||||
touched, whatever their encoding; each targeted GEMM is followed by `y += scale * B(A x)` in bf16
|
||||
adapter weights and f32 accumulation, on every rank before the all-reduce, so it works at any
|
||||
`--tp`, and on the CPU (libavx) as on a card. A step that carries no adapter request runs no adapter
|
||||
op, so base requests cost what they cost without `--lora`; the one exception is the fused GEMM
|
||||
below.
|
||||
|
||||
- `--max-loras N` reserves N slots (default: the number of `--lora`). Each slot holds one adapter's
|
||||
A and B for every targeted weight; startup prints the size. With free slots, adapters load and
|
||||
@@ -1156,18 +1220,21 @@ all-reduce, so it works at any `--tp`.
|
||||
already on the card may still read it), which a load waits for by itself.
|
||||
- `--max-lora-rank R` (default 16) is the rank every slot is sized for. A smaller rank is padded,
|
||||
a larger one refused.
|
||||
- `--lora-target-modules q_proj,k_proj,...` names what adapters may target. Default: what the
|
||||
`--lora` adapters target. Needed with `--max-loras` and no `--lora`.
|
||||
- `--lora-target-modules q_proj,k_proj,...` names what adapters may target, as module leaf names.
|
||||
Default: what the `--lora` adapters target. Needed with `--max-loras` and no `--lora`. A name
|
||||
that is no trunk linear of the model is refused at startup.
|
||||
- `/v1/models` lists each adapter as its own model, `parent` naming the base.
|
||||
- The prefix cache keys every block on the adapter, so KV is never shared across adapters, and a
|
||||
reload under the same name starts cold.
|
||||
|
||||
Refused at startup or load, by name: DoRA, embedding or `lm_head` LoRA, `modules_to_save`, trained
|
||||
biases, a module the base does not have, and a module some op cannot carry -- a routed MoE expert,
|
||||
a rotated (ParoQuant) or otherwise transformed weight. A fused GEMM over a targeted weight (the fp8
|
||||
gated gate_up fold) is not used while LoRA is on; the unfused pair runs instead. A drafter keeps the
|
||||
base's weights: proposals are still verified by the adapter, so output is exact and only the
|
||||
acceptance rate can drop.
|
||||
biases, PEFT's `layer_replication`, QA-LoRA and activated LoRA, a module the base does not have, and
|
||||
a module some op cannot carry -- a routed MoE expert, a rotated (ParoQuant) or otherwise transformed
|
||||
weight, a GEMM fed int8 codes in the WMMA's step order (`w4a8`, `w8a8`, `w2a8`). Adapters serve models that generate text: an
|
||||
image, audio or video generator and an embedding model refuse `--lora` and `--max-loras`. A fused
|
||||
GEMM over a targeted weight (the fp8 gated gate_up fold) is not used while LoRA is on, for base
|
||||
requests too; the unfused pair runs instead. A drafter keeps the base's weights: proposals are
|
||||
still verified by the adapter, so output is exact and only the acceptance rate can drop.
|
||||
|
||||
### 4.10 Every flag
|
||||
|
||||
@@ -1229,7 +1296,7 @@ acceptance rate can drop.
|
||||
| `--deterministic` | off | pin placement to the loader's plan, so the resident set cannot change under the heat engine |
|
||||
| `--checkpoint-interval N` | 2048 | linear-attention state checkpoint interval, in tokens |
|
||||
| `--prefill-span N` | 1 | checkpoint intervals one step may carry of a prefill alone in its step, from the prompt's second interval on; needs `--max-num-batched-tokens` of N intervals. Every other step is planned at the budget less the extra intervals, and the checkpoints inside a span are not written (§4.5) |
|
||||
| `--checkpoint-slots N` | 8 | linear-state (hybrid) or sliding-window snapshots the server may hold at once, in total, not per sequence. They live in pinned host memory, allocated at startup: one slot is a snapshot of every rank's shard (113 MB on Flash-Next at `--tp 2`; on Gemma 4 31B the 1024-token window of every sliding layer, 406 MiB at `--tp 2`). A full store retires its least recently used snapshot. A store the host memory cannot hold or pin stops the start, and a table placed in host memory leaves room for it; `0` serves with none, every prefix hit then prefilling from the start |
|
||||
| `--checkpoint-slots N` | auto | linear-state (hybrid) or sliding-window snapshots the server may hold at once, in total, not per sequence. They live in pinned host memory, allocated at startup: one slot is a snapshot of every rank's shard (113 MB on Flash-Next at `--tp 2`, 144 MiB on Qwen3.8-27B; on Gemma 4 31B the 1024-token window of every sliding layer, 406 MiB at `--tp 2`). `auto` gives each of `--max-num-seqs` what `--checkpoint-policy` keeps for a `--max-model-len` session plus one (10 at 200K tokens under geometric backoff), within an eighth of host memory and what the host can pin; the startup line and the report say what it chose and why (§4.8). A full store retires its least recently used snapshot. A count is taken as given: a store the host memory cannot hold or pin stops the start, and a table placed in host memory leaves room for it; `0` serves with none, every prefix hit then prefilling from the start |
|
||||
| `--checkpoint-policy NAME` | geometric-backoff | also `tip-only`, `keep-all` |
|
||||
| `--no-prefix-cache` | prefix cache on | disable prefix caching |
|
||||
|
||||
@@ -1313,6 +1380,8 @@ a model that takes no images or video. A Qwen-VL container that states none uses
|
||||
| `--kld-ref DIR` | score this model against the reference in `DIR`: mean, median, 99/99.9/99.99th percentile KL divergence and top-1 agreement |
|
||||
| `--kld-corpus FILE` | JSONL, one `{"prompt", "score_from"?, "source"?}` a line; `--kld-record` only |
|
||||
| `--kld-out FILE` | the `--kld-ref` report as JSON, and every position's numbers in `FILE.rows` |
|
||||
| `--kld-lora NAME` | run the documents through the `--lora` adapter `NAME` (§4.9.1), e.g. against a reference recorded from the merged checkpoint |
|
||||
| `--kld-lora-sources PREFIX` | with `--kld-lora`, only the documents whose `source` starts with `PREFIX` run through the adapter; the rest run as the base, in the same steps |
|
||||
|
||||
**Diagnostics**
|
||||
|
||||
@@ -1341,6 +1410,9 @@ a model that takes no images or video. A Qwen-VL container that states none uses
|
||||
| `POST /v1/systemone` | LiquidAI d1's decisions over a state: named yes/no, choice and score questions answered as probabilities, nothing generated; needs a container converted as d1, else 501 (§5.13) |
|
||||
| `POST /v1/audio/transcriptions` | OpenAI's speech to text, for a model whose plugin transcribes (Qwen3-ASR), else 501 (§5.14) |
|
||||
| `GET /v1/realtime` (WebSocket) | OpenAI's realtime transcription session: audio streamed in, the words back as they are spoken (§5.14) |
|
||||
| `POST /v1/audio/speech` | OpenAI's speech API, whole or streamed: speech from a speech model (Breeze-TTS-2), `instructions` describing the voice; songs from a music model (MiniMax-Music3), `input` the lyrics and `instructions` the song; else 501 (§5.15) |
|
||||
| `GET /v1/audio/speech/stream` (WebSocket) | vLLM-Omni's realtime speech session: text streamed in, each sentence's audio streamed out as soon as the sentence is complete; needs an audio generation model (§5.15) |
|
||||
| `POST /v1/videos`, `GET /v1/videos[/:id[/content]]`, `DELETE /v1/videos/:id` | OpenAI's video jobs: a video with its soundtrack from a prompt, made in the background and downloaded as MP4; needs a video model (MiniMax-H3), else 501 (§5.16) |
|
||||
| `POST /v1/messages`, `POST /v1/messages/count_tokens` | Anthropic's Messages API, for Claude Code and the Anthropic SDKs (§5.9, §5.11) |
|
||||
| `POST /v1/responses`, `POST /v1/responses/input_tokens` | OpenAI's Responses API, for Codex and the OpenAI SDKs' `responses` client (§5.9) |
|
||||
| `POST /completion`, `/completions`, `POST /infill` | llama-server's native completion and fill-in-the-middle, for llama.vim, llama.vscode and clients of llama-server's own API (§5.9) |
|
||||
@@ -1363,9 +1435,10 @@ a model that takes no images or video. A Qwen-VL container that states none uses
|
||||
Methods follow vLLM's: `/tokenize` is POST because its input is a body, and `/ping` answers GET and
|
||||
POST because load balancers differ. As in llama-server, `/chat/completions`,
|
||||
`/chat/completions/input_tokens`, `/embeddings`, `/images/generations`, `/images/edits`,
|
||||
`/audio/transcriptions`, `/models`, `/responses` and `/responses/input_tokens` also answer without
|
||||
`/v1`, for a client configured with the bare host as its base URL; `/completions` without `/v1` is
|
||||
llama-server's native completion, as it is there. A path nothing serves is a JSON 404.
|
||||
`/audio/transcriptions`, `/audio/speech`, `/models`, `/responses` and `/responses/input_tokens` also
|
||||
answer without `/v1`, for a client configured with the bare host as its base URL; `/completions`
|
||||
without `/v1` is llama-server's native completion, as it is there. A path nothing serves is a JSON
|
||||
404.
|
||||
|
||||
A text prompt to `/v1/completions`, `/v1/embeddings` or `/tokenize` reads the model's control tokens
|
||||
as tokens, as vLLM and llama.cpp do: a client that renders its own chat template can send
|
||||
@@ -1702,7 +1775,7 @@ fall into four kinds:
|
||||
| `post_sampling_probs` | false | logprobs are the raw distribution's; the sampler's are not returned |
|
||||
| `best_of` | ≤ 1 | not implemented |
|
||||
| `suffix` | empty | infilling through `/v1/completions` is not implemented |
|
||||
| `lora` | empty | out of scope |
|
||||
| `lora` | empty | an adapter is chosen by `model` (§4.9.1), not by a per-request list |
|
||||
| `modalities`, `audio` | `["text"]`, null | output other than text is not implemented |
|
||||
| `n_indent`, `t_max_predict_ms`, `return_tokens` | 0, ≤ 0, false | not implemented (`return_tokens` is served on `/completion`, §5.9) |
|
||||
| `grammar_lazy`, `grammar_triggers`, `preserved_tokens` | off, empty, empty | the chat format decides them |
|
||||
@@ -2083,6 +2156,181 @@ socket.
|
||||
|
||||
---
|
||||
|
||||
### 5.15 Speech and music: `/v1/audio/speech`
|
||||
|
||||
An audio generation model answers OpenAI's `POST /v1/audio/speech`: a speech model (Breeze-TTS-2)
|
||||
speaks `input`, in a voice `instructions` may describe; a music model (MiniMax-Music3) sings `input`
|
||||
as lyrics, as `instructions` describe the song (SGLang-Omni's reading of the route). Both are
|
||||
converted from their release directories (§3.2).
|
||||
|
||||
#### Speech: Breeze-TTS-2
|
||||
|
||||
```sh
|
||||
radiance --model breeze-tts2-bf16.rad # one card
|
||||
|
||||
curl -s http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d '{
|
||||
"input": "The quick brown fox jumps over the lazy dog."}' -o fox.wav # 24 kHz mono, 16-bit
|
||||
curl -s http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d '{
|
||||
"input": "It was a bright cold day in April.",
|
||||
"instructions": "A calm, warm female narrator, speaking slowly.", "guidance_scale": 4}' -o april.wav
|
||||
```
|
||||
|
||||
- **`input`** is the text to speak, as written. **`instructions`**, optional, describe the voice
|
||||
(who speaks, how); BreezeBlue suggests `guidance_scale` 4 with them, against a voice without the
|
||||
description (1, the default, is none).
|
||||
- **The length** is `duration` in seconds or `max_new_tokens` in frames (12.5 a second), up to two
|
||||
minutes; the model ends the speech at the end of the text. The prompt holds at most 512 tokens.
|
||||
- **`seed`**, **`response_format`**, **`speed`** and **`voice`** are read as for music below
|
||||
(`voice` is ignored here too: the instructions say who speaks); `num_inference_steps` is refused
|
||||
(the model has no denoiser). Cloning a voice from a recording is not served.
|
||||
|
||||
Speech is played four frames (0.32 s) at a time as it is made, so the streamed forms below carry it
|
||||
as it is spoken. On one R9700 a sentence is made at 0.6 of the time it plays (5.1 s of speech in
|
||||
3.1 s), and a stream's first audio comes 0.21 s after the request; four speak at once at about the
|
||||
speed they play (43 s of speech in 12.1 s). Breeze-TTS-2 is licensed for research and
|
||||
non-commercial use only, and BreezeBlue counts hosting it as an API as commercial.
|
||||
|
||||
#### Music: MiniMax-Music3
|
||||
|
||||
```sh
|
||||
radiance --model minimax-music3-bf16.rad --tp 2
|
||||
|
||||
curl -s http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d '{
|
||||
"input": "[verse]\nMorning light filtering through the pine\n[chorus]\nSoftly the world begins to breathe",
|
||||
"instructions": "Genre: acoustic pop. BPM: 96. Warm and intimate. Vocals: soft female lead.",
|
||||
"duration": 30, "seed": 7}' -o song.wav # 44.1 kHz stereo, 16-bit
|
||||
curl -sN http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d '{
|
||||
"input": "...", "instructions": "...", "stream_format": "audio",
|
||||
"response_format": "pcm"}' | ffplay -nodisp -f s16le -ar 44100 -ch_layout stereo - # as made
|
||||
```
|
||||
|
||||
- **`input`** (the lyrics, with the model's section tags such as `[verse]` and `[chorus]`) and
|
||||
**`instructions`** (genre, tempo, key, mood, vocals, instruments) are both required. Each is
|
||||
rewritten into the form the model was trained on and read as plain text, so neither can carry
|
||||
the model's control tokens.
|
||||
- **The length** is `duration` in seconds or `max_new_tokens` in frames (25 a second), up to six
|
||||
minutes; without either the song runs until the model ends it, which it usually does at the end
|
||||
of the lyrics. Give one, not both.
|
||||
- **`seed`** makes a song repeatable: the same seed, text and length give the same samples again
|
||||
on the same deployment. Another card count rounds differently, and a song can then take another
|
||||
turn. Absent or -1 picks one; the `X-Seed` response header says which.
|
||||
- **`num_inference_steps`** (30) and **`guidance_scale`** (1.7) are the denoiser's.
|
||||
- **`response_format`** is `wav` (the default) or `pcm`, 16-bit little-endian at the model's rate
|
||||
and channels, which the `X-Audio-Sample-Rate` and `X-Audio-Channels` headers state. `voice` is
|
||||
accepted and ignored (the description says who sings); `speed` must be 1.
|
||||
|
||||
A song's first window comes once its 200 frames are written and denoised; each later one follows
|
||||
a hundred frames on. On two R9700s a song is made at about the speed it plays: 10 s of audio in
|
||||
10.8 s with the first audio at 8.5 s, 12 s in 12.7 s; on one card, 4 s in 7.3 s. Up to four songs
|
||||
are made at once.
|
||||
|
||||
#### Streaming
|
||||
|
||||
Without a stream field the response is the whole audio once it is finished. A song is played eight
|
||||
seconds at a time (a 200-frame window, a new one every 100 frames), speech four frames at a time,
|
||||
and two streamed forms send each piece as it is played, as vLLM-Omni's speech route does:
|
||||
|
||||
- `"stream_format": "audio"` sends the bytes themselves; a `wav` stream's header states no length.
|
||||
- `"stream": true` or `"stream_format": "sse"` sends Server-Sent Events: `speech.audio.delta` with
|
||||
base64 PCM in `audio` (`response_format` must be `pcm`), then `speech.audio.done` with the usage
|
||||
(prompt tokens in, frames out), or `speech.audio.error`.
|
||||
|
||||
#### Live: `/v1/audio/speech/stream`
|
||||
|
||||
The same model speaks text while it is still being written, over a WebSocket at
|
||||
`/v1/audio/speech/stream` speaking vLLM-Omni's realtime speech protocol: the client streams the
|
||||
text in (a language model's reply token by token, say), and each sentence is spoken as soon as it
|
||||
is complete, so the first audio waits for the first sentence rather than the whole text.
|
||||
|
||||
| client sends | server answers |
|
||||
|---|---|
|
||||
| `session.config` — first, and again only between utterances | nothing, or `error` naming the field it refused |
|
||||
| `input.text` `{"text": "..."}` — any piece of the text | for each sentence it completes: `audio.start`, the audio as binary messages, `audio.done` |
|
||||
| `input.done` — the utterance's text has ended | the rest of the text as its last sentence, then `session.done` |
|
||||
| `session.close` | the socket closes (1000); a sentence being spoken is cancelled |
|
||||
|
||||
- **`session.config`** takes the fields of `POST /v1/audio/speech` but `input` (`instructions`,
|
||||
`voice`, `seed`, `guidance_scale`, `max_new_tokens` or `duration` for each sentence, `speed`,
|
||||
`num_inference_steps` where the model has a denoiser), checked as that route checks them, and
|
||||
four of its own: `response_format` `pcm` (the default) or `wav`; `stream_audio`, false (the
|
||||
default) for one binary message a sentence or true for the audio as the model makes it;
|
||||
`split_granularity`, `sentence` (the default), `clause` (also at commas and semicolons) or `none`
|
||||
(the whole utterance at `input.done`); and `text_input_mode`, whose only value here is
|
||||
`buffered` (vLLM-Omni's `commitment` mode is refused by name). Every sentence is one request made
|
||||
with these fields; with a `seed`, every sentence uses it.
|
||||
- **`audio.start`** carries `utterance_index`, `sentence_index` (from 0 in each utterance),
|
||||
`sentence_text`, `format`, `sample_rate` and `channels`. The audio is 16-bit little-endian PCM at
|
||||
that rate and channel count; a `wav` sentence is one file, whose header states its length, or
|
||||
while it streams a header that states none before the samples. **`audio.done`** carries
|
||||
`utterance_index`, `sentence_index`, `total_bytes` (of the binary messages) and `error`, true when
|
||||
the sentence failed, after an `error` event saying why. **`session.done`** carries
|
||||
`utterance_index` and `total_sentences`; the session then takes the next utterance.
|
||||
- **Sentences** end after `.`, `!` and `?` followed by whitespace, and after their CJK (`。!?…`),
|
||||
Indic (`।॥`) and Arabic (`؟`) forms followed by anything, since those scripts put no space there;
|
||||
`clause` also ends one after `,` `;` and `,;،؛`. A decimal point, a common abbreviation (Dr.,
|
||||
Mr., e.g., etc.) and an initial (J., J.R.) end none, and a run of punctuation or a closing quote
|
||||
or bracket stays with its sentence. A stop at the end of what has arrived waits for the next
|
||||
piece, or for `input.done`.
|
||||
|
||||
**Limits.** A server holds as many sessions as the model has lanes (four for both models), each
|
||||
holding one admission place (`--max-queued-requests`) for its whole life; a session refused either
|
||||
way gets an `error` event and a 1013 close. A session speaks its sentences one at a time, in order.
|
||||
An utterance holds at most 128 KiB of text that no sentence has ended yet; a piece past that is
|
||||
refused with an `error` and dropped. A message that is not JSON, or a binary one, is an `error`,
|
||||
and the session goes on.
|
||||
|
||||
### 5.16 Video: `/v1/videos`
|
||||
|
||||
A video generation model (MiniMax-H3) answers OpenAI's video jobs: `POST /v1/videos` queues a video
|
||||
with its stereo soundtrack and answers at once with the video object; `GET /v1/videos/{id}` reports
|
||||
its `status` (`queued`, `in_progress`, `completed`, `failed`) and `progress` (0 to 100);
|
||||
`GET /v1/videos/{id}/content` downloads the MP4 once it is completed (`?variant=thumbnail` gives the
|
||||
first frame as WebP). `GET /v1/videos` lists the jobs, newest first (`limit`, `after`, `order`), and
|
||||
`DELETE /v1/videos/{id}` removes one, cancelling it if it is still running.
|
||||
|
||||
```sh
|
||||
radiance --model minimax-h3-fp8.rad --tp 2 --vision-tower-placement ram
|
||||
|
||||
curl -s http://localhost:8000/v1/videos -H 'Content-Type: application/json' -d '{
|
||||
"prompt": "A red fox trotting through a snowy pine forest, snow crunching underfoot",
|
||||
"seconds": "5", "size": "1344x768", "seed": 7}' # -> {"id": "video_...", "status": "queued", ...}
|
||||
curl -s http://localhost:8000/v1/videos/video_... # poll until "status": "completed"
|
||||
curl -s http://localhost:8000/v1/videos/video_.../content -o fox.mp4
|
||||
```
|
||||
|
||||
- **`prompt`** is read as written, with no template; MiniMax-H3 was trained on long structured
|
||||
descriptions (a shot, its soundscape, its music), which follow it best. At most 2048 tokens.
|
||||
- **`seconds`** is rounded up to the model's length steps (17 frames, 0.71 s, at 24 frames a
|
||||
second): 5.17 to 14.4 seconds, 5.17 by default. The video object's `seconds` is what is made.
|
||||
- **`size`** is the frame's `WIDTHxHEIGHT`: both sides multiples of 32 from 256, at most
|
||||
1344 x 768 pixels of area, at most 4:1. By default 1344x768. SGLang's `target`
|
||||
`{"aspect_ratio": "9:16", "short_edge": 768, "duration_seconds": 8}` lays the model's own canvas
|
||||
over a ratio instead (768 on the short side, the area capped, rounded to 32).
|
||||
- **`seed`** makes a video repeatable on the same deployment (absent or -1 picks one);
|
||||
**`num_inference_steps`** counts sigma grid points as diffusers and SGLang do (50, so 49 model
|
||||
evaluations, by default; at most 65). The model is guidance-distilled, so there is no guidance
|
||||
scale and no negative prompt. A step-distilled release (FastH3, below) runs only the schedule it
|
||||
was trained on: 9 grid points, and any other count is refused with a 400.
|
||||
- Only text is read: `input_reference` and non-empty `conditions` are refused, as is a `task`
|
||||
other than `t2va`. Fields are JSON or a multipart form (OpenAI's clients send the form).
|
||||
|
||||
**FastH3.** FastVideo's FastH3 8-Step V2 (`FastVideo/FastVideo-FastH3-8-Step-V2`) is the same model
|
||||
distilled to eight steps with video sparse attention; it is converted with the same recipe, its text
|
||||
encoder and decoders taken from a MiniMax-H3 container (`data/recipes/minimax-h3-fp8.recipe` says
|
||||
how), served the same way and named `fastvideo-fasth3-8-step-v2`. Its card notes that difficult
|
||||
motion, fine detail and some audio may fall below the base model's; it serves text to video only.
|
||||
|
||||
On two R9700s (`--tp 2`, 300 W) a 5.17 s clip at 1344x768 takes about 68 s with FastH3 and about
|
||||
8.8 minutes with MiniMax-H3's default 50 steps. Both attentions run their scores in int8 and
|
||||
P.V in fp8 (docs/ARCHITECTURES.md); a step's cost grows with the square of the rows, so a longer
|
||||
clip or a larger frame costs more than in proportion. The text encoder and the modulation
|
||||
projections (17.9 GiB a rank) and the token embedding (1.5 GiB a rank) are read from pinned host
|
||||
memory, about 39 GiB of it in all, which `--vision-tower-placement ram` requires at two ranks.
|
||||
|
||||
The MP4 holds H.264 video (yuv420p, BT.709) and AAC audio at 32 kHz stereo. A finished file is kept
|
||||
for an hour (`expires_at`), at most 32 of them. MiniMax-H3's license excludes use in the EU, the UK,
|
||||
the Republic of Korea and the USA without a separate license from MiniMax.
|
||||
|
||||
## 6. Operation
|
||||
|
||||
### 6.1 The dashboard
|
||||
@@ -2265,7 +2513,7 @@ is the part of a log to paste into an issue. Its sections:
|
||||
warning is also printed as a `W` line of its own.
|
||||
|
||||
```
|
||||
I STARTUP REPORT -- radiance 1.7.0
|
||||
I STARTUP REPORT -- radiance 1.8.0
|
||||
I CONFIGURATION -- every option, the value in force, and where it came from
|
||||
I --model /models/flashnext.rad [command line]
|
||||
I --tp 2 [command line]
|
||||
@@ -2310,7 +2558,7 @@ curl -s -H "Authorization: Bearer $KEY" localhost:8000/diagnostics | jq '.findin
|
||||
| `out of memory` / `the carve reserved N of address space and the card would not back it` | Something else is holding VRAM | Check with `rocm-smi` and stop the other process. The budget is stated before allocation, so the log says what it asked for |
|
||||
| `pool allocation refused` with `backing allocation of … refused` on the second card, after the first card's pools succeeded | The VRAM budget is measured before any rank allocates, so a card that refuses its weights pool lost that memory to another process in between (the next line says how much is free now). A refused `host_pool` is pinned memory: every rank pins its own `--host-pool-mib` (twice at `--tp 2`), and the amdgpu driver caps what all processes together pin at RAM less 1/64 and 1.5 GiB. It is locked user memory, which `ttm.pages_limit` does not count | Stop the other process (`rocm-smi --showpids`). For the host pool, keep `--tp` × `--host-pool-mib` under both the cap and the available RAM the refusal names. `amdgpu.no_system_mem_limit=1` lifts the driver's cap, but not the RAM |
|
||||
| `host_pool: backing allocation of … refused: rad_dev_alloc(…): locking piece K of N`, and `failed to pin userptr` in `journalctl -k` | The IOMMU would not DMA-map one piece of the pinned host pool. Pinned host memory is locked in pieces of at most 1 GiB because an Intel VT-d host in scalable mode can refuse a single pin above about 2.5 GiB; a failing piece means this machine refuses smaller pins still, or a total its IOMMU will not map | Keep IOMMU translation on: `iommu=pt` lets every pin through, but on such a host it can also remove peer access between the cards, moving every all-reduce onto the slower host-memory path. Report the kernel version, the IOMMU mode and the refusal line |
|
||||
| `device: a synchronisation has waited 5 s; the queues:` with the packet each queue is on, then `device: no queue has advanced`, then `HW Exception … GPU Hang` and a reset in `journalctl -k` (`MES failed to respond to msg=REMOVE_QUEUE`, `MODE1 reset`) | The card stopped running the queue; the kernel named is where it stopped, not necessarily why. The driver resets the whole card, VRAM included, and the engine is aborted. The usual cause is compute wave save/restore being off: the driver evicts a process's queues whenever host memory the card maps moves under memory pressure, and with `cwsr_enable=0` it cannot preempt a running queue, so the eviction waits on a queue that never drains. Clock instability (a voltage offset) is the other cause seen on R9700s. If the follow-up line says the queues advanced, the wait was long, not stuck | `cat /sys/module/amdgpu/parameters/cwsr_enable` must print `1` (the startup report warns when it is `0`); set `amdgpu.cwsr_enable=1`, rebuild the initramfs and reboot. Remove any `OD_VDDGFX_OFFSET` (`pp_od_clk_voltage`). A reset restores the power cap, fan curve and voltage offset to firmware defaults; re-apply them before every start. Keep the devcoredump under `/sys/class/drm/card*/device/devcoredump/data`, which a reboot loses. `docker inspect` shows exit code 0 for a container Docker already restarted, whatever ended the old process |
|
||||
| `device: a synchronisation has seen no queue advance for 5 s; the queues:` with the packet each queue is on, then `device: no queue has advanced`, then `HW Exception … GPU Hang` and a reset in `journalctl -k` (`MES failed to respond to msg=REMOVE_QUEUE`, `MODE1 reset`) | The card stopped running the queue; the kernel named is where it stopped, not necessarily why. The driver resets the whole card, VRAM included, and the engine is aborted. The usual cause is compute wave save/restore being off: the driver evicts a process's queues whenever host memory the card maps moves under memory pressure, and with `cwsr_enable=0` it cannot preempt a running queue, so the eviction waits on a queue that never drains. Clock instability (a voltage offset) is the other cause seen on R9700s. A wait that is only long (a deep prefill, a video's denoising pass) reports nothing while any queue advances | `cat /sys/module/amdgpu/parameters/cwsr_enable` must print `1` (the startup report warns when it is `0`); set `amdgpu.cwsr_enable=1`, rebuild the initramfs and reboot. Remove any `OD_VDDGFX_OFFSET` (`pp_od_clk_voltage`). A reset restores the power cap, fan curve and voltage offset to firmware defaults; re-apply them before every start. Keep the devcoredump under `/sys/class/drm/card*/device/devcoredump/data`, which a reboot loses. `docker inspect` shows exit code 0 for a container Docker already restarted, whatever ended the old process |
|
||||
| `--draft-model is not implemented` | The engine loads its drafter from the container | `rad-convert --draft-model DIR` at conversion time |
|
||||
| `context_length_exceeded` on a request | The prompt alone does not fit the context. `max_tokens` is clamped rather than refused, so this fires only when there is no room left to generate | Shorten the prompt by the number of tokens the message names, or raise `--max-model-len` if the model allows it |
|
||||
| `unknown option '--foo'` and the engine exits | An unknown flag is an error, so a typo in a budget flag cannot silently change the plan | Check `radiance --help` |
|
||||
|
||||
+371
-17
@@ -193,7 +193,7 @@ at once. Run it before adding a kernel plugin; the loader names only the first c
|
||||
| `layernorm` | `M`(range) `n` `eps`:f64 `dtype` | `x`, `w`w, `b`w? → `y` |
|
||||
| `grid_embed` | `M`(range) `n` `side` `dtype` | `x`:inout, `table`w, `coord` |
|
||||
| `grid_embed_aa` | `M`(range) `n` `side` `dtype` | `x`:inout, `table`w, `coord` |
|
||||
| `add` | `M`(range) `n` `dtype` | `a`, `b` → `y` |
|
||||
| `add` | `M`(range) `n` `dtype` `div`:f64/opt | `a`, `b` → `y` |
|
||||
| `mul` | `M`(range) `n` `dtype` | `a`, `b` → `y` |
|
||||
| `silu_mul` | `M`(range) `n` `dtype` | `gate_up` → `y` (splits `[M,2n]` into gate·up) |
|
||||
| `mul_weight` | `M`(range) `n` `dtype` `scalar`/opt | `x`, `w`w → `y` (w one element or one row) |
|
||||
@@ -204,7 +204,7 @@ at once. Run it before adding a kernel plugin; the loader names only the first c
|
||||
| `clamp` | `M`(range) `n` `dtype` | `x`, `lo`w, `hi`w → `y` |
|
||||
| `conv2d` | `M`(range) `width` `cin` `cout` `kh` `kw` `stride` `pad` `cu_div`/opt `valid_stride`/opt `dtype` `t_last`/opt `act`/opt | `x`, `w`w, `cu_seqlens`, `valid`? → `y`; `b`w? |
|
||||
| `conv2d_unfold` | `M`(range) `width` `cin` `kh` `kw` `stride` `pad` `cu_div`/opt `valid_stride`/opt `t_last`/opt `dtype` | `x`, `cu_seqlens`, `valid`? → `y` |
|
||||
| `conv1d_dw` | `M`(range) `n` `k` `cu_div`/opt `dtype` | `x`, `w`w, `cu_seqlens` → `y` |
|
||||
| `conv1d_dw` | `M`(range) `n` `k` `cu_div`/opt `dtype` | `x`, `w`w, `cu_seqlens` → `y`; `b`w? |
|
||||
| `rel_sinusoid` | `M`(range) `n` `max_timescale`:f64/opt `dtype` | → `y` |
|
||||
| `gelu_mul` | `M`(range) `n` `dtype` | `gate_up` → `y` (splits `[M,2n]` into gelu·up, tanh approx) |
|
||||
| `seg_sinusoid` | `M`(range) `n` `period` `max_timescale`:f64/opt `cu_div`/opt `dtype` | `cu_seqlens` → `y` |
|
||||
@@ -237,7 +237,10 @@ does it. A plugin asks for it first and falls back to `add` + `rmsnorm` (`spec.m
|
||||
with the gate in the first half.
|
||||
|
||||
**`add` and `mul`** broadcast a `b` of exactly `n` elements along the rows of a taller output (a
|
||||
bias add). Nothing else broadcasts, in these or any other elementwise op.
|
||||
bias add). Nothing else broadcasts, in these or any other elementwise op. `add`'s `div` divides
|
||||
the sum after its rounding, `y = rd(rd(a + b) / div)` with `rd` `y`'s dtype (absent, 1: the plain
|
||||
sum): the last step of a mean summed pairwise, as a vocoder averages its residual blocks,
|
||||
`add(add(b0, b1), b2, div 3)` for `(b0 + b1 + b2) / 3`. A `div` of 0 is refused.
|
||||
|
||||
**`sigmoid`**, with `mul`, gates a shared expert (`ffn_gate_inp_shexp`). Without it the shared
|
||||
expert runs ungated, which is a different model.
|
||||
@@ -326,8 +329,8 @@ is easy to miss.
|
||||
With `valid`, input row `t` reads as zeros unless `valid[t * valid_stride] != 0`: the frame mask
|
||||
the subsampler applies before each convolution. f32 sum, one rounding.
|
||||
- **`conv1d_dw`** is a causal depthwise convolution over time,
|
||||
`y[t, c] = sum_j w[c, 0, j] * x[t - (k - 1) + j, c]`, with rows before the segment's start
|
||||
reading as zeros.
|
||||
`y[t, c] = sum_j w[c, 0, j] * x[t - (k - 1) + j, c] + b[c]`, with rows before the segment's start
|
||||
reading as zeros and `b` zero when unbound.
|
||||
- **`rel_sinusoid`** writes the sinusoidal relative-position table, row `d` for distance `d`:
|
||||
`sin(d * inv[i])` over the first half and `cos(d * inv[i])` over the second,
|
||||
`inv[i] = exp(i * -log(max_timescale) / max(n/2 - 1, 1))`, each step in f32 as the reference's
|
||||
@@ -485,6 +488,7 @@ and is optional.
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `quant_act_fp8` | `M` `n` `group` `dtype` | `x` → `q`, `scale` |
|
||||
| `quant_cols_fp8` | `M` `n` `dtype` | `x` → `y`, `scale` |
|
||||
| `had_quant_act_fp8` | `M` `n` `group` `dtype` | `x` → `q`, `scale` |
|
||||
| `givens_dense_quant` | `M` `n` `group` `dtype` `parts` `out`:str | `x`, `tdense`w, `rscale`w → `q`, `scale` |
|
||||
| `givens_rotate` | `M` `n` `group` `dtype` `stages` `parts` | `x`, `pairs`w, `angle`w, `rscale`w → `y` |
|
||||
@@ -492,6 +496,11 @@ and is optional.
|
||||
| `gated_quant_fp8` | `M` `n` `group` `dtype` `act`:str/opt | `gate_up` → `q`, `scale`, `out_bf16`? |
|
||||
| `gemm_nt_q_gated` | `M` `N` `K` `group` `dtype` `act` | `a`, `a_scale`, `b`w, `b_scale`w → `q`, `scale`, `out_bf16`? |
|
||||
|
||||
`quant_cols_fp8` is the same E4M3 quantiser with one scale per column over all `M` rows,
|
||||
`scale[c] = amax_r |x[r, c]| * (1/448)` (1 for an all-zero column), `scale` `[n]` f32: an
|
||||
attention's values for its fp8 P.V form, where a column is one dimension of one head and its scale
|
||||
multiplies out of the sum over keys.
|
||||
|
||||
`gemm_nt_q_gated` is `gemm_nt_q` over a `[N, K]` gate_up plane (`N` is the weight's rows, twice the
|
||||
fused width, gate half first) with `gated_quant_fp8`'s pass in the epilogue, so the `[M, N]` bf16
|
||||
tensor between them is never written. It is a separate schema, not a flag on `gemm_nt_q`, because
|
||||
@@ -629,7 +638,8 @@ implementation reads `res` before it stores the product over it.
|
||||
| `lora_expand` | `M`(range) `N` `R` `S` `dtype` | `t`, `slot`, `lora_b`, `scale`, `y`:inout |
|
||||
|
||||
The two halves of `y += scale ⊙ (B · (A · x))` at a trunk GEMM, issued by the core right after the
|
||||
GEMM in the GEMM's own row slice, with several adapters and no adapter mixed in one step. `slot` is
|
||||
GEMM in the GEMM's own row slice, with several adapters and no adapter mixed in one step; a step
|
||||
with no adapter row issues neither. `slot` is
|
||||
an i32 per row naming its adapter's pool slot -- the step batch's `RadBatch::lora_slot` from the
|
||||
GEMM's first row on; **a row with `slot < 0 || slot >= S` is a base row and neither op touches
|
||||
it**: `lora_shrink` writes nothing into its `t` row, and `lora_expand` does not read or write its
|
||||
@@ -665,12 +675,12 @@ bytes).
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `attn_paged` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
|
||||
| `attn_dense` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt `max_seqlen`/opt `window`/opt `cu_div`/opt `block`/opt | `q`, `k`, `v`, `cu_seqlens` → `out` |
|
||||
| `attn_dense` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt `max_seqlen`/opt `window`/opt `cu_div`/opt `block`/opt `window_right`/opt | `q`, `k`, `v`, `cu_seqlens` → `out` |
|
||||
| `attn_local_rel` | `M`(range) `head_dim` `n_head` `left` `right` `softcap`:f64 `cu_div`/opt `dtype` | `q`, `k`, `v`, `relk`, `pds`w, `cu_seqlens` → `out` |
|
||||
| `kv_store` | `M`(range) `head_dim` `n_head_kv` `block_size` `kv_dtype` `k_scale`:f64/opt `v_scale`:f64/opt | `k`, `v`, `slot_mapping`, `kv_cache`:inout |
|
||||
| `rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `scale`:f64 `mode` `rotary_dim`/opt `sections`/opt `yarn_factor`:f64/opt `yarn_low`:f64/opt `yarn_high`:f64/opt `yarn_magnitude`:f64/opt `ladder`/opt | `qkv`:inout, `positions` |
|
||||
| `rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `scale`:f64 `mode` `rotary_dim`/opt `sections`/opt `yarn_factor`:f64/opt `yarn_low`:f64/opt `yarn_high`:f64/opt `yarn_magnitude`:f64/opt `ladder`/opt `llama3_factor`:f64/opt `llama3_low`:f64/opt `llama3_high`:f64/opt `llama3_orig`:f64/opt | `qkv`:inout, `positions` |
|
||||
| `rope_table` | `M`(range) `rot` `theta`:f64 `scale`:f64 `dtype` `yarn_factor`:f64/opt `yarn_low`:f64/opt `yarn_high`:f64/opt `yarn_magnitude`:f64/opt `head_dim`/opt `ladder`/opt | `positions` → `cos_sin` |
|
||||
| `qk_norm_rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `wadd`:f64/opt `v_norm`/opt `sections`/opt `comps`/opt | `qkv`:inout, `positions`, `q_w`w, `k_w`w |
|
||||
| `qk_norm_rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `wadd`:f64/opt `v_norm`/opt `sections`/opt `comps`/opt | `qkv`:inout, `positions`?, `q_w`w?, `k_w`w? |
|
||||
| `qkv_norm_rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `ladder`/opt `wadd`:f64/opt `v_from_k`/opt `dtype` | `q`:inout, `k`:inout, `v`:inout, `positions`, `q_w`w, `k_w`w |
|
||||
|
||||
**`attn_paged`**'s band is `q_len`, not `M`: one query row at decode, `1 + n_spec` at a speculative
|
||||
@@ -689,7 +699,9 @@ maximum, which selects the band; the per-sequence lengths come from `cu_seqlens`
|
||||
or one input per entry so a whole batch is one launch. `window` is `attn_paged`'s rule over a
|
||||
segment's own positions (causal: key `j` is visible to query `i` when `i - j < window`; non-causal:
|
||||
when `|i - j| < window`), and 0 is no window. A bidirectional encoder's sliding layer of radius `r`
|
||||
(`|i - j| <= r`) is `window = r + 1`. `q`, `k` and `v` may each be `[tokens, heads, head_dim]` or
|
||||
(`|i - j| <= r`) is `window = r + 1`; one that sees `l` keys behind and `r` ahead is `window = l + 1`
|
||||
with `window_right = r + 1` (non-causal only: key `j` visible when `i - j < window` and
|
||||
`j - i < window_right`). `q`, `k` and `v` may each be `[tokens, heads, head_dim]` or
|
||||
`[tokens, heads * head_dim]`, and the second form may be a column slice of a fused projection read
|
||||
at its row pitch, so a tower's `[q|k|v]` row needs no copy.
|
||||
|
||||
@@ -717,6 +729,19 @@ owns:
|
||||
With `[M]` positions every component is that one position, so `mrope` and `imrope` over a text batch
|
||||
are exactly `neox`.
|
||||
|
||||
**Positions** are integers or floats, and the operand's dtype says which. An integer `positions`
|
||||
(i32) is read as an integer; an f32 one (bf16 and f16 too) as the value it holds, a fractional
|
||||
coordinate such as a video decoder's normalised grid already multiplied by `2 pi`. Either way the
|
||||
angle is `f32(pos / scale) * inv` in f32. `[C, M]` positions are read at the operand's own strides,
|
||||
so a `[C, M]` view of a wider `[C, max]` plane is read in place.
|
||||
|
||||
**`llama3_*`** applies Llama 3's frequency scaling (transformers' `rope_type` `llama3`) to `rope`'s
|
||||
ladder: with wavelength `2 pi / inv`, a frequency shorter than `llama3_orig / llama3_high` is kept,
|
||||
one longer than `llama3_orig / llama3_low` is divided by `llama3_factor`, and those between blend,
|
||||
`s = (llama3_orig / wavelength - llama3_low) / (llama3_high - llama3_low)`,
|
||||
`(1 - s) inv / llama3_factor + s inv`, in f32 (`abi/rad_yarn.h`, `RadLlama3`). It does not combine
|
||||
with YaRN or a multi-component mode.
|
||||
|
||||
**`ladder`** names the width the base frequency ladder is measured in. Absent or `rotary`, the
|
||||
exponent divides by `rotary_dim`: a partial rotary is a complete rotation of its own width. `head`
|
||||
divides by `head_dim` instead (the proportional variant), so the `rotary_dim / 2` frequencies are a
|
||||
@@ -726,8 +751,12 @@ ladders), and the head past `rotary_dim` is untouched either way. `rope_table` t
|
||||
the same reason: its angles must stay `rope`'s exactly.
|
||||
|
||||
**`qk_norm_rope`** RMS-norms each q and k head of a fused `[q | k | v]` row against its gain (plus
|
||||
`wadd`), rounds, and rotates in place.
|
||||
`wadd`), rounds, and rotates in place. `positions` is read as `rope` reads it, integer or f32.
|
||||
|
||||
- An absent `q_w` or `k_w` is a unit gain, without `wadd`: the head is `x rsqrt(mean(x^2) + eps)`,
|
||||
rounded (a video decoder's weightless q and k norms).
|
||||
- `rotary_dim` 0 is the norm alone: nothing rotates, and `positions` may be absent (`M` is then
|
||||
`qkv`'s rows). A rotation with no positions is refused.
|
||||
- `v_norm` 1 also RMS-norms every v head with a unit gain and does not rotate it: Gemma 4's value
|
||||
norm, which has no weight.
|
||||
- `mode` `blocks` rotates each section as its own block of channels: section `c` is `sections[c]`
|
||||
@@ -740,6 +769,14 @@ the same reason: its angles must stay `rope`'s exactly.
|
||||
a 3-axis image rotary's complex form.
|
||||
- `mode` `imrope` is `rope`'s `imrope` over NeoX pairs, reading three position planes (Qwen3-VL's
|
||||
text attention).
|
||||
- `mode` `axial` is `rope`'s `axial` over NeoX pairs `(i, i + rotary_dim / 2)`: the
|
||||
`rotary_dim / 2` frequencies split into contiguous `sections` (summing to `rotary_dim / 2`),
|
||||
section `c`'s `j`-th frequency `theta^(-2j / (2 sections[c]))` turned by position component `c`.
|
||||
`positions` is `[C, M]` with `C` at least the section count, or `[M]`, every component then that
|
||||
one position on the same per-section ladders (unlike `rope`, whose `[M]` positions fall back to
|
||||
the plain ladder). MiniMax-H3's DiT rotates 96 of its 128 channels with sections `16 16 16`
|
||||
(theta 1e4) over f32 `(t, h, w)` positions; its video decoder 48 of 64 with `8 8 8` (theta 100)
|
||||
over positions `grid_pos3` writes.
|
||||
|
||||
**`qkv_norm_rope`** (device-only) is the same prologue over separate `q`, `k` and `v` projections
|
||||
(Gemma 4's text attention, three GEMMs): the q and k norms, the unit-gain value norm and the rotary
|
||||
@@ -819,7 +856,7 @@ says which (`libref/ref_gen.cpp`).
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `ln_mod` | `M`(range) `n` `eps`:f64 `dtype` | `x`, `s`, `cu_seqlens` → `y` |
|
||||
| `gate_add` | `M`(range) `n` `dtype` | `y`, `g`, `cu_seqlens`, `x`:inout |
|
||||
| `gate_add` | `M`(range) `n` `dtype` `act`/opt | `y`, `g`, `cu_seqlens`, `x`:inout |
|
||||
| `ln_mod_quant_fp8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` | `y`?, `g`?, `s`, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`? |
|
||||
| `timestep_embed` | `M`(range) `n` `scale`:f64 `max_period`:f64 `round`/opt `dtype` | `t` → `y` |
|
||||
| `gather_rows2` | `M`(range) `n` `dtype` | `a`, `b`, `idx` → `y` |
|
||||
@@ -827,7 +864,7 @@ says which (`libref/ref_gen.cpp`).
|
||||
| `lane_store` | `M`(range) `n` `stride` `dtype` | `src`, `lane`, `dst`:inout |
|
||||
| `randn_lanes` | `M`(range) `n` `stride` `dtype` | `flags`, `seed`, `lane`, `cu_seqlens`, `dst`:inout |
|
||||
| `flow_euler` | `M`(range) `n` `stride` `dtype` | `v`, `sigma`, `sigma_next`, `cfg`, `pair`, `lane`, `flags`, `seed`, `cu_seqlens`, `inp_lat`?, `inp_mask`?, `state`:inout, `preview`:inout? |
|
||||
| `chan_affine` | `M`(range) `n` `mul` `add` `mode` `dtype` | `x` → `y` |
|
||||
| `chan_affine` | `M`(range) `n` `mul` `add` `mode` `dtype` `round`/opt | `x` → `y` |
|
||||
| `conv2d_nhwc` | `M`(range) `cin` `cout` `k` `stride` `pad` `up` `dtype` | `x`, `w`w, `b`w → `y` |
|
||||
| `l2norm_chan` | `M`(range) `n` `act` `dtype` | `x`, `gamma`w → `y` |
|
||||
| `d2s_add` | `M`(range) `cin` `cout` `ft` `dtype` | `x`, `y`:inout |
|
||||
@@ -835,7 +872,7 @@ says which (`libref/ref_gen.cpp`).
|
||||
| `to_rgba8` | `M`(range) `n` `dtype` | `x` → `y` |
|
||||
| `gelu_tanh` | `M`(range) `n` `dtype` | `x` → `y` |
|
||||
| `scatter_add_rows` | `M`(range) `n` `dtype` | `v`, `idx`, `x`:inout |
|
||||
| `attn_prefix_self` | `q_len` `head_dim` `gqa` `block_size`/der `causal` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `qk`/opt | `q`, `k`, `v`, `kv_cache`, `block_table`, `seqused`, `cu_seqlens`, `k_descale`?, `v_descale`?, `k_i8`?, `k_scale`? → `out` |
|
||||
| `attn_prefix_self` | `q_len` `head_dim` `gqa` `block_size`/der `causal` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `qk`/opt `pv`/opt | `q`, `k`, `v`, `kv_cache`?, `block_table`?, `seqused`?, `cu_seqlens`, `k_descale`?, `v_descale`?, `k_i8`?, `k_scale`? → `out`, `v_scale`? |
|
||||
|
||||
**Sequences and lanes.** `cu_seqlens` partitions the rows into entries (`[n_seq+1]` i32, entry `e`
|
||||
owning `[cu[e], cu[e+1])`; it need not start at 0). `ln_mod` and `gate_add` take each row's
|
||||
@@ -845,7 +882,10 @@ apart: `lane_gather` copies entry `e`'s rows out of lane `lane[e]`, and `lane_st
|
||||
source into every listed lane (a repainted picture's latent into each of its images).
|
||||
|
||||
- `ln_mod`: `y = bf16(bf16(LN(x)) * bf16(1 + s[seq]))`, a layer norm with no gain and no bias.
|
||||
- `gate_add`: `x = bf16(x + bf16(bf16(tanh(g[seq])) * y))`.
|
||||
- `gate_add`: `x = bf16(x + bf16(bf16(tanh(g[seq])) * y))`. `act` names the gate's activation,
|
||||
`tanh` (the default) or `none`, the gate as it is and not rounded first:
|
||||
`x = bf16(x + bf16(g[seq] * y))` (MiniMax-H3's last block, whose gates have no tanh). The
|
||||
roundings are to `x`'s dtype.
|
||||
- `ln_mod_quant_fp8`: with `gated` 1, `gate_add` first; then `z = ln_mod(x)` and
|
||||
`(q, scale) = quant_act_fp8(z, group)`, `z` written when bound. Each value is rounded as its own
|
||||
store would round it, so the bytes are the three ops'.
|
||||
@@ -873,7 +913,10 @@ shapes: an image's size belongs to a request, and a parameter is fixed at declar
|
||||
- `l2norm_chan`: each pixel's channels to unit L2 (eps 1e-12), times `sqrt(n)`, times `gamma`
|
||||
(three roundings), then `act` `none` or `silu`.
|
||||
- `chan_affine`: `mul` and `add` are space-separated lists of `n` values, each rounded to bf16;
|
||||
`fma` is `bf16(bf16(x * mul) + add)`, `inv` is `bf16(bf16(x - add) / mul)`.
|
||||
`fma` is `bf16(bf16(x * mul) + add)`, `inv` is `bf16(bf16(x - add) / mul)`, the roundings to
|
||||
`y`'s dtype. With `round` 0 (default 1) the lists stay f32 and so does the arithmetic, rounded
|
||||
once into `y`: `fma` is `rd(f32(x * mul) + add)`, `inv` `rd(f32(x - add) / mul)` (MiniMax-H3
|
||||
denormalises its f32 audio latents with an f32 deviation and mean).
|
||||
- `d2s_add` (Wan's DupUp3D on one frame): `y[2r+i, 2c+j, o] += x[r, c, (o F + off + 2i + j) / rep]`,
|
||||
`F = 4 ft`, `off = 4` when `ft` is 2, `rep = cout F / cin`.
|
||||
- `s2d_avg_add` (AvgDown3D on one frame): `y` gains the mean of each output channel's group of
|
||||
@@ -889,7 +932,318 @@ segments before it. `qk` `"i8"` is the int8 score form and takes `k_i8` `[tokens
|
||||
head_dim]` and `k_scale` `[tokens, kv_heads]` f32, the own keys as `quant_act_i8g` writes them at
|
||||
group `head_dim`. The query and every prefix key are quantised inside the op by the same rule
|
||||
(scale `amax/127`, 1 for an all-zero row; code `rint(clamp(x * (1/scale), ±127))`), a score is the
|
||||
exact integer dot product times both scales, and `k` is not read for the own rows.
|
||||
exact integer dot product times both scales, and `k` is not read for the own rows. The prefix's
|
||||
three operands come together or not at all: without them every entry's prefix is empty and the op
|
||||
is self attention over each entry's rows (`max_ctx` 0 declares that form), which is how a single
|
||||
long sequence takes the int8 score form.
|
||||
|
||||
`pv` `"fp8"` is the fp8 P.V form, prefix-free only: `v` holds E4M3 codes and `v_scale`
|
||||
`[kv_heads * head_dim]` their column scales (`quant_cols_fp8`). Over a row's visible keys, with
|
||||
`p = exp(s - max)` against the row's max, each weight is taken to E4M3 as `w = e4m3(448 p)` and
|
||||
|
||||
o = (sum w v) v_scale / (448 sum p) f32 sums in key order
|
||||
|
||||
A kernel may take `p` against its running max in its own key order as long as every `p <= 1`
|
||||
(E4M3's top is 448), which differs from this only by where each weight was rounded.
|
||||
|
||||
## Audio generation
|
||||
|
||||
The ops an audio generator declares (`rad_declare_audio_generator`, `abi/rad_builder.h`) beyond a
|
||||
language model's and an image generator's: a frame sampler with guidance between branches over
|
||||
residual codebooks, the frame embeddings, the window states of a latent denoiser, and a
|
||||
vocoder's 1-D convolutions. Each rounds where the reference model materialises a bf16 tensor; the
|
||||
libref function says which (`libref/ref_audio.cpp`).
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `conv1d` | `M`(range) `cin` `cout` `k` `dil` `act`/opt `dtype` `causal`/opt | `x`, `w`w, `cu_seqlens`, `res`? → `y`; `b`w? |
|
||||
| `conv_t1d` | `M`(range) `cin` `cout` `stride` `dtype` `pad`/opt `k`/opt | `x`, `w`w, `b`w, `cu_seqlens` → `y` |
|
||||
| `snake` | `M`(range) `n` `dtype` `log`/opt | `x`, `alpha`w → `y`; `beta`w? |
|
||||
| `snake_aa` | `M`(range) `n` `ratio` `k` `log`/opt `dtype` | `x`, `alpha`w, `beta`w, `f_up`w, `f_down`w, `cu_seqlens` → `y` |
|
||||
| `cfg_topk_sample` | `M`(range) `n_vocab` `k` `rep` `cond_k`/opt `cfg`:f64 `temp`:f64/opt `stream` `dtype` `sup_lo`/opt `sup_hi`/opt `penalty`:f64/opt | `logits`, `seed`, `frame` → `ids`; `cfg`?, `lane`?, `hist`:inout? |
|
||||
| `rvq_embed` | `M`(range) `n_embd` `n_codes` `vocab` `off0` `scale`:f64 `dtype` `round`/opt | `codes`, `t0`w, `t1`w → `y` |
|
||||
| `frame_mix_store` | `M`(range) `n_embd` `L` `stride` `rep`/opt `dtype` | `hid`, `logits`w, `scale`w, `lane`, `frame`, `status`, `dst`:inout |
|
||||
| `end_status` | `M`(range) `end` `rep` | `ids`, `lane`, `status`:inout |
|
||||
| `frame_store` | `M`(range) `n_codes` `stride` `rep`/opt `skip`/opt | `codes`, `lane`, `frame`, `status`, `dst`:inout |
|
||||
| `resample_nearest` | `M`(range) `n` `dtype` | `x` → `y` |
|
||||
| `fourier_embed` | `M`(range) `n` `round`/opt `dtype` | `t`, `w`w → `y` |
|
||||
| `win_input` | `M`(range) `n_lat` `n_zero` `n_cond` `stride` `dtype` | `lat`, `cond`, `lat_cu`, `win_lane`, `pair` → `y` |
|
||||
| `win_prep` | `M`(range) `n` `stride` `ov` `dtype` | `flags`, `t`, `seed`, `win_index`, `win_lane`, `pair`, `lat_cu`, `prev`, `noise`:inout, `lat`:inout |
|
||||
| `win_finish` | `M`(range) `n` `n_cond` `stride` `ov` `dtype` | `flags`, `pair`, `win_lane`, `lat_cu`, `cond`, `lat`:inout, `prev`:inout, `prev_cond`:inout |
|
||||
| `chan_split` | `M`(range) `n` `parts` `dtype` | `x` → `y` |
|
||||
| `interleave2` | `M`(range) `dtype` | `a`, `b` → `y` |
|
||||
| `iota` | `M`(range) `start` `step` `period`/opt | → `y` |
|
||||
| `cu_repeat` | `M`(range) `mult` | `len` → `y` |
|
||||
|
||||
**Frames.** A lane is one piece; a frame is one step of its language model, whose branches (the
|
||||
conditional first, then the unconditional) are consecutive rows, `rep` of them a lane.
|
||||
|
||||
- `cfg_topk_sample`: per lane, `g = u + cfg (c - u)` between its first two branch rows (`c` alone
|
||||
at `rep` 1), `cfg` the operand's value for the lane when it is bound. With `hist`
|
||||
`[lanes, n_vocab]` i32 and `lane` `[n]`, the lane's history row is cleared at frame 0 and every id
|
||||
it holds is penalised, `g > 0 ? g / penalty : g * penalty` (a repetition penalty over the lane's
|
||||
earlier picks); the pick is recorded in it. Ids in `[sup_lo, sup_hi)` are never candidates; with
|
||||
`cond_k` > 0 only the entries where `c` reaches its `cond_k`-th largest value are. The `k`
|
||||
largest `g` (ties to the lower index) are kept, divided by `temp`, softmaxed in f32 and drawn by
|
||||
inverse CDF in descending `g`, `u = rad_philox_uniform_s(seed, 2^32 + frame, stream)`
|
||||
(`abi/rad_philox.h`); the pick goes to every one of the lane's `rep` slots. `logits`
|
||||
`[rep n, n_vocab]` f32 or bf16, `seed` `[n, 2]` u32 low word first, `frame` `[n]`.
|
||||
- `end_status`: `status[lane[i]] = ids[rep i] == end ? -1 : ids[rep i]`.
|
||||
- `rvq_embed`: `codes` is code-major `[n_codes, rows]`, read at the operand's own strides (a block
|
||||
of a wider plane is a view);
|
||||
`y = bf16(bf16(t0[c_0 + off0] + bf16(sum_k t1[c_k + (k - 1) vocab])) * scale)`, or with `round` 1
|
||||
one f32 sum of every codebook's row in codebook order, times `scale`, rounded once to `y`'s dtype.
|
||||
A first code outside `t0` leaves its row unwritten; a later code outside `t1` adds nothing.
|
||||
- `frame_store`: `dst[(lane n_codes + k) stride + frame - skip] = codes[k, rep i]` for every `k`,
|
||||
when `frame >= skip` and `status[lane] >= 0`: a frame's codes into its lane's history, each
|
||||
codebook a row over the lane's frames, so a run of a lane's frames is a block of `n_codes`
|
||||
rows.
|
||||
- `frame_mix_store`: `m = bf16(bf16(sum_l w_l h_l) * bf16(scale))`, `w = bf16(softmax(bf16(logits)))`
|
||||
over the `L` planes of `hid` `[L, rows, n_embd]`, row `rep i` of each plane being lane `i`'s
|
||||
conditional row; stored at `dst[lane * stride + frame - 1]` for `frame >= 1` and
|
||||
`status[lane] >= 0` (frame 0 only moves past the prompt; a negative status ended the piece).
|
||||
- `iota`: `y[i] = start + i * step`, or `start + (i % period) * step` with `period` (the
|
||||
positions of equal sequences laid end to end). `cu_repeat`: `y[j] = j * len[0] * mult`, the bounds of equal
|
||||
sequences whose length lives on the device.
|
||||
|
||||
**Windows.** The denoiser runs over windows of frames, each entry of a window step a lane's latent
|
||||
in a state buffer `stride` rows a lane (`lat_cu` bounds each entry's rows, `win_lane` names its
|
||||
lane, `pair` is -2 for an unconditional branch, which moves no lane). `flags` carries 1 (the
|
||||
window's first step), 8 (its last) and 16 (it overlaps the previous window by `ov` rows).
|
||||
|
||||
- `win_input`: `y = [lat | zeros(n_zero) | cond]` from the entry's lane; an entry with `pair` -2
|
||||
takes zeros for `cond`.
|
||||
- `win_prep`: flag 1 fills the lane with `rad_philox_normal_s(seed, 1 + win_index, k n + c)` as
|
||||
bf16, keeping its first `ov` rows in `noise` with flag 16; flag 16 then binds the first
|
||||
`min(ov, rows)` rows to the previous window's end,
|
||||
`bf16(bf16(1 - bf16((1 - 1e-6) t)) noise + bf16(t prev))`, `t = bf16(t[e])`.
|
||||
- `win_finish` (flag 8): with flag 16 the first `min(ov, rows)` rows become `prev` exactly; then
|
||||
rows `[max(0, rows - 2 ov), max(.., rows - ov))` of the latent and of `cond` are kept as the next
|
||||
window's `prev` and `prev_cond`.
|
||||
- `fourier_embed`: `[cos(2 pi t w) | sin(2 pi t w)]`, `t` f32 `[M]`, `w` `[n / 2]`; with `round` 1
|
||||
`t`, `2 pi t`, the product and each cosine and sine are rounded to bf16.
|
||||
- `resample_nearest`: output row `j` reads input row `min(floor(j * in / out), in - 1)`, the row
|
||||
counts read off the operands (torch's `interpolate(mode="nearest")`).
|
||||
|
||||
**The vocoder.** Rows are samples, channels innermost; `cu_seqlens` bounds each sequence and the
|
||||
input reads zero outside it.
|
||||
|
||||
- `conv1d`: PyTorch's `[cout, cin, k]` weight, `k` odd, dilation `dil` and padding
|
||||
`dil (k - 1) / 2` a side, or with `causal` 1 (any `k`) `dil (k - 1)` on the left; `res` is added
|
||||
after the bias, then `act` `none`, `tanh` or `clamp`, `min(max(y, -1), 1)` (BigVGAN's output
|
||||
clamp; a NaN stays NaN). f32 accumulation, one rounding.
|
||||
- `conv_t1d`: PyTorch's `[cin, cout, k]` transposed weight, any `k` of at least a stride (two
|
||||
strides by default), padding `pad` (`(k - stride) / 2` by default, which needs `k - stride` even;
|
||||
0 is the causal form, whose full output's last `k - stride` rows are dropped; it may exceed a
|
||||
stride): output row `o` of a sequence is `b + sum_i x[i] w[(o + pad) - i stride]` over the
|
||||
sequence's input rows `i` with `0 <= (o + pad) - i stride < k`, summed in f32 as
|
||||
`q = (o + pad) / stride`, `r = (o + pad) % stride` and taps `t = 0, 1, ..` while
|
||||
`r + t stride < k` reading `x[q - t] w[r + t stride]`; one rounding. Sequence `e`'s rows
|
||||
`[cu[e], cu[e+1])` become `[stride cu[e], stride cu[e+1])`, `stride L` rows from `L`. BigVGAN
|
||||
upsamples with `(k 9, stride 5, pad 2)` and `(k 4, stride 2)`.
|
||||
- `snake`: `x + sin(alpha x)^2 / (alpha + 1e-9)`, `alpha` per channel; with `beta` the SnakeBeta
|
||||
form `x + (1 / (beta + 1e-9)) sin(alpha x)^2`. `log` 1 reads both as logarithms, exponentiated
|
||||
first.
|
||||
- `snake_aa`: BigVGAN's alias-free SnakeBeta (diffusers' `MiniMaxH3AudioActivation1d`: an
|
||||
upsampler, the activation, a low-pass downsampler) over each sequence, in f32. For channel `c`
|
||||
of a sequence of `L` rows, `P = k / ratio - 1`:
|
||||
- `xp` is the sequence replicate-padded by `P` rows on each side;
|
||||
- `u_full[o] = sum_i f_up[o - i ratio] xp[i]` over the rows `i` with `0 <= o - i ratio < k`, in
|
||||
ascending `i` (a depthwise `conv_transpose1d` at stride `ratio`), and
|
||||
`u = ratio u_full[P ratio + (k - ratio) / 2 + m]` for `m < L ratio` (the full output cropped by
|
||||
`P ratio + (k - ratio) / 2` rows at the start and `P ratio + (k - ratio + 1) / 2` at the end);
|
||||
- `a = u + (1 / (B + 1e-9)) sin(A u)^2` as `snake`'s `beta` form evaluates it, `A = exp(alpha[c])`
|
||||
and `B = exp(beta[c])` with `log` 1, the values themselves otherwise;
|
||||
- `ap` is `a` replicate-padded by `k / 2` rows on the right and `k / 2` on the left less one for
|
||||
an even `k`, and `y[o] = sum_j f_down[j] ap[o ratio + j]` over `j < k` in ascending `j`, for
|
||||
`o < L`.
|
||||
|
||||
`f_up` and `f_down` are the checkpoint's `[1, 1, k]` Kaiser filters, one for every channel
|
||||
(MiniMax-H3: `k` 12, `ratio` 2). A sequence keeps its length.
|
||||
- `chan_split`: `y[p rows + r] = x[r, p n .. p n + n)`, a stereo latent's halves as two streams.
|
||||
- `interleave2`: `y [rows, 2] = (a[r], b[r])`, f32.
|
||||
|
||||
## Video generation
|
||||
|
||||
The ops a video generator (MiniMax-H3) needs beyond a language model's, an image generator's and
|
||||
an audio generator's: its diffusion transformer's modulated RMS norm and its sampler step, and the
|
||||
video decoder's patch unfold, the tiles it runs over, their stitch back into frames and their
|
||||
rotary positions. The transformer's attention is `qk_norm_rope` `axial` (its step-distilled form's
|
||||
is [video sparse attention](#video-sparse-attention)) and its gated residual
|
||||
`gate_add` `act` none; the soundtrack's vocoder is `conv_t1d`, `snake_aa` and `conv1d` `clamp`
|
||||
([Audio generation](#audio-generation)). Each op rounds where the reference model materialises a
|
||||
bf16 tensor and keeps f32 where it computes in f32; the libref function says which
|
||||
(`libref/ref_gen.cpp`, `libref/ref_video.cpp`).
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `rms_mod` | `M`(range) `n` `eps`:f64 `gated`/opt `dtype` | `y`?, `g`?, `s`, `w`w, `cu_seqlens`, `x`:inout → `z` |
|
||||
| `rms_mod_quant_fp8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` | `y`?, `g`?, `s`, `w`w, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`? |
|
||||
| `flow_x0_step` | `M`(range) `n` `dtype` | `v`, `t`, `sigma`, `sigma_next`, `x`:inout |
|
||||
| `patch_unfold` | `M`(range) `C` `pt` `ph` `pw` `mul` `add` `dtype` | `x`, `geom` → `y` |
|
||||
| `vtile_gather` | `M`(range) `n` `tile` `overlap` `frames` `period` `n_reg` `dtype` | `x`, `reg`w, `geom` → `y` |
|
||||
| `vtile_stitch` | `M`(range) `tile` `overlap` `scale` `pt` `skip` `keep` `blend` `period` `mean` `std` | `x`, `geom`, `prev`:inout → `y` |
|
||||
| `grid_pos3` | `M`(range) `T` `H` `W` `period` `scale`:f64 | → `y` |
|
||||
|
||||
**The transformer.** `cu_seqlens` partitions the rows into entries as for `ln_mod`, and each row
|
||||
reads its entry's rows of `s` and `g`.
|
||||
|
||||
- `rms_mod` is `norm(h) (1 + scale) + shift` after the branch before it is added: with `gated` 1
|
||||
first `x = bf16(x + bf16(g[e] y))`, no tanh, stored back to `x`; then
|
||||
`n1 = bf16(x rsqrt(mean(x^2) + eps))` (the sum of squares f32 in ascending order, over the
|
||||
stored `x`), `n2 = bf16(n1 w)`, `m = bf16(n2 bf16(1 + scale[e]))`, `z = bf16(m + shift[e])`.
|
||||
`s` is `[n_seq, >= 2n]` at its own row pitch, `shift = s[e, 0:n]` and `scale = s[e, n:2n]` (a
|
||||
column slice of the modulation table); `g` is `[n_seq, >= n]` at its own pitch; `w` is `[n]`.
|
||||
The residual rounds to `x`'s dtype and the norm chain to `z`'s.
|
||||
- `rms_mod_quant_fp8` is `rms_mod` with the norm chain in bf16, then `quant_act_fp8` of that bf16
|
||||
row per `group` as `ln_mod_quant_fp8` takes it; `z` written when bound.
|
||||
- `flow_x0_step` is MiniMax-H3's sampler step over a lane's rows, all f32, each product and sum
|
||||
one rounding: the velocity points at the data, so the clean estimate is `d = x + (1 - t) v` and
|
||||
the step blends toward it, `st = f32(1 - t)`, `d = f32(x + f32(st v))`,
|
||||
`r = f32(sigma_next / sigma)`, `x = f32(f32(r x) + f32(f32(1 - r) d))`. `t` (the timestep the
|
||||
transformer was conditioned on), `sigma` and `sigma_next` (the schedule's entries) are one f32
|
||||
value each; `v` is f32 or bf16, `x` f32.
|
||||
|
||||
**The decoder** runs over a request's latent geometry, which `geom`, i32 on the device, carries
|
||||
(the parameters are fixed at declare). `mul`, `add`, `mean` and `std` are space-separated lists
|
||||
kept in f32. An output holds at least the rows the geometry writes; rows past them are not
|
||||
written.
|
||||
|
||||
- `patch_unfold`: patch rows `x [F Hp Wp, C pt ph pw]` (row `(f, i, j)` frame-major then
|
||||
row-major, column `(c, a, b, d)` at `c pt ph pw + a ph pw + b pw + d`, `geom` = `(F, Hp, Wp)`)
|
||||
to voxel rows `y [(F pt) (Hp ph) (Wp pw), C]`, row `(t, yy, xx)` row-major:
|
||||
`y[(t, yy, xx), c] = f32(f32(x[(t/pt, yy/ph, xx/pw), (c, t%pt, yy%ph, xx%pw)] mul[c]) + add[c])`,
|
||||
the latent denormalised with f32 statistics. `M` is the output's rows.
|
||||
- The tiles of an axis of `L` latent units are diffusers' `_split_tiles` in latent units: a `tile`
|
||||
at least as long as the axis is one tile `[0, L)`, refused unless `L == tile`; otherwise
|
||||
`n = ceil(L / tile)`, raised while `tile n - overlap (n - 1) < L`; `ov = [overlap] * (n - 1)`,
|
||||
the slack `tile n - sum(ov) - L` added one unit at a time to `ov[i % (n - 1)]` for
|
||||
`i = 0, 1, ..`; `start[0] = 0`, `start[i + 1] = start[i] + tile - ov[i]`. `overlap` must be
|
||||
below `tile`. A frame's tiles are row-major over (row band, column band).
|
||||
- `vtile_gather`: the tiles out of voxel rows `x [frames H W, n]` (`(t, yy, xx)` row-major,
|
||||
`geom` = `(frames, H, W)`, its frames the parameter's). Tile `k` is rows
|
||||
`[k period, (k + 1) period)` of `y`: its `frames tile tile` voxels `(t, ty, tx)` row-major from
|
||||
`x`'s row `(t, start_y + ty, start_x + tx)`, then `reg`'s first `n_reg` rows in `y`'s dtype (a
|
||||
decoder's register tokens), then zero rows to the period, which holds at least
|
||||
`frames tile tile + n_reg` rows. `M` is `y`'s rows, `n_tiles period`.
|
||||
- `vtile_stitch`: a decoded chunk's tiles into RGB bytes. `x [>= n_tiles period, 3 pt scale^2]`:
|
||||
tile `k`'s row `k period + (lt tile + ty) tile + tx`, column
|
||||
`c pt scale^2 + a scale^2 + b scale + d`, is colour `c` of pixel `(ty scale + b, tx scale + d)`
|
||||
of clip frame `lt pt + a`. `geom` = `(frames, H, W, first, last)`: the chunk's latent geometry,
|
||||
and whether it is its video's first and its last chunk (nonzero). Pixel `(Y, X)` belongs to the
|
||||
tile `(i, j)` whose kept range holds it, `[start_i scale, start_{i+1} scale)` on each axis (the
|
||||
last tile to its end), at `(ly, lx)` within it, `T(i, j, ly, lx)` that tile's decoded value. With
|
||||
every product and sum rounded to `x`'s dtype (`rd`), `wb(p, e) = rd(p / e)` and
|
||||
`wa(p, e) = rd(1 - wb(p, e))`, the spatial stitch blends with the tile above, then with the tile
|
||||
to the left, both as decoded:
|
||||
|
||||
V = rd(rd(T(i-1, j, ly + tile scale - ev, lx) wa(ly, ev)) + rd(T(i, j, ly, lx) wb(ly, ev)))
|
||||
when i > 0 and ly < ev = ov_y[i-1] scale, else T(i, j, ly, lx)
|
||||
S = rd(rd(T(i, j-1, ly, lx + tile scale - eh) wa(lx, eh)) + rd(V wb(lx, eh)))
|
||||
when j > 0 and lx < eh = ov_x[j-1] scale, else V
|
||||
|
||||
Output frame `k < keep` is clip frame `skip + k`, its first `blend` frames blended with the
|
||||
previous chunk's tail unless the chunk is first,
|
||||
`v = rd(rd(prev[k] wa(k, blend)) + rd(S wb(k, blend)))`; then `prev[k'] = S(2 skip + keep + k')`
|
||||
for `k' < blend` (`prev` `[blend, H scale, W scale, 3]`), which a last chunk also writes as
|
||||
frames `keep + k'`. A byte is `round_half_even(255 clamp(f32(f32(v std[c]) + mean[c]), 0, 1))`
|
||||
(a NaN is 0). `y` is u8 `[frames_out, H scale, W scale, 3]`, `frames_out` `keep` or
|
||||
`keep + blend`; `M` is its pixels. Refused: `blend` past `keep`, clip frames (`frames pt`) short
|
||||
of `2 skip + keep + blend`, a `period` short of `frames tile tile`. MiniMax-H3: `tile` 16,
|
||||
`overlap` 4, `scale` 16, `pt` 4, `skip` 3, `keep` 17, `blend` 5, `period` 1797, ImageNet's
|
||||
`mean` and `std`.
|
||||
- `grid_pos3`: a ViT decoder's rotary positions over consecutive tiles of `period` rows, the
|
||||
tile's `T x H x W` tokens first, then the period's other rows (register tokens). Row `m` is
|
||||
token `k = m % period`; for `k < T H W`, `(t, i, j) = (k / (H W), (k / W) % H, k % W)` and
|
||||
`y[0][m] = f32(f32(scale) g(t, T))`, `y[1][m] = f32(f32(scale) g(i, H))`,
|
||||
`y[2][m] = f32(f32(scale) g(j, W))`, `g(c, n) = f32(f32(2 f32((c + 0.5) / n)) - 1)` (torch's
|
||||
`2 * (arange(0.5, n) / n) - 1`); otherwise all three are 0. `y` is f32 `[3, >= M]`,
|
||||
component-major, at its own row pitch: a `[3, M]` view of a wider plane, which `qk_norm_rope`
|
||||
`axial` then reads as f32 positions. MiniMax-H3: `T` 7, `H` 16, `W` 16, `period` 1797,
|
||||
`scale` `2 pi`.
|
||||
|
||||
### Video sparse attention
|
||||
|
||||
MiniMax-H3's step-distilled form (FastH3) was trained with FastVideo's video sparse attention: a
|
||||
video query sees the dense rows and only the video tiles it scores highest, scored per head from
|
||||
tile means, and a coarse branch adds attention over every tile's mean, gated per element.
|
||||
`vsa_select` makes the selection and the coarse term, `attn_vsa` the attention over them. They
|
||||
share their parameters; `attn_vsa` recomputes `k` from `sparsity`.
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `vsa_select` | `M`(range) `head_dim` `tile_t` `tile_h` `tile_w` `patch` `sparsity`:f64 `scale`:f64/opt | `q`, `k`, `v`?, `segs`, `geom` → `sel`, `coarse`? |
|
||||
| `attn_vsa` | `M`(range) `head_dim` `tile_t` `tile_h` `tile_w` `patch` `sparsity`:f64 `scale`:f64/opt `qk`/opt `pv`/opt | `q`, `k`, `v`, `segs`, `geom`, `sel`, `coarse`?, `gate`? → `out`, `k_i8`?, `k_scale`?, `v_scale`? |
|
||||
|
||||
**The tiles.** A pass's `R` rows (`M` is their band) are one packed sequence. `segs`, i32
|
||||
`[n_seg + 1]`, cuts it into segments: `segs[0] = 0`, non-decreasing, `segs[n_seg] = R`; every
|
||||
segment but the last is dense (the text, the soundtrack), the last is the video grid of
|
||||
`F x Hp x Wp` rows in `(t, h, w)` order, `w` fastest. `geom` is the request's geometry on the
|
||||
device, i32 `[RAD_VGEOM_N]` (`abi/rad_runtime.h`): `F = geom[RAD_VGEOM_LAT_FRAMES]`,
|
||||
`Hp = geom[RAD_VGEOM_LAT_H] / patch`, `Wp = geom[RAD_VGEOM_LAT_W] / patch`. With
|
||||
`TT = tile_t tile_h tile_w`:
|
||||
|
||||
- each dense segment, on its own, is cut into chunks of `TT` rows from its start, the last chunk
|
||||
shorter, an empty segment none: the prefix tiles `0 .. P-1`, in segment order;
|
||||
- the grid is cut into `ceil(F / tile_t) x ceil(Hp / tile_h) x ceil(Wp / tile_w)` boxes. Box
|
||||
`(a, b, c)` holds `t` in `[a tile_t, min(F, (a + 1) tile_t))` and likewise `h` and `w`, edge boxes
|
||||
smaller, and is tile `P + (a nb + b) nc + c` (`nb = ceil(Hp / tile_h)`, `nc = ceil(Wp / tile_w)`):
|
||||
`V` video tiles, `N = P + V` in all;
|
||||
- a tile's rows are taken in its `(t, h, w)` raster order (a prefix tile's in row order), which
|
||||
fixes the order of every f32 sum over a tile. `size(i)` is tile `i`'s row count.
|
||||
|
||||
`k = max(1, min(ceil((1 - sparsity) V), V))`, computed in f64 from the f64 `sparsity`, as the
|
||||
trained schedule computes it: `(1 - 0.8) 660` is `131.99999999999997`, so MiniMax-H3's 660 video
|
||||
tiles at 1344 x 768 keep 132, and `(1 - 0.7) 10` keeps 4.
|
||||
|
||||
Both ops refuse with `RAD_E_SHAPE` a `segs` that does not start at 0, decreases, or covers no row
|
||||
or more rows than the operands hold; a last segment of other than `F Hp Wp` rows; a box extent or
|
||||
`patch` below 1; a `sparsity` outside `[0, 1)`; and an optional operand without its partner. `sel`
|
||||
must be i32 (`RAD_E_DTYPE`). Rows past `segs[n_seg]` are neither read nor written. `q`, `k`, `v`,
|
||||
`gate` and `out` are `[R, n_head head_dim]`, a column slice of a wider projection read at its own
|
||||
row pitch, or `[R, n_head, head_dim]`; the head count is read off `q`.
|
||||
|
||||
**`vsa_select`.** Per head `h` and tile `i`, the tile means and the scores, in f32:
|
||||
|
||||
qp[h][i] = (sum over the rows r of tile i, in raster order, of q[r, h, :]) / size(i)
|
||||
kp[h][i], and vp[h][i] (read for `coarse` alone), likewise from k and v
|
||||
S[h][i][j] = (qp[h][i] . kp[h][j]) scale the dot a sum over d ascending, then the product
|
||||
|
||||
For a video query tile `i >= P`, `sel[h][i][0 .. k)` is the `k` video tiles `j` (`P <= j < N`) of
|
||||
largest `S[h][i][j]`, written in ascending tile order; equal scores go to the lower tile, and a NaN
|
||||
ranks above every number (`torch.topk`'s ranking). The prefix query tiles' rows of `sel` and its
|
||||
slots past `k` are not written. `sel` is `[n_head, tiles_cap >= N, k_cap >= k]`. With `coarse`
|
||||
(and `v`: both or neither), for every tile `i`, prefix tiles too:
|
||||
|
||||
e_j = exp(S[h][i][j] - max over all N tiles of S[h][i][:])
|
||||
p[h][i][j] = e_j / (sum over all N tiles, j ascending, of e_j)
|
||||
coarse[h][i][:] = (sum over j ascending of p[h][i][j] vp[h][j][:]), rounded once to its dtype
|
||||
|
||||
`coarse` is `[n_head, tiles_cap >= N, head_dim]`. At `sparsity` 0, `k = V` and every video tile is
|
||||
selected.
|
||||
|
||||
**`attn_vsa`.** A query row of tile `i` sees the rows of every tile when `i < P` (dense prefix
|
||||
queries), else of the prefix tiles and of the tiles `sel[h][i][0 .. k)`. Each such row of `sel` must
|
||||
hold `k` ascending video tiles, `RAD_E_INVAL` otherwise, checked before anything is written; `sel`'s
|
||||
other entries are not read. Per head (`q`, `k` and `v` have the same heads), `o` is the softmax over
|
||||
the visible keys of `(q . k) scale` times `v`, accumulated in f32, and
|
||||
|
||||
out[r, h, :] = o without coarse and gate
|
||||
out[r, h, :] = rd(rd(o) + coarse[h][i][:] gate[r, h, :]) with them, in f32
|
||||
|
||||
`rd` rounding to `out`'s dtype: FastVideo's inference epilogue, the sparse output in bf16, then
|
||||
`out.addcmul_(coarse, gate)` in bf16 with f32 arithmetic. Two bf16 values multiply exactly in f32,
|
||||
so that is one f32 add between the two roundings. `gate` comes with `coarse`, both or neither. At
|
||||
`sparsity` 0 (with `vsa_select`'s selection) `attn_vsa` is `attn_dense` over the whole sequence.
|
||||
libref takes the keys by ascending tile, each tile in raster order, in `attn_dense`'s two passes.
|
||||
`qk` `"i8"` is `attn_prefix_self`'s int8 score form: `k_i8` `[M, n_head * head_dim]` and `k_scale`
|
||||
`[M, n_head]` f32 are k as `quant_act_i8g` writes it at group `head_dim`, each query row is
|
||||
quantised inside the op by the same rule, a score is `((dot * q_scale) * k_scale) * scale` in f32
|
||||
with `dot` the codes' exact integer sum, and `k` is not read. `pv` `"fp8"` is `attn_prefix_self`'s
|
||||
fp8 P.V form (`v` E4M3 codes, `v_scale` `[n_head * head_dim]`), before the epilogue.
|
||||
|
||||
MiniMax-H3: `tile_t`, `tile_h` and `tile_w` 4, `patch` 2, `sparsity` 0.8, `head_dim` 128, the
|
||||
default `scale` `1 / sqrt(head_dim)`.
|
||||
|
||||
## Mixture of experts
|
||||
|
||||
|
||||
+9
-1
@@ -180,8 +180,9 @@ also matches a norm leaves the norm as it is.
|
||||
| `paroquant` | a channel scaling and `stages` rounds of Givens pair rotations, learned against the Hessian, then AutoRound on the rotated weight; the encoding's `givens` transform |
|
||||
| `ggml` | `type=` one of llama.cpp's formats (q4_0, q4_1, q5_0, q5_1, q8_0, q2_K..q6_K, iq4_nl, iq4_xs, iq2_xxs, iq2_xs, iq2_s, iq3_xxs, iq3_s, iq1_s, iq1_m), chosen by llama.cpp's own search, imatrix-weighted; the codes are byte for byte llama.cpp's, stored as each type's affine planes. iq2_xxs, iq2_xs and iq1_s need `--imatrix` |
|
||||
| `cast` | a float weight in another float dtype (`dtype=` f32, bf16, f16, fp8_e4m3, fp8_e5m2), no scale |
|
||||
| `import` | rad-convert's own, not a plugin: the numbers a quantised release ships, in the spelling the kernels read, instead of quantising again. `codes=uN` makes a symmetric grid's signed codes unsigned under a zero point of 2^(N-1); `zero=` is the zero plane's dtype (u4, u8); `scale=` the scale's (f16, bf16, f32), each shipped scale rounded to nearest; `block=RxC` repeats an FP8 scale shipped per row or per tensor over that block grid. It reads an imported integer grid (GPTQ, CT-INT4) or an FP8 weight with a scale per row or per tensor, refuses any other quantised form by name, and keeps a plain float weight as it is. The run reports per rule how many weights it re-expressed and how many scales the new dtype rounded |
|
||||
|
||||
Every quantiser except `ggml` and `cast` takes the grid options:
|
||||
Every quantiser except `ggml`, `cast` and `import` takes the grid options:
|
||||
|
||||
| option | |
|
||||
|---|---|
|
||||
@@ -781,6 +782,13 @@ reference with the exact wire and a bf16 KV cache.
|
||||
agreement to `FILE.rows` (`[positions, 4]` f32, reference row order), so two candidates can be
|
||||
compared position by position.
|
||||
|
||||
A runtime LoRA adapter (GUIDE.md §4.9.1) is scored the same way: `--lora NAME=DIR --kld-lora NAME`
|
||||
runs every document through the adapter, against a reference recorded from the merged checkpoint
|
||||
(or from PEFT itself). `--kld-lora-sources PREFIX` runs only the documents whose `source` starts
|
||||
with `PREFIX` through it and the rest as the base, in the same steps. The steps are those of the
|
||||
all-adapter and all-base runs with the same flags, so each document's rows should be byte for byte
|
||||
theirs: that is how a mixed batch is checked.
|
||||
|
||||
---
|
||||
|
||||
## The shell harnesses
|
||||
|
||||
Reference in new issue
Block a user