ops: the tiled encode ops take their row count from the operands, not from M

The engine never hands a kernel the issued value of a ranged parameter: the oracle
binds it to the matched band's bound, and ref_common.h's band_rows spells the rule
out -- the parameter stays a ceiling where one is stated -- which is why every
existing kernel derives its counts from its operands. vtile_plan/crop/join were the
first to read M as the row count of the call, so the first real tiled encode refused
on device: a 512 keyframe's 3 x 3 plan, issued under the band bound 33, tripped the
wrapper's rows-of-y < M clause, which answered RAD_E_STRIDE -- and the strerror
insisted, wrongly, that a non-contiguous operand was the problem. Crop and join
carried the same latent bug: crop would have launched 33 blocks over a ~590k-row
cut, and both would have refused every canvas under their bands' real bounds.

All three tiers now count from the operands and treat the passed M as the ceiling it
is -- y longer than the ceiling is refused, equality never demanded. The reference
and host tiers take the count from geom through band_rows; the device wrappers take
it from y's rows and pass that count in the kernel's M slot, which the kernels' own
operand-row guards make safe. OPS.md says the rule once at the head of the tiled
encoder section: an M written in a shape is an operand's row count, the ranged M
argument a ceiling only.

The host gates missed the bug precisely because they drove an exact M. ref_test's
three vtile cases now pass the band's bound -- 33, 33 * 256 * 256, 320 * 320 -- and
demand the same exact output, plus short-operand cases that must refuse E_SHAPE
under the over-declared ceiling; r4d_selftest drives the same bounds on device.
Verified: ref_test 264 cases, device vtile plan 4 / crop 8 / join 5 / gather 2 /
stitch 8 all exact, full ctest 123/123; and the FL2VA render that used to die in
tiled encode now runs its 25 steps with both keyframes visible in the decoded clip.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-25 11:23:15 -05:00
1 parent fe311c5c80
commit c463a0ab1b
6 files changed
+98 -40

No files matched your search

+6 -2
View File
@@ -1564,14 +1564,18 @@ one latent plane. The encoder itself is the existing per-level ops, issued per t
geometries; these three ops are the plan, the cut and the blend. Their axis split is vae.py's
`split_tiles`, whose multi-tile branch is the decoder's rule above exactly but whose single-tile
branch answers one tile `[0, L)` even when `tile > L` -- a lone short tile, which the decoder's
exact-fit split refuses. MiniMax-H3: `tile` 16 latents, `overlap` 4, `ratio` 16.
exact-fit split refuses. MiniMax-H3: `tile` 16 latents, `overlap` 4, `ratio` 16. An `M` written
in a shape below is that operand's row count, which the kernels read from the operand; the ranged
`M` argument is a ceiling only, as everywhere else -- the engine binds a ranged parameter to the
band's bound, never to this call's rows.
- `vtile_plan`: the plan for one frame of `geom` = `(clip, H, W)` pixels, split in latent units
over the spatial axes and numbered row-major over (row band, column band). Row `t` of the i32
`y [M, 22]`: the tile's first pixel `(y0, x0)` at [0] [1], its pixel extent `(th, tw)` at
[2] [3] (`tile ratio`, save the lone short tile), and level `L`'s volume
`(1, th / 2^min(L, 4), tw / 2^min(L, 4))` at `3 L + 4` for `L = 0..5` -- the encoder's five
levels and the deepest one's repeat, which shares it. `M` is the tile count.
levels and the deepest one's repeat, which shares it. The tile count is `y`'s row count, the
`M` argument a ceiling only.
- `vtile_crop`: the frame's pixel plane `x [>= H W, 3]` (pixel `(Y, X)` at row `Y W + X`) cut into
the plan's tiles: `y [M, 3]` holds the tiles' pixels tile-major, tile `t`'s `(th, tw)` rows in
plane order at their offset in the sum; `M` is the tiles' pixel count. The tiles' union covers