Repository navigation
dots: serve dots.mocr's images on CUDA with --vision - #2771
Conversation
|
Thanks @laudney, this is a careful piece. The image limits hold end to end: the request's count and token budget, the engine's span re-check, image rows charged per lane, and the tower's bytes counted before load. Text-only requests skip the image path entirely. Two small things:
|
|
Thanks, both are in:
|
|
Thanks @laudney, both are in. Two optional thoughts, neither blocking:
Ready from our side.
|
|
@laudney main landed dots changes of its own under this stack (
|
|
Thanks @laudney. The rebased serving increment keeps main's own-prompt and hash-only fixtures while declaring the tower through the shared dense engine. The chunk-cut check verifies the cuts were actually taken and compares KV rows, final logits, reply ids and one encode per image. The text runner covers startup with and without
|
|
Thanks @laudney. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.
|
c37e821 to
c66215b
Compare
The tower's tensors load as plain BF16 [n, k] matrices for cuBLASLt: fc1 and fc3 stacked into one gate|up projection, and the patch weight flattened to 588 columns and zero-padded to 592 so its rows meet the library's alignment. Every vision_tower tensor is consumed, the device bytes count the padding, and a failed load drains its uploads before any buffer is freed. -- 2.54.0 (Apple Git-157) -- 2.43.0
The drain test called settle directly, so dropping the errdefer in load, or registering it before the tower's own errdefer, would stay green. A host test now runs load on a sparse checkpoint against a fake device whose first upload's wait fails: the buffers must go only after the context proved the copies done. The sparse checkpoint helper moves to its own test file so the tower's tests can share it. -- 2.54.0 (Apple Git-157) -- 2.43.0
The dense engine's Tower contract gets its first real tower: dots.mocr's 42-block image tower, which turns merge-ordered patches into the decoder's rows at the rounding points of the HIP port and of Transformers. The tower reuses the shared vit GEMMs, attention, LayerNorm and linears, the engine's norms and SwiGLU, and the new vision rotary and patch bias launches. It holds one call's scratch at the processor's 57,600 patches and taps every stage for the oracle's comparison. Host tests pin the contract, the exact weight, scratch and open bytes against a sparse checkpoint, the rotary inv_freq fixture, the refusals' words (the budget's naming --vision-image-tokens, the flag the CLI accepts), the grid checks and the patch rows; the recipe declares the tower in its own change.
The tower needs device checks that the host suite cannot run, so tf-cuda-test gains two dots commands behind one dispatch line and a dots-help that prints their usage. dots-stages encodes one image with a tap that writes every stage's rows as BF16 .npy files for the oracle's stages mode. dots-image encodes a generated page (the processor fixture's pixel pattern, no file read) and an optional image twice each, requires equal bytes, prints the merged rows' hash and the time, and fails unless the page's hash equals its anchor, so a tower drift fails without the Python oracle. The runner imports the served dots module and its engine.
The vision-merged pin is a GB10 value, so another GPU's rows would read as a tower drift. dots-image still encodes twice and requires equal bytes everywhere, but on a device other than sm_121 it skips the pin comparison and names that device's SM.
Two trailing comments ran past 120 columns (the dots runner import in the CUDA build and a control line in the tower test); each now sits above its line. The tower test also takes the sparse checkpoint dir from the shared test helper instead of keeping its own copy.
The recipe now declares the tower, so the dense engine's tower variant serves dots.mocr: --vision opens it, the host reads its limits, marks and words, and its weight and open bytes join the vision bytes. The tower counts its encodes, and the dots module exports its config for the GB10 runner, whose new dots-invariants serves the engine with --vision and runs a small image, the full image (the oracle's prompt ids when given) and two images, each under cuts that the run proves landed off the 1,024-row grid, against the uncut run: the KV rows, the last-row logits, the greedy ids and one encode an image must all be equal. Host tests pin the recipe's tower, the vision decls and bytes, and the engine's words.
ashhart#2732's runner gains dots-text, so a decoder drift fails without the Python oracle: three chat-templated prompts of our own (18, 578 and 2,537 ids, committed as fixtures/own-prompts.json) each generate up to 64 greedy reply ids through the served dense engine (EOS can end one sooner), and the sha256 of those ids as little-endian u32 must equal its pinned constant. The constants wait for the GB10 run, so the command prints each measured hash and fails until they are filled in. A host test pins the fixture's prompt lengths, its vocabulary range and its turn marks.
The description claims the text path with and without --vision, but dots-text served the engine only with --vision. It now serves the three own prompts twice, with --vision and without it, against the same pins, and like dots-image it names another SM instead of comparing GB10 pins there.
The fixture's ids could not be regenerated from the tree. The fixtures README now names their source text, our own ownprompts.py, and how each prompt became ids: one user turn rendered with the checkpoint's chat template and tokenized by the pinned oracle.
|
Thank you @laudney. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
--vision)--vision: the tower, its 2×2 merger, image rows spliced into prompt chunks--no-drafts, concurrent = solo (8 lanes), repeat, seeded, cancel mid-image, chunk cuts through imagestf-cuda-test dots-text(3 prompts of our own, up to 64 greedy ids each)What this changes
#2673 serves dots.mocr's text decoder on the shared CUDA dense engine and refuses images. With this piece the recipe declares the tower (pieces b to d), so
--visionserves images.zig/src/families/dots_mocr/cuda_recipe.zig:pub const Tower. The engine's tower variant then gives the host dots.mocr's vision limits, marks, words and bytes (the tower's weight and open bytes join the vision bytes).zig/tests/cuda/dots_tests.zig):dots-invariants MODEL IMAGE [N] [IDS]: serves the engine with--visionand runs a small image, the full image (the oracle's prompt ids when given) and two images, each under cuts that the run proves landed off the 1,024-row grid, against the uncut run. The KV rows, the last-row logits, the greedy ids and one encode an image must all be equal.dots-text MODEL: three chat-templated prompts of our own (18, 578 and 2,537 ids,fixtures/own-prompts.json) each generate up to 64 greedy ids through the served engine; the sha256 of each reply's ids (u32, little-endian) must equal its pin. A decoder drift fails without the Python oracle.Serving the publisher's original BF16 weights is what makes these results comparable with other engines and lets every reply be checked against the model card's own Transformers model.
dots-studio/dots.mocris published under the dots.mocr License Agreement (Xingyin Information Technology (Shanghai) Co., Ltd., on MIT terms; the model card readslicense: mit). TensorFold redistributes no weights; serving reads the publisher's files.da27cc0fe). This PR's commits:ad77d3d59feat(dots): serve dots.mocr's image tower with --vision;e903ef5d1test(dots): pin dots.mocr's greedy text replies on the GB10;f8edb0c02test(cuda): dots-text pins its replies without --vision too;731f8a72edocs(dots): say how own-prompts.json was made. Piece 5 of 7.cd1cb0baainto main6b739dd5eis clean (git merge-tree).Checks on this head
731f8a72ezig build test-cuda-host,check-native-cuda-host7/7,test-kernel-contract,zig fmt --checkandgit diff --checkpass; lean 386 / 386, 0 new against piece d. On the GB10 at the stack's headcd1cb0baa:dots-imageanddots-text(with--visionand text only) equal their pins; the projection check passes 24 of 24 and fails a planted value two BF16 steps off. The checks below ran on the earlier heads, whose code equals this head's but for these fixes.python3 tools/zig/lean_check.py, on the base (cuda: a shared engine for dense decoders, with dots.mocr's text decoder on it #2673's head05e5e5fdd) and on this head: 386 / 386, 0 new (also 0 new against piece d).zig build test-cuda-host: 378/378 steps, 0 failed (the test binaries this piece changes re-ran; the others are the parent's and passed there).zig build test-cuda-dense-host: 33/33 passed, uncached.zig build test-dots-mocr-cuda-host: 24/24 passed, uncached.zig build check-native-cuda-host: 7/7 steps.zig build test-kernel-contract: 32/32 steps, 0 failed.zig build compile-cuda-tests(the GB10 runner compiles): 10/10 steps.zig fmt --check build.zig zig,git diff --check: pass.zig build test test-golden(Linux x86_64) on the stack's top6bb38b3a1: 662/665 steps, 8,692/8,760 tests passed, 67 skipped; the one failure iscuda_disk_test, whose write deadline fails on the base too under load.Receipt
05e5e5fdd, whose tree equals these heads except one moved comment; NVIDIA GB10 (sm_121), nvcc 13.4, Zig 0.17.0, 128 GB unified memory. Checkpointdots-studio/dots.mocr@e539fbb52280393adc081b289ec597430a0f9031. HF: the pinned oracle on the same GB10, Torch 2.14.1+cu130, Transformers 4.57.6, Pillow 12.2.0, qwen-vl-utils 0.0.10, the tower on SDPA.--visionon the dense engine, drafted and--no-drafts, 1 to 8 lanes; the text path with and without--vision. GB10 (sm_121) only; not run: sm_80, sm_86, sm_89 and sm_120 devices.Gate 1: HF agreement with images (greedy)
receipt.png(eb0216df…, grid 92×52) andinvoice.png(64e479ee…, grid 126×88)The two pages are ours: a deterministic Pillow script draws them with text we wrote, Pillow's bundled default font and a fixed seed (2732), and saves them as PNG. The receipt is 720×1280 (a shop name, eight item lines with prices, the subtotal, the tax and the total); the invoice is 1240×1754 (a header block, a five-row table of hours, rates and amounts, the subtotal, VAT and the total due).
The page generator (
make_pages.py)python3 -I make_pages.py OUT_DIRprints each page's path and sha256. Pillow changes the glyphs between versions, so the hashes above are from Pillow 12.2.0, the oracle's pin.Gate 2: invariants with images (reply-id sha256, 8 lanes)
725385cf--parallel 8) against--no-drafts3fe6ad3bboth times725385cf, as the uncut requestdots-invariants): a small image cut at its first row, inside it, at its last row and at all three; the full image cut inside off the 1,024-row grid; two images with the grid line through the first and one more cut in eachGate 3: text and served checkpoints unchanged
tf-cuda-test dots-text: PASS, served with--visionand text only (two serves). Under both, the three own prompts' replies (up to 64 greedy ids each) hash to the pins4136394a…,37b4105c…anded7e831a….33ada77c3against the stack's head, two runs each:2b28aa21aafe5ed4,a06fab34d9498b28Gate 4: named refusals
--visionthis server accepts text parts only; image, audio and video inputs are unsupportedcontent parts must be text or image_url; audio and video inputs are unsupportedimage 1 is not PNG, JPEG or WebP; send one of thoseDenseImageSpan,DotsImageBudgetnaming--vision-image-tokens, the planner's per-lane bytes); on the GB10,--parallel 64at a 131,072-token context fits--visionand--vision-image-tokensare the host's existing flags.Checklist
"draft": false, and concurrent equals solo. A resumed prompt equals a fresh one: n/a, the engine keeps no prompt states.--drafter, no slower than without it, greedy and sampled:--drafteris refused for dots.mocr; Qwen3.8-27B above.