Repository navigation
nemotron cuda: an encode hook on Vision, and a host test that a request encodes each image once - #1104
nemotron cuda: an encode hook on Vision, and a host test that a request encodes each image once#1104plotarmordev wants to merge 3 commits into
Conversation
…ot twice The merge of ashhart#897 and ashhart#938 put a `Vision.begin` where Bolt's branch set up its image rows, after the kept-prefix restore, and kept the one Super VL's images brought after the prompt-rows setup. The second ends the first pass and encodes every image again, so each image request ran the tower twice before its first chunk. The first call stays.
…st encodes each image once `Vision.encoder`, when set, takes a prompt pass's planned images in the tower's place, as Flash Next's `encoder` does (a `ctx` and an `encode` function). The new host test runs the actual lane prefill with a counting encoder and checks one encode per image per request; it fails with the duplicate `Vision.begin` that ashhart#1057 removed.
|
Linux CI crashed in |
|
Thanks @plotarmordev, this is landed on main as 2e81b6c and 4cd72a5, with you as the author. Your first commit's fix, one RADIO tower pass for a prompt with images, was already on main when we carried it (the duplicate - Synthema, Ash's AI Assistant. |
What this changes
The follow-up to #1057 you asked for: an encode hook on
Vision, so a host test can count encodes per request.zig/src/families/nemotron/cuda_vision.zig:Vision.encoder: ?Encoder = null. AnEncoderis actxand anencodefunction, as Flash Next'sencoderis; when set,Vision.beginhands it the pass's images, planned spans androws buffer in place of
Tower.encode. Null (every server) keeps the tower call as it was.zig/src/families/nemotron/cuda_vision_lanes_test.zig(new, inzig build test): runs the actual lane prefill(
Cuda.backend().prefill, i.e.prefillFn) for a request with 1 image and with 3, twice each, with a counting encoder.It asserts one encode pass a request and one encode an image. The engine's own sequence is set to hold fewer rows than
the prompt, so
prefillFromreturnserror.ContextFullbefore its first chunk and nothing past the image setup needsa GPU.
cuda_vision_test.zigsets the hook to null so its test still reaches the real tower'serror.RowShapecheck.Stacks on #1057
#1057's fix is not on upstream main yet: main (d1018b3, after the 1.1.1 merge) still calls
Vision.beginatcuda_lanes.zig:299and again at:312, and main is the only public branch. On main as it is, the new test fails. Sothis branch sits on #1057. Its first commit is #1057's change rebased onto current main, with the same
git patch-id --stableas #1057's head e2357b5. Its second commit is the hook and the test. Once #1057 (or your 1.1.2carry of it) is on main, the first commit drops out and the second applies alone. The test only counts encodes before
the first chunk, so it passes whichever of the two calls the fix keeps.
The test fails without the fix
The new test alone, on the tip with #1057's commit reverted (main's prompt pass plus the hook):
The same step passes on the tip:
5/5 steps succeeded; 11/11 tests passed. The filtered step runs 11 tests, and thenew one is the only one that changes.
Receipt
Raw files: https://github.com/plotarmordev/TensorFold/tree/nemotron-receipts/receipts/nemotron/vision-encode-hook (
README.mdmaps every file;SHA256SUMS).nvcc 13.0,
-j1, a fresh cache for each step (scripts/gates.sh, output inhost/gates.txt).Vision.encodernull, soVision.begincallsTower.encodewith the samearguments as before. The added work is one null check a prompt pass with images.
zig build test: 211/211 steps, 2960 of 2974 tests passed, 14 skipped, 0 failed. Main: 211/211 steps, 2959 of2973, 14 skipped. The difference is the new test.
zig build test-kernel-contract: 65 of 65.zig build test-golden: 306/319 and 26/26 equal to the server goldens, 0 unexpected differences.zig build fuzz-cortheon: 11 of 11.zig fmt --check zig build.zig: clean on main and on the tip.tools/zig/lean_check.py: 444 problems on the tip, 444 on main, 0 new (tools/zig/lean_new.py).zig build fatbins -Dsm=121(182/182 steps) andzig build native -Doptimize=fast -Dstrip=true(7/7) succeed.tf-cuda-test kernel-contract: no kernel changed.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Serving code is unchanged while the hook is null; no GPU run.)SUMMARYline is in the receipt. (No kernel changed.)