This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/arch/minimaxh3/rad_ref2va_pack.h
T
Deadcode 6645337f69 radiance 1.13.0
New models:
- Tencent Hy-Memory (HYV3) from its BF16, FP8 and GGUF checkpoints, with its native tool calls
- M2XFP4: metadata-augmented MXFP4 weights for Qwen3.8-27B and its DFlash2 drafter (top-1 89.1% ->
  92.4% against plain MXFP4), its quantiser and recipe, and ParoQuant's M2XFP4 checkpoints
- Gemma 4 E2B/E4B audio input; NVIDIA-Nemotron-3.5-Bolt-E4B in int8 and 4-bit, on two cards by
  default; Ornith-1.5-122B compose files

Speed:
- Weight reads beside the decode all-reduces (qwen35_fp8, gemma3; --weight-prefetch, on by default):
  the 27B MXFP4 with DFlash2 61.2 -> 67.9 tok/s at c1, TranslateGemma 27B +13%
- Head-256 split-KV decode attention at 256 workgroups and without bank conflicts (27B: +3-5% a
  step at 25-41K context), and the prefill KV split for small launches (a short turn over a long
  context decodes the other sequences 27% faster in that step)
- MXFP4 decode gate_up, activation and fp8 quantiser in one launch (27B, Gemma 3 up to 64 rows:
  TranslateGemma +2-5% at 2-8 streams)
- ParoQuant int4/int5 tiled GEMMs 6-9% faster
- Speculation: a step's tokens are sent before the drafter's passes end, no step waits behind one
  that ends its requests, and the MTP head's first draft no longer collapses after short chats in
  the prefix cache

Features:
- --kv-resident N: KV streaming for a context bigger than VRAM (qwen4exp_fp8, GLM-5.3)
- MiniMax-H3: reference media and keyframe conditioning with the VAE encoders
- Krea 2 rebalance presets balanced, detail and subtle
- The dashboard's request history; a stall watch that reports a frozen step's thread and stack
- rad-tune at the served configuration, collectives measured as the exchange; Gemma 4 E2B/E4B's
  per-layer embeddings read ahead off the step path
- A GPTQ calibration tap and recipe for Gemma 4 31B's w4a8 container

Fixes:
- The two-rank all-reduce checks that a peer's push has landed before reducing it
- z-lab's DFlash drafter on Gemma 4 31B keeps drafting after a prefix-cache hit
- MiniMax-H3's modulation rows

Changes: Plugin ABI 31: out-of-tree plugins must be rebuilt. RADIANCE_PREFETCH_BESIDE is
--weight-prefetch now; RADIANCE_NO_HUGE_PAGES, RADIANCE_IDS_EARLY, RADIANCE_ATTN_BAND_SPLIT,
R4D_PREFILL_SPLITS, RAD_PLE_TIMING and RAD_PLE_CACHE_ROWS are gone.
2026-10-27 16:47:35 +01:00

108 lines
4.7 KiB
C++

