Archived
PIN ref2va: verified device differential + ref-count gate (revert anchor)
Ref2VA ref-image conditioning verified on-device: ref step runs all steps no fault; output differs ref-present vs ref-absent (by log). 6-9 images rejected cleanly at submit (no engine crash). Merged-cell modulation (<=9) tracked next. NOTE: placeholder author -- re-author before any push. Do NOT push this branch. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
816e24bd46
commit
490d4c604a
73 files changed
+16484
-432
No files matched your search
+99
-1
@@ -853,9 +853,29 @@ int rad_declare_audio_generator(RadBuilder* b, const RadAudioGenDecl* d);
|
||||
* pass carries the geometry its latent has at that point: a step before the VUPSCALE pass is at
|
||||
* W' x H'. The schedule is the request's own, whatever size each evaluation runs at.
|
||||
*
|
||||
* Reference conditioning (ref2va), for a program whose container carries the VAE encoders
|
||||
* (`encodes`, below): before the prompt pass the driver encodes the request's reference media,
|
||||
* one media a pass. Nothing the passes make is read back — each latent lands in the lane, and the
|
||||
* step's packed sequence carries it:
|
||||
*
|
||||
* RAD_GEN_PASS_VENCODE one reference video's frames, staged in `enc_pixels` (RadVideoGenBatch),
|
||||
* to the lane's video latents.
|
||||
* RAD_GEN_PASS_AENCODE one reference audio's samples, staged in `enc_samples`, to the lane's
|
||||
* soundtrack latents.
|
||||
*
|
||||
* `enc_kind` names the media (RAD_ENC_*, rad_runtime.h) and `enc_slot` is its 1-based number
|
||||
* within that kind; RAD_ENC_TAIL — slot 0 — is the request's continuity tail, the frames of the
|
||||
* clip it continues, which rides Vencode. The media an encoder takes is bounded by the model:
|
||||
* reference pictures are one frame, reference video and the tail up to 289 frames, every frame
|
||||
* at most 256 x 256 with both sides multiples of 16, and a reference audio up to 500 000
|
||||
* samples; `rad_arch_encode_geom` (below) is the authority and refuses what it cannot encode. A
|
||||
* program without the encoders declares neither pass and `encodes` stays 0, so the server
|
||||
* refuses a request that carries references.
|
||||
*
|
||||
* A program declares exactly one of this, the other generators, logits or pooled vectors. */
|
||||
enum { RAD_GEN_PASS_VCOND = 8, RAD_GEN_PASS_VSTEP = 9, RAD_GEN_PASS_ADECODE = 10,
|
||||
RAD_GEN_PASS_VDECODE = 11, RAD_GEN_PASS_VUPSCALE = 12 };
|
||||
RAD_GEN_PASS_VDECODE = 11, RAD_GEN_PASS_VUPSCALE = 12,
|
||||
RAD_GEN_PASS_VENCODE = 13, RAD_GEN_PASS_AENCODE = 14 };
|
||||
|
||||
typedef struct RadVideoGenDecl {
|
||||
const char* name; /* "minimax-h3" -- the served model id and messages */
|
||||
@@ -902,6 +922,49 @@ typedef struct RadVideoGenDecl {
|
||||
* and fewer than the default schedule's. */
|
||||
double upscale_max;
|
||||
int32_t upscale_refine;
|
||||
|
||||
/* Reference media a request may carry (ref2va): the ceilings the server enforces and
|
||||
* `/v1/models` reports. All 0 — the zero default — on a generator that conditions on no
|
||||
* reference media, which is how the server refuses the task outright; a generator declares
|
||||
* them only once it can actually consume the bytes. Trailing since ABI 22: an older plugin's
|
||||
* declaration reads none and keeps the 0 default. */
|
||||
int64_t max_ref_images, max_ref_videos, max_ref_audios;
|
||||
|
||||
/* Nonzero when the container carries the video and audio VAE encoders, so the driver may
|
||||
* stage Vencode and Aencode passes (above). Trailing since ABI 23: an older plugin declares
|
||||
* none and keeps the 0 default. */
|
||||
int32_t encodes;
|
||||
|
||||
/* The ceilings one encode pass may carry, so the driver can size its staging slab: a video's
|
||||
* clip-padded frame count, the encoder's side (square, a multiple of its downsample), and an
|
||||
* audio's sample count. Only meaningful with `encodes`; 0 otherwise. The driver stages at most
|
||||
* one media item per pass, so the slab is these bounds, not a per-request sum. Trailing since
|
||||
* ABI 23 (the encoder's own pass enums and batch fields): an older plugin declares none. */
|
||||
int64_t max_enc_frames, max_enc_side, max_enc_samples;
|
||||
|
||||
/* The encoder's spatial downsample, so the server can snap a reference's sides to a multiple
|
||||
* of it before handing them over (the geom refuses any other). Distinct from `size_multiple`,
|
||||
* which bounds the *generated* video's size and is a further multiple of this. Only meaningful
|
||||
* with `encodes`; 0 otherwise. Trailing since ABI 23. */
|
||||
int32_t enc_ratio;
|
||||
|
||||
/* Nonzero when this generator's denoiser *consumes* the reference table the driver stages in
|
||||
* `RadVideoGenBatch::ref_tab` — i.e. its per-step packed sequence already interleaves the
|
||||
* reference blocks between the text and the audio/video targets, so the driver must size and
|
||||
* stage those rows (via `rad_arch_video_pack`) rather than the plain `[text|audio|video]`
|
||||
* layout. Trailing since ABI 23: an older plugin declares none and keeps the 0 default, which
|
||||
* is exactly the plain path — the driver then never widens rows or segment boundaries and the
|
||||
* generated bytes are unchanged. It is the arch, not the driver, that knows whether its own
|
||||
* denoiser reads `ref_tab`, so this flag is what makes staging and consumption flip together. */
|
||||
int32_t ref_rows;
|
||||
|
||||
/* The largest segment count this generator's modulation table holds: its denoiser lays out one
|
||||
* modulation cell per pack segment, and the table is sized `kMaxSegs` columns. A conditioned
|
||||
* pack whose segments exceed this cannot be built -- the step would abort the engine. The driver
|
||||
* refuses such a request at submit (it lays the pack out itself, so it knows the count before
|
||||
* dispatch) rather than letting the arch fail mid-generation. 0 = no reference consumption, so
|
||||
* no such limit. Trailing since ABI 23: an older plugin declares none and keeps the 0 default. */
|
||||
int32_t max_ref_segs;
|
||||
} RadVideoGenDecl;
|
||||
|
||||
int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d);
|
||||
@@ -1184,6 +1247,41 @@ typedef struct RadVideoGeom {
|
||||
enum { RAD_VPOS_STEP = 1, RAD_VPOS_DECODE = 2 };
|
||||
int64_t rad_arch_video_positions(int which, const RadVideoGeom* g, float* pos, int64_t cap);
|
||||
|
||||
/* The packed sequence's segment boundaries for a video generator: cu[k] is the first row of
|
||||
* segment k (modulation, attention sinks -- whatever segmentation the model lays out), and
|
||||
* cu[n-1] the sequence's total rows -- the same rows RAD_VPOS_STEP positions. With `cu` null
|
||||
* it returns the number of int32s needed; with `cap` too small, a negative status. Additive
|
||||
* export; RAD_ABI_VERSION does not move -- a driver without it stages its own segmentation,
|
||||
* which for a plain [text | audio | video] request is this table. Called on any thread. */
|
||||
int64_t rad_arch_video_segs(const RadVideoGeom* g, int32_t* cu, int64_t cap);
|
||||
|
||||
/* The geometry of a video generator's encode passes (RAD_GEN_PASS_VENCODE, RAD_GEN_PASS_AENCODE;
|
||||
* rad_builder.h, "Reference conditioning"): the i32 vector the driver stages into the pass's
|
||||
* `enc_geom_d` device buffer, derived from the media's own shape, because what the network's
|
||||
* strided convolutions and causal attention run at — the padded sample length, the latent frame
|
||||
* count — is only the model's to know. `kind` is the pass value; `in` is four i64s
|
||||
* {frames_or_samples, height, width, channels}, each unused entry 0. With `out` null it returns
|
||||
* the number of int32s needed, or a negative status for media the model cannot take; with `out`
|
||||
* it fills `out[cap]`. The driver stages the samples right-padded with zeros to the length this
|
||||
* reports (entry 0), and copies these bytes to the device verbatim: it interprets nothing.
|
||||
* Additive export; RAD_ABI_VERSION does not move — a driver without it drives no encode pass and
|
||||
* the server refuses references. Called on any thread. */
|
||||
int64_t rad_arch_encode_geom(int32_t kind, const int64_t* in, int32_t* out, int64_t cap);
|
||||
|
||||
/* The whole packed-sequence layout of a reference-conditioned video request: the general form
|
||||
* of rad_arch_video_segs. `g` is the target's geometry and `ref_tab` the request's keyframes
|
||||
* and VAE references -- RadVideoGenBatch::ref_tab, its int32 table verbatim -- or null when the
|
||||
* request conditions on no VAE media, which lays out the plain [text | soundtrack | video]
|
||||
* sequence. Returns the packed sequence's total rows -- the rows RAD_VPOS_STEP positions -- or
|
||||
* a negative status for counts the model cannot present or caps too small to write into. With
|
||||
* `seg` non-null it writes the segment boundaries (seg[k] the first row of segment k, of the n
|
||||
* it needs) when `cap_seg` int32s hold them; with `pos` non-null the rotary positions (f32
|
||||
* [3, rows]) when `cap_pos` rows hold them. A null `seg` and `pos` answer with the rows alone,
|
||||
* which is all a submit needs to size the request. Additive export; RAD_ABI_VERSION does not
|
||||
* move -- a driver without it refuses reference requests. Called on any thread. */
|
||||
int64_t rad_arch_video_pack(const RadVideoGeom* g, const int32_t* ref_tab, int32_t* seg,
|
||||
int64_t cap_seg, float* pos, int64_t cap_pos);
|
||||
|
||||
int rad_arch_declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx);
|
||||
/* Forward declaration; the signature is in rad_runtime.h. */
|
||||
struct RadCtx;
|
||||
|
||||
Reference in new issue
Block a user