Archived
minimaxh3+ops: a picture too big for one volume encodes tile-by-tile, as the reference does
vae.py's tiled_encode cuts a picture bigger than tile_size (256 px, 16
latents) into overlapping tiles, encodes each tile alone, and blends every
tile's RAW moments with its raw top and left neighbours -- top first, then
left, never an already-blended neighbour -- into the whole latent canvas.
GroupNorm normalises inside the volume it sees, so the tile seams are
observable: our port ran the whole canvas through the trunk at once, and a
photo or keyframe over 256 px a side drifted from the reference's look.
Three ops, libref/avx/r4d alike. vtile_plan lays each tile's geometry rows
the way vae.py splits -- round-robin slack, and one short tile on an axis
no longer than a tile. vtile_crop cuts the picture's pixels tile-major.
vtile_join blends the tile-major moments into the plain pass's b_eq2 with
vae.py's weights, every product and sum rounding through x's dtype. The
split carries one structural gift: with the slack fully distributed,
start[last] = len - tile, so every band is exactly a tile, and a short
band exists only in the single-band branch -- whose axis has no neighbour
to blend against. The join can therefore fetch the left neighbour always
at the full tile width while own and top fetch at the owner's own column
width, and vae.py's min() clamp inside blend is provably dead code.
step_venc_tiled runs the plain trunk once a tile: pixels from b_vtile,
moments out to one slice of b_eqt, the tile's six level geometries read
back off b_tplan (PERSIST) through raw pointers, exactly as every clip's
geometries come off enc_geom_d. The arena packs by declared lifetime, so
op_ve_q moved ahead of the trunk and the tiled ops sit last: b_vtile must
span op_ve_pix's first read to op_vt_crop at the tail and b_eqt must span
op_ve_q to op_vt_join, bracketing every trunk op the tiled pass re-runs.
b_vtile and b_eqt size tile-major at the declared tile cap; a picture
splitting past the cap step-fails by name. Clips never tile -- their
volume forces each side back to kEncMaxSide. OPS.md documents all three.
Verified: ref_test 264 cases (plan pins the round-robin overlaps {6,5,5}
and a short lone row with column neighbours; crop walks a short band at
ratio 4; join checks a 6x9 canvas with uneven round-robin splits point by
point, and a 32x32 eighths-exact f32 blend that must land bit-identical);
rad-avx-check scalar/avx/avx2 on all three ops; device r4d_selftest plan
4 / crop 8 (f32+bf16) / join 5 cases ok. Full ctest 123/123. ABI
unchanged at 28.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
47b7aae7a3
commit
69087ce773
15 files changed
+1407
-14
No files matched your search
@@ -2660,6 +2660,23 @@ static const RadOperandSpec oVtileStitch[] = {
|
||||
{ "x", RAD_OPD_IN, 0 }, { "geom", RAD_OPD_IN, 0 }, { "prev", RAD_OPD_INOUT, 0 },
|
||||
{ "y", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
/* The tiled encoder (r4d_video.hip): the plan, the cut and the blend. `geom` is the request's
|
||||
* (clip, H, W); plan and crop take it in pixels, join in latent units. */
|
||||
static const RadParamSpec pVtilePlan[] = { P_INT("M"), P_INT("tile"), P_INT("overlap"),
|
||||
P_INT("ratio") };
|
||||
static const RadOperandSpec oVtilePlan[] = {
|
||||
{ "geom", RAD_OPD_IN, 0 }, { "y", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
static const RadParamSpec pVtileCrop[] = { P_INT("M"), P_INT("tile"), P_INT("overlap"),
|
||||
P_INT("ratio"), P_STR("dtype") };
|
||||
static const RadOperandSpec oVtileCrop[] = {
|
||||
{ "x", RAD_OPD_IN, 0 }, { "geom", RAD_OPD_IN, 0 }, { "y", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
static const RadParamSpec pVtileJoin[] = { P_INT("M"), P_INT("tile"), P_INT("overlap"),
|
||||
P_INT("n"), P_STR("dtype") };
|
||||
static const RadOperandSpec oVtileJoin[] = {
|
||||
{ "x", RAD_OPD_IN, 0 }, { "geom", RAD_OPD_IN, 0 }, { "y", RAD_OPD_OUT, 0 },
|
||||
};
|
||||
static const RadParamSpec pGridPos3[] = { P_INT("M"), P_INT("T"), P_INT("H"), P_INT("W"),
|
||||
P_INT("period"), P_F64("scale") };
|
||||
static const RadOperandSpec oGridPos3[] = { { "y", RAD_OPD_OUT, 0 } };
|
||||
@@ -3600,6 +3617,19 @@ static const RadOpSchema kSchemas[] = {
|
||||
SCHEMA("vtile_stitch", pVtileStitch, oVtileStitch,
|
||||
"a decoded chunk's tiles stitched into RGB bytes, blended with the previous chunk's "
|
||||
"tail."),
|
||||
SCHEMA("vtile_plan", pVtilePlan, oVtilePlan,
|
||||
"the tiled encoder's plan for one frame of geom = (clip, H, W) pixels: the encoder's "
|
||||
"tile split over the spatial axes in latent units, tiles row-major; row t of the "
|
||||
"i32 [M, 22] y is the tile's first pixel, its pixel extent and the six level "
|
||||
"volumes (1, th / 2^min(L, 4), tw / 2^min(L, 4)); M is the tile count."),
|
||||
SCHEMA("vtile_crop", pVtileCrop, oVtileCrop,
|
||||
"one frame's pixel plane [>= H W, 3] (geom = (clip, H, W) pixels) cut into "
|
||||
"vtile_plan's tiles: y [M, 3] the tiles' pixels tile-major, M the tiles' pixel "
|
||||
"count."),
|
||||
SCHEMA("vtile_join", pVtileJoin, oVtileJoin,
|
||||
"the tiled encoder's per-tile moments blended into the canvas y [M, n] of "
|
||||
"geom = (clip, lat_h, lat_w): each position blended with the tile above and then "
|
||||
"the tile to the left, both RAW, the products and sums rounding to x's dtype."),
|
||||
SCHEMA("grid_pos3", pGridPos3, oGridPos3,
|
||||
"a video decoder's rotary positions over tiles of `period` rows, f32 [3, M]."),
|
||||
SCHEMA("conv3d_ndhwc", pConv3d, oConv3d,
|
||||
@@ -9313,6 +9343,27 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
nullptr, 0, NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_vtile_stitch },
|
||||
|
||||
{ "vtile_plan", "vtile_plan", "elem",
|
||||
"the tiled encoder's per-tile geometry table: a thread a (tile, entry)",
|
||||
"any M; the split reads geom on the device", "i32 table, i32 geom",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
nullptr, 0, NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_vtile_plan },
|
||||
|
||||
{ "vtile_crop", "vtile_crop", "elem",
|
||||
"a frame's pixel plane cut into the encode tiles: a thread a tile pixel row",
|
||||
"row pitches honoured", "f32 or bf16 plane and tiles",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
nullptr, 0, NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_vtile_crop },
|
||||
|
||||
{ "vtile_join", "vtile_join", "elem",
|
||||
"the encode tiles' moments blended into the latent canvas: a thread a canvas row",
|
||||
"row pitches honoured", "f32 or bf16 moments and canvas",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
nullptr, 0, NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_vtile_join },
|
||||
|
||||
{ "grid_pos3", "grid_pos3", "elem",
|
||||
"a video decoder's rotary positions over its tiles", "a [3, M] view at its own pitch", "f32",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
|
||||
Reference in new issue
Block a user