minimaxh3+driver: a one-frame encode cannot exceed the deepest clip buffer, and must be refused for it

The venc_geom cap tested only the pixels volume -- clip * h * w against 17
squares -- but the encoder arena holds five volumes, and the temporal
downsamplers shrink a full clip 17 -> 9 -> 5 while a one-frame clip stays 1:
the deep buffers (5 frames at their side) bind a single frame at
h * w <= 5 * kEncMaxSide^2, a ~572-sided square, not the 17-frame budget.
A 544x736 endpoint keyframe (the workflow-native Flair size) passed the
volume check and then killed the server mid-step: `operand 5 reaches past
buffer 'venc.l3.in': [6256,256] at offset 0, declared [5120,256]`. Check
every volume; the spatial divisor cancels between clip and arena, so the
temporal factors alone decide. 512^2 keyframes, every reference video and
the 256-side pictures all ride exactly as before.

The driver's picture and keyframe branches never asked the encoder at all
(only videos queried rad_arch_encode_geom), so the refusal has to arrive at
accept: probe the geometry for one-frame media and name the size in the
error, instead of a step-time rad_step_fail -- which stops the engine and
takes the server with it.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-22 21:21:31 -05:00
1 parent 4ca02f18dd
commit a75bdd7fd6
2 files changed
+38 -3

No files matched your search

+19 -3
View File
@@ -2360,6 +2360,7 @@ static bool venc_geom(int64_t frames, int64_t h, int64_t w, int32_t* out) {
return false;
const int64_t clip = frames == 1 ? 1 : kVaeClipLength;
const int64_t n_clips = frames == 1 ? 1 : (frames + kVaeClipLength - 1) / kVaeClipLength;
const int64_t t1 = (clip + 1) / 2, t2 = (t1 + 1) / 2;
/* The side the buffers set the ceiling on, not a flat number: they hold ONE clip's pixels at
* a time, sized for a full kVaeClipLength-frame clip at kEncMaxSide, so a media fits while
* clip * h * w stays within that volume. A multi-frame reference video is unchanged -- clip
@@ -2369,14 +2370,29 @@ static bool venc_geom(int64_t frames, int64_t h, int64_t w, int32_t* out) {
* across the TARGET grid (they are resized to the target canvas before the VAE, rad_ref2va_pack
* ref2va_build), so an endpoint pin at output resolution is what the DiT attends to; the flat
* kEncMaxSide cap used to refuse them at any output above 256. The slot-latent check below and
* step_venc's own overflow check bound the result; nothing here enlarges a buffer. */
if (clip * h * w > (int64_t)kVaeClipLength * kEncMaxSide * kEncMaxSide) return false;
* step_venc's own overflow check bound the result; nothing here enlarges a buffer.
*
* The cap is per VOLUME, not just the pixels volume: the temporal downsamplers shrink a full
* clip 17 -> 17 -> 9 -> 5 but a one-frame clip only 1 -> 1 -> 1 -> 1, so the deep buffers --
* 5 frames' worth at their side -- bind a single frame at h * w <= 5 * kEncMaxSide^2 (a
* ~572-sided square), not the 17-frame budget's 17 * kEncMaxSide^2. A 544x736 keyframe proved
* it: it
* passed the volume check, then the engine died on `venc.l3.in` 6256 > 5120 rows. The spatial
* divisor is the same on both sides of each comparison, so it cancels and only the temporal
* factors remain. */
{
const int64_t tv[5] = { clip, clip, t1, t2, t2 };
const int64_t fv[5] = { kVaeClipLength, kVaeClipLength, (kVaeClipLength + 1) / 2,
((kVaeClipLength + 1) / 2 + 1) / 2,
((kVaeClipLength + 1) / 2 + 1) / 2 };
for (int i = 0; i < 5; ++i)
if (tv[i] * h * w > fv[i] * (int64_t)kEncMaxSide * kEncMaxSide) return false;
}
const int64_t lat = vae_latent_frames(frames);
const int64_t full = vae_clip_latents(clip);
const int64_t last = lat - full * (n_clips - 1);
if (lat < 1 || full < 1 || last < 1 || last > full) return false;
if (!out) return true; /* the export's validation call, which wants only the answer */
const int64_t t1 = (clip + 1) / 2, t2 = (t1 + 1) / 2;
const int64_t g[5][3] = { { clip, h, w }, { clip, h / 2, w / 2 }, { t1, h / 4, w / 4 },
{ t2, h / 8, w / 8 }, { t2, h / 16, w / 16 } };
int32_t* o = out;
+19
View File
@@ -515,6 +515,16 @@ int VideoDriver::shape_job(Job& j, const VideoRequest& r, int32_t chunks, int32_
return d.enc_ratio < 1 || m.enc_h < d.enc_ratio || m.enc_w < d.enc_ratio ||
m.enc_h % d.enc_ratio || m.enc_w % d.enc_ratio;
};
/* A picture or an endpoint keyframe folds through the VAE as a ONE-frame clip, which is
* why it rides at a far larger side than a video can -- but "larger" is not "unbounded":
* the encoder's per-level buffers hold a full clip's worth of the DEEPEST temporal stage,
* so one frame cannot exceed a fifth of the pixels budget no matter how few frames it
* has. The geometry call answers that; asking it here refuses an over-cap media at
* accept, where a step-time refusal would stop the whole engine. */
auto one_frame = [&](const VideoRefMedia& m) {
const int64_t in[4] = { 1, m.enc_h, m.enc_w, 3 };
return !enc_geom_ || enc_geom_(RAD_GEN_PASS_VENCODE, in, eg, 25) >= 0;
};
for (size_t i = 0; i < r.refs.size(); ++i) {
const VideoRefMedia& m = r.refs[i];
if (m.kind == VideoRefMedia::IMAGE) {
@@ -526,6 +536,10 @@ int VideoDriver::shape_job(Job& j, const VideoRequest& r, int32_t chunks, int32_
return no("'" + m.name + "' has encoder sides (" + std::to_string(m.enc_h) +
"x" + std::to_string(m.enc_w) + ") the VAE grid of " +
std::to_string(d.enc_ratio) + " does not divide");
if (!one_frame(m))
return no("'" + m.name + "' is " + std::to_string(m.enc_h) + "x" +
std::to_string(m.enc_w) +
", a single frame larger than the video encoder's capacity");
j.enc_q.push_back({RAD_ENC_IMAGE, m.index, (int32_t)i});
if (j.ref_tab.empty()) j.ref_tab.assign(2, 0); /* [n_refs, n_keys] */
++j.ref_tab[0];
@@ -602,6 +616,11 @@ int VideoDriver::shape_job(Job& j, const VideoRequest& r, int32_t chunks, int32_
return no("'" + m.name + "' has encoder sides (" + std::to_string(m.enc_h) +
"x" + std::to_string(m.enc_w) + ") the VAE grid of " +
std::to_string(d.enc_ratio) + " does not divide");
if (!one_frame(m))
return no("'" + m.name + "' is " + std::to_string(m.enc_h) + "x" +
std::to_string(m.enc_w) +
", a single frame larger than the video encoder's capacity; a keyframe "
"encodes at the output resolution, so ask for a smaller size");
if (j.ref_tab.empty()) j.ref_tab.assign(2, 0); /* [n_refs, n_keys] */
const int32_t slot = ++j.ref_tab[1]; /* keyframe order -> image slot 1, 2 */
j.enc_q.push_back({RAD_ENC_IMAGE, slot, (int32_t)i});