Repository navigation
Model L runtime frame on the HIP backend (confirmed FORMATS.md interface) - #111
Merged
Merged
Conversation
phantoslayer21
force-pushed
the
model-l/runtime-frame-l
branch
from
November 14, 2026 00:43
3fa09d7 to
7471a12
Compare
phantoslayer21
force-pushed
the
model-l/runtime-frame-l
branch
4 times, most recently
from
November 14, 2026 02:19
843f5fa to
23c12e8
Compare
phantoslayer21
marked this pull request as ready for review
November 14, 2026 02:21
…ncoder and decoder (FORMATS.md interface) Builds with WG_MODEL_L (clean/l/runtime compiled in) accept model=L. Model data: only the converter's model.wgcm in <model_dir>/L, checked against the preset-L map (l::load_wgcm_model); raw tensors are refused. Model M's ten Swin stages packed as before, Model L's blobs from wgrt::l::pack_model, code objects l_enc_values.co (tag lev), l_ops.co, l_swin.co. Step 2: values into the halo map, the two per-pixel linears, the encoder block, the gather projection. Step 4: the decoder projection, the decoder block, l_coef. Kernel names, arguments, grids and maps as clean/l/FORMATS.md (#113). No pack12 for Model L; the fused dec1 + dec0, recon=output, motion_outres=original, enc0 variants and backends 1 to 3 are refused. Without WG_MODEL_L nothing changes. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ence clean/l/runner/l_frame_check.py runs the runtime's Model L frame (model.wgcm through l::load_wgcm_model, runtime option model=L) on the HIP backend for a sequence of frames (aligned and non-aligned render sizes, a size change, game resets, both parities) with every stage output read back, and checks each stage on the runtime's own inputs against the float64 references: Model L's encoder and decoder (clean/l/reference/oracle.py), the ten shared Swin stages, post and the filter, plus the state handed from frame to frame. Model M's frame on the same harness is the control. The bottleneck runs as six launches for the stage checks (the default megakernel leaves b0 ... b4's buffers unwritten); the default kernels must give the same bytes. --prepare and --compare run on the CPU; only --run uses the GPU (in a GPU slot, with clean/runner/hip.py's environment). Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…d blobs The review's remaining item for #111: the recorder now names allocations, and the Model L test asserts each launch's weight buffer and its input / output roles. - clean/tests/runtime_frame_trace.cpp logs what create uploads with the bytes' SHA-256 ("upload b<k>+<offset> <bytes> <digest>") and, after each frame, every buffer name the runtime knows ("name <buffer> b<k>+<offset> <bytes>", from wg_rt_buffer). Trace parses both. - clean/runtime/runtime.cpp names Model L's three maps for wg_rt_buffer (l.wide, l.narrow, l.x3). - test_l_runtime_frame.py: every argument of the eight Model L launches against the named buffers (inputs, state, maps, features, dec1's output, A, B, C, latent) and the weight blobs, found by the hash of the blob l_pack.py packs from the test model's parameters. Ten mix-ups in a recorded frame (Win1 / Win2, the two blocks, the two projections, values / coef, A / B, C / latent, colour / depth, latent / motion history, m_near / m_far, q / x1) each fail; so does a runtime built with enc0.Win1 and enc0.Win2 swapped, whose frames still pass the map chain, size and grid checks. - clean/tests/host_cxx.py: build() takes extra include folders (the mutated runtime source is compiled from a temporary folder). Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
force-pushed
the
model-l/runtime-frame-l
branch
from
November 14, 2026 02:34
23c12e8 to
e6878ab
Compare
This was referenced Nov 14, 2026
phantoslayer21
added a commit
that referenced
this pull request
Nov 14, 2026
…encoder and decoder Model L on backend 3 (native D3D12) runs Model M's native frame with Model L's encoder (step 2) and decoder (step 4). Its coefficients go through the pack12 store l_coef_pack12 (lossless, #131 / #134) into Model M's pack12 post path, the only post path ported to D3D12. dec1 runs its own block (Model M fuses it into its pack12 decoder there; Model L's decoder reads dec1's map), so the xe / xo / xd fusions, which need that fused decoder, are off for Model L; pm, mb and rv apply as for Model M. - clean/runtime/runtime.cpp: - Model L is accepted on backend 3 (builds with WG_MODEL_L); - at create, every D3D12 port Model L needs that <build>/dx12/manifest.json lacks is refused by name, "not yet ported to D3D12": its encoder (the _direct form on the direct-resource route), linears, clamp-free blocks, projections, l_coef_pack12, and dec1's own block swin_block_c64_add_ex_nc. Weights that need a clamped block are refused too (only the _nc forms are ported); - pack12 is Model L's default on backend 3 and required there; on HIP it stays refused (l_coef, base format); - the encoder launches lev/input_encoder_direct on the direct-resource route; the decoder launches l_coef_pack12 on pack12 frames; - the direct-resource checks accept Model L without the fused pack12 decoder. - clean/tests/runtime_frame_trace.cpp: --backend=<n>; l_coef_pack12's arguments decoded. - test_l_runtime_frame.py, class D3D12: the manifest is built from the repository's own @wg-kernel declarations. The missing ports are named, and each one alone is named; with every port present, the frame passes #111's checks on backend 3 (map chain, extents, offsets, parameters, every argument against named buffers and blobs, history, sizes, resets, a failed launch), with the pack12 images' extents, dec1's own block and Model M's pack12 post after the store. Model M on backend 3 traces the same with and without Model L in the build. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
added a commit
that referenced
this pull request
Nov 14, 2026
…encoder and decoder Model L on backend 3 (native D3D12) runs Model M's native frame with Model L's encoder (step 2) and decoder (step 4). Its coefficients go through the pack12 store l_coef_pack12 (lossless, #131 / #134) into Model M's pack12 post path, the only post path ported to D3D12. dec1 runs its own block (Model M fuses it into its pack12 decoder there; Model L's decoder reads dec1's map), so the xe / xo / xd fusions, which need that fused decoder, are off for Model L; pm, mb and rv apply as for Model M. - clean/runtime/runtime.cpp: - Model L is accepted on backend 3 (builds with WG_MODEL_L); - at create, every D3D12 port Model L needs that <build>/dx12/manifest.json lacks is refused by name, "not yet ported to D3D12": its encoder (the _direct form on the direct-resource route), linears, clamp-free blocks, projections, l_coef_pack12, and dec1's own block swin_block_c64_add_ex_nc. Weights that need a clamped block are refused too (only the _nc forms are ported); - pack12 is Model L's default on backend 3 and required there; on HIP it stays refused (l_coef, base format); - the encoder launches lev/input_encoder_direct on the direct-resource route; the decoder launches l_coef_pack12 on pack12 frames; - the direct-resource checks accept Model L without the fused pack12 decoder. - clean/tests/runtime_frame_trace.cpp: --backend=<n>; l_coef_pack12's arguments decoded. - test_l_runtime_frame.py, class D3D12: the manifest is built from the repository's own @wg-kernel declarations. The missing ports are named, and each one alone is named; with every port present, the frame passes #111's checks on backend 3 (map chain, extents, offsets, parameters, every argument against named buffers and blobs, history, sizes, resets, a failed launch), with the pack12 images' extents, dec1's own block and Model M's pack12 post after the store. Model M on backend 3 traces the same with and without Model L in the build. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
added a commit
that referenced
this pull request
Nov 14, 2026
…encoder and decoder Model L on backend 3 (native D3D12) runs Model M's native frame with Model L's encoder (step 2) and decoder (step 4). Its coefficients go through the pack12 store l_coef_pack12 (lossless, #131 / #134) into Model M's pack12 post path, the only post path ported to D3D12. dec1 runs its own block (Model M fuses it into its pack12 decoder there; Model L's decoder reads dec1's map), so the xe / xo / xd fusions, which need that fused decoder, are off for Model L; pm, mb and rv apply as for Model M. - clean/runtime/runtime.cpp: - Model L is accepted on backend 3 (builds with WG_MODEL_L); - at create, every D3D12 port Model L needs that <build>/dx12/manifest.json lacks is refused by name, "not yet ported to D3D12": its encoder (the _direct form on the direct-resource route), linears, clamp-free blocks, projections, l_coef_pack12, and dec1's own block swin_block_c64_add_ex_nc. Weights that need a clamped block are refused too (only the _nc forms are ported); - pack12 is Model L's default on backend 3 and required there; on HIP it stays refused (l_coef, base format); - the encoder launches lev/input_encoder_direct on the direct-resource route; the decoder launches l_coef_pack12 on pack12 frames; - the direct-resource checks accept Model L without the fused pack12 decoder. - clean/tests/runtime_frame_trace.cpp: --backend=<n>; l_coef_pack12's arguments decoded. - test_l_runtime_frame.py, class D3D12: the manifest is built from the repository's own @wg-kernel declarations. The missing ports are named, and each one alone is named; with every port present, the frame passes #111's checks on backend 3 (map chain, extents, offsets, parameters, every argument against named buffers and blobs, history, sizes, resets, a failed launch), with the pack12 images' extents, dec1's own block and Model M's pack12 post after the store. Model M on backend 3 traces the same with and without Model L in the build. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Model L's runtime frame on the HIP backend (P13): Model M's frame with Model L's encoder in step 2 and its decoder in
step 4. It follows the confirmed interface in
clean/l/FORMATS.md(#113): maps, FP16 formats, the halo, blobnames, kernel names, arguments, grids and launch order. The ten Swin stages, exposure and post are Model M's,
unchanged. It is compiled in only with the define
WG_MODEL_L(the L sources inclean/l/runtime); the build switchthat sets it and builds the
l_*.cocode objects comes next. Without the define, nothing changes.Three commits on main (#113, #115, #119 and #125 are in): eb278cb the frame, 9d86126 its GPU check,
e6878ab buffer identities in the recorder and the tests (the re-check's remaining item).
The review's list:
test_l_runtime_abi.pycompiles the three code objects from main'ssources and checks, from each code object's own kernel metadata, that every kernel the frame launches is exported
with exactly the arguments the runtime passes (count and sizes).
l::load_wgcm_modelagainst the preset-L map.Raw folders are refused, and so is a mixed file (Model L's own stages with Model M's shared stages).
aligned, non-aligned and changing, and a failing launch. With the real kernels on the GPU (HIP), every stage's
output and the history are compared with the CPU reference over both parities and resets: see "GPU record".
SHA-256, and after each frame every buffer name of
wg_rt_buffer, Model L's three maps included (l.wide,l.narrow,l.x3). Every argument of the eight Model L launches is asserted against these names: inputs, state,maps, features, dec1's output, A, B, C, latent, and the weight blob. Each blob is found by the hash of the bytes
l_pack.pypacks from the test model's parameters, so the weights are named independently of the runtime. Swappingenc0.Win1andenc0.Win2now fails: seeRolesunder "Tested".GPU record (HIP,
clean/l/runner/l_frame_check.py, on 23c12e8; re-run on e6878ab with the same results)The runtime's Model L frame runs on the HIP backend:
model.wgcmthroughl::load_wgcm_model, runtime optionmodel=L, the build's real code objects. Every stage output is read back (clean/runner/pipeline.py), and each stageis checked on the runtime's own inputs against the float64 reference with the kernels' GELU, as
test_runtime.pydoes in the emulator:
clean/l/reference/oracle.py;clean/reference/swin.py;clean/reference/post.py.Model M's frame on the same harness is the control (
post_pack=none, the base coefficient format and post kernel thatModel L uses). Synthetic models (Model L:
oracle.random_params) and synthetic frames;--prepareand--comparerunon the CPU, only
--runuses the GPU.Effective resets on frames 0 (first), 2 (game), 5 (size change), 8 (size change) and 9 (game).
gpu_slot.py --cap-s 170, the frames of both models in 2.0 s (waited 10 s; on e6878ab 2.0 s, nowait). The environment is
clean/runner/hip.py's.window offsets, and the latent, motion history and full history handed over byte for byte.
swin_bneck=none). The default megakernel writes only b5'soutput. The default kernels' outputs are byte-identical to the six-launch run on all 11 frames, both models; on the
first frame the previous-frame state buffers are left out, since no frame has written them yet.
11 frames.
Values that differ from the reference, over the 11 frames (largest difference in FP8 steps, FP16 ulps or codes):
The worst single frame for the enc0 features has 0.14 % of values more than one FP8 step off (the rule allows 2 %).
Found on the way: in a default build,
Pipeline.debug_outputsreports b0 ... b4 from buffers that the bottleneckmegakernel never writes. That is Model M's existing behaviour and is not changed here; the check works around it.
What changes
clean/runtime/model_select.h:model_l_built()(true withWG_MODEL_L).model_from_options(
clean/k/runtime/model_k.cpp,clean/runtime/no_model_k.cpp) acceptsmodel=Lwhen it is built and refuses itby name as before when not. The unknown-model message lists L only when built.
no_model_k.cppnow returns thechosen model (it always returned M; M was the only one it could accept).
clean/runtime/runtime.cpp, formodel=L:model data: only
<model_dir>/L/model.wgcm, checked against the preset-L map (wgrt::l::load_wgcm_model:whole-file hash, every stage's keyed digest, names, types, shapes, values). The map is
map_pathwhen it isthat file, else
preset-L.v1.map.jsonnext to it (or in the build folder). Raw tensors (model_format=1) arerefused: nothing in them shows that they are Model L's;
Model M's ten stage blobs as before, plus Model L's blobs from
wgrt::l::pack_model(enc0.values,enc0.Win1,enc0.Win2,enc0_block,enc0.project,dec0.project,dec0_block,dec0.coef);_ncfor both blocks from bit 0 of their blobs;code objects
l_enc_values.co(taglev),l_ops.co,l_swin.co, in place ofencoder.coanddecoder.co;three buffers for the maps:
q, thenx2(FP16), then the decoder'sy2(FP16);x1, then the decoder'sy;x3on the grid.No kernel runs in place; the reuse is the one FORMATS.md allows.
lev/input_encoder(Model M's arguments,qin place of the features, grid over the halo map's 2 x 2groups),
l_linear_32_32_relu,l_linear_32_32_f16,l_swin_block_c32_enc[_nc](H = fh, W = fw, offsets"first"),
l_project_gatherinto enc0's features.l_dec_project(dec1's output toy),l_swin_block_c32_dec[_nc](offsets "second"), andl_coefintoA, B, C and the new latent.
l_coeftakes Model M'sWgDecParams; no motion, previous latent, jitter or reset ispassed.
l_coefwrites Model M's base coefficient format, so the_p12post kernels donot apply. pack12 is not chosen by default for Model L, and
post_pack=p12is refused.WG_DEC1_DEC0=fused,recon=output,motion_outres=original, enc0 variants. Backends 1 and 2 refuse Model L;backend 3 already did.
runtime_model()returns "L"; the kernel summary ends withmodel=L l_kernels=...(Model L only).clean/l/runtime/tests/test_l_runtime_frame.py,test_l_runtime_abi.py(new).clean/tests/runtime_frame_trace.cpp:upload b<k>+<offset> <bytes> <SHA-256>for create's uploads andname <buffer> b<k>+<offset> <bytes>after each frame;test_runtime_frame_trace.Traceparses both(
uploads, each frame'snames,uploaded(digest)).clean/runtime/runtime.cppnames Model L's maps forwg_rt_buffer.clean/tests/host_cxx.py:build()takes extra include folders.clean/l/runner/l_frame_check.py(new): the GPU check above.--preparebuilds Model L's code objects and aruntime library with
WG_MODEL_Linto a build folder that holds build.py's code objects (build.py has no Model Lrow yet).
The coefficient value positions (the 13 of
table.L_DEC_VALUES/ map v1.1) live insidel_coef; the runtime passesno list.
Refs #89
Tested
On the CPU (the recording device of #108 / #119 records launches and their arguments and runs nothing):
Roles(intest_l_runtime_frame.py), 3 tests, OK:blobs are eight distinct allocations. The same check also runs inside every
Argumentsframe;values / coef weights, A / B, C / latent, colour / depth, previous latent / motion history, m_near / m_far, and
q's map / x1's map;
enc0.Win1andenc0.Win2swapped in its source still passes the map chain, size, grid andparameter checks, and fails the role check on exactly the two linears' weight arguments.
test_l_runtime_frame.py, 8 tests, OK (clang++):input_encoderandcoef_decoderreplaced by Model L'ssteps. The grids are computed from FORMATS.md, the offsets from
table.block_offset, and_ncfroml_pack.pack_model_l's block blobs. Run with an empty build folder and with a full build's optional code objects(no pack12 kernel in Model L's frame; the wave64 post kept);
latent;
l_coefwrites and the near motion the encoder writes are what the next frame's encoderreads; the two latent buffers swap;
frames (reset 1, 0, 0, 0; both parities);
l_coeffailure stops its frame right after the decoder block; the next frame runs whole;encoder.co/decoder.coare not; Model M in the build withWG_MODEL_Ltraces the same as without it;
the map's digest"), the same file with Model L's stages (loads);
WG_POST_PACK=p12.test_l_runtime_abi.py, 2 tests, OK:l_enc_values.co,l_ops.co,l_swin.cocompiled from main's sources(HIP SDK 7.2 clang, compile only,
l_c32_check.compile_kernels). Their AMDGPU metadata gives:input_encoder12 x 8 + 116 bytes;l_linear_32_32_relu/_f168, 8, 8, 4;l_project_gatherandl_dec_project8, 8, 8, 4, 4;l_coef6 x 8 + 56;l_swin_block_c32_enc[_nc]/_dec[_nc]4 x 8 + 4 x 4.These are exactly the frame trace's argument kinds, which the recorder checks the runtime's launches against. CI has
no HIP SDK, so CI skips this test.
Mutation check: with
l_project_gathergiven x2 instead of x3, the argument tests fail (three of three).Model M unchanged: the 14-case runtime frame trace set, now with every decoded argument, is byte-identical between
Runtime frame trace: launch arguments, allocations, sizes, resets, an injected failure #119's head and this commit without
WG_MODEL_L. WithWG_MODEL_Lit is identical except two expected messages(
model=Lnow refuses the raw folder; "known: M, L").clang++ (ROCm 7.2)
-Wall -Wextra, objects of runtime.cpp, model_k.cpp / no_model_k.cpp, l_pack.cpp, l_model.cpp inthe four builds with and without Model K and Model L: 0 diagnostics.
clang++:
clean/l/runtime/tests/test_l_runtime_*.py18 tests OK;clean.tests.test_runtime_frame_trace,test_model_select,test_model_filter,test_model_pack_cpp,clean.k.tests.test_k_runtime_pack,test_k_runtime_tables,clean.l.tests.test_l_pack,test_l_reference: 81 tests OK, and the L runtime tests(19) OK, after the rebase onto main with Model L reference: confirmed encoder and decoder arithmetic (FP16 block maps, block borders, L's per-pixel functions) #113 (3cb87db). On 0ebc989 (with Model L kernels: encoder and decoder blocks, input linears, projections, coefficient step (HIP) #115): the L runtime tests (21, the ABI
test included) OK, and the Model M trace set again identical to Runtime frame trace: launch arguments, allocations, sizes, resets, an injected failure #119's head (14 cases). On e6878ab (main
613f293): the L runtime tests (24) OK;
test_runtime_frame_trace,test_model_select,test_model_filter,test_model_pack_cpp(31) OK. The Model M trace set (14 cases) is identical to main's once the recorder's newupload/namelines are left out; withWG_MODEL_L, identical except the two expected messages.Not tested