/* rad_ref2va_pack.h -- MiniMax-H3's packed sequence with keyframes and reference media, on the
* host: ComfyUI's PackedLayout (comfy/ldm/minimax/model.py), tested against that code's own numbers
* (tests/data/ref2va).
*
* The sequence is [text | keyframes | references in request order | soundtrack | video]. The
* video's clock starts after every reference's time span; a keyframe sits on it at 5/3 a pixel
* frame; a reference clip's soundtrack rows come right before its video rows, at the same time
* origin. Keyframes and references keep a near-clean timestep; the sampler steps the last two
* segments only.
*/
#ifndef RAD_ARCH_MINIMAXH3_REF2VA_PACK_H
#define RAD_ARCH_MINIMAXH3_REF2VA_PACK_H
#include <cstdint>
#include <vector>
namespace minimaxh3 {
/* Segment kinds, named as the reference implementation names them. */
enum Ref2VAKind {
kR2VText = 0, /* the prompt's hidden states */
kR2VCond, /* a keyframe's video latent rows */
kR2VCondAudio, /* a keyframe's soundtrack latent rows */
kR2VRefImg, /* a reference photo, or a reference clip's video */
kR2VRefAudio, /* a reference clip's (or standalone audio's) soundtrack */
kR2VAudio, /* the target soundtrack -- sampler-owned */
kR2VVideo, /* the target video -- sampler-owned */
kR2VKinds
};
/* A reference's kind; a video with a soundtrack of its own is either of the last two. */
enum Ref2VARefKind { kR2VRefImage = 0, kR2VRefAudioOnly = 1, kR2VRefVideo = 2, kR2VRefVideoAudio = 3 };
/* A keyframe: the frame of the video it is pinned at and its latent frames of each stream. */
struct Ref2VAKeyframe {
int frame; /* >= 0 */
int video_t; /* 0: none */
int audio_t; /* 0: none */
};
/* A reference, in latents: its own grid and frames for a picture or video, its soundtrack's
* length for one that has sound. */
struct Ref2VARef {
int kind; /* Ref2VARefKind */
int lat_h, lat_w;
int latent_t;
int audio_t;
};
/* The target, in latent units. */
struct Ref2VAGeom {
int latent_t, latent_h, latent_w, audio_t;
};
struct Ref2VASeg {
int kind;
int64_t start, end; /* rows [start, end) */
int update; /* 1 for the soundtrack and the video the sampler steps */
};
struct Ref2VAPack {
std::vector<Ref2VASeg> segs;
int64_t rows = 0;
/* The rotary positions, [3, rows]: every row's time, then row, then column. */
std::vector<float> pos;
};
/* A kind's modality in the modulation (ComfyUI's seg_tag): 0 video, 1 text, 2 sound. */
int ref2va_seg_tag(int kind);
/* Whether a kind's rows are video latents or soundtrack latents; text is neither. */
int ref2va_is_img(int kind);
int ref2va_is_audio(int kind);
/* A keyframe's or reference's timestep is the larger of its stream's and these. */
constexpr double kR2VVisualPin = 0.999, kR2VAudioPin = 1.0;
/* The modulation groups: runs of consecutive rows that read the same modulation cell, which the
* segment's kind fixes (`md` its modality's projection, `r0` its block of timestep embeddings) --
* except inside the prompt, where a picture's vision pads read the video projection on the text's
* block, as ComfyUI tags them (`runs`). The modulated norm takes the group boundaries, the attention
* the segments'. Groups that share a cell read one column of the modulation table (`col`), so the
* table grows with the distinct cells, not with the references or the pads: nine pictures add one
* cell. The groups cover the sequence; an empty segment opens none. */
struct Ref2VATagRun {
int64_t start, end; /* prompt rows [start, end) */
int tag; /* the projection they read: 0 video for vision pads */
};
struct Ref2VAModGroups {
std::vector<int64_t> bound; /* [groups + 1], from 0 to the rows */
std::vector<int> col; /* [groups]: the cell the group reads */
std::vector<int> md; /* [cells]: 0 video, 1 text, 2 sound */
std::vector<int64_t> r0; /* [cells] */
};
/* `S` is the steps a schedule has, and the embeddings are [0, S) the video's, [S, 2S) the
* soundtrack's, then each again with its pin, [2S, 3S) and [3S, 4S). The boundaries do not depend
* on S. `runs` may come in any order; the parts outside the prompt are ignored. Without runs every
* group has a cell of its own. */
void ref2va_mod_groups(const Ref2VAPack& p, int64_t S, const std::vector<Ref2VATagRun>& runs,
Ref2VAModGroups* out);
/* The sequence, and its positions when `positions`; -1 for a negative size or an unknown kind. */
int ref2va_build(int text_len, const Ref2VAGeom& g, const std::vector<Ref2VAKeyframe>& keyframes,
const std::vector<Ref2VARef>& refs, Ref2VAPack* out, bool positions = true);
} /* namespace minimaxh3 */
#endif