Repository navigation
Conversation
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 -- 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 -- 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. -- 2.43.0
#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. -- 2.43.0
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. -- 2.43.0
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. -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
The GB10 has no flash-attn, so oracle, score and text install a stand-in for the tower's import, put the tower on SDPA and refuse a block that is not VisionSdpaAttention; oracle and score record the SDPA backend Torch picks, score teacher-forces image prompts with the reference's pixel_values and image_grid_thw, oracle saves BF16 tower taps (with the patch embed before its norm), the tower rotary inv_freq fixture text and cos/sin, and decides once or twice rounding of the patch bias, and a stages mode compares native taps by max abs and BF16-ulp histogram; image references now require pillow 12.2.0 and qwen-vl-utils 0.0.10, because Pillow 13.0.0 changes the demo pixels from the fixture's hash. The image modes (oracle, stages and score's pixels) move to dots_mocr_images.py, which the reference script loads by its path, so python -I runs it from any directory, and each file keeps room under the 600-line limit.
Gate 2 asks each changed reduction order to be no worse than Torch's BF16 matmul against FP64 on the same device inputs, so the dense pass and the dots tower gain an optional tap on each projection's input and output rows. Served passes leave the tap null. The new dots-projections runner command encodes one image and prefills the image prompt's first chunk with the taps set. It writes every input row, sampled output rows and each fused class's separate GEMMs for the tower's patch, blocks 0, 20 and 41 and merger, and for the decoder's first and last layers and head. tools/zig/ dots_projection_check.py computes FP64 products and Torch's layers as Transformers calls them, and fails a class past one BF16 step plus the FP32 sum's error, worse than Torch's worst column, or with a fused part off its own GEMM; a missing class also fails.
The oracle put the tower on SDPA on every GPU, so HIP image references made with flash-attn would differ in the tower from the ones behind the HIP numbers. The tower now follows --attention when flash-attn is installed and falls back to SDPA only without it, and only an SDPA tower refuses blocks that are not VisionSdpaAttention. oracle and score gain --sdpa-backend auto|math: math turns flash, memory-efficient and cuDNN SDPA off, as the math-backend reference needs, and both record the choice in their output.
A trailing comment ran past 120 columns; it now sits above its line.
The oracle's help and the image module's docstring still promised an SDPA tower, though the tower now follows --attention when flash-attn is installed; both now say so, with SDPA as the fallback.
The CUDA page now serves images with --vision: the per-request image budget, the largest image, the per-lane rows that lower the admitted lanes, the JPEG library, and the oracle's SDPA image references, the tower stage comparison and its Pillow pin, and the runner's anchored dots-image and dots-text checks; the README, the recipes index and the HIP page point to it, and the changelog credits the change under Unreleased.
The fixtures README still described the oracle as HIP-only with the flash command. It now says that the tower and the decoder follow --attention, that without flash-attn the tower falls back to SDPA and the decoder needs --attention sdpa, that --sdpa-backend math keeps SDPA on its math kernel, and that image references pin Pillow 12.2.0; it gives the HIP and the CUDA commands, and the CUDA page names the math-backend switch.
…-out on two fused tiles Off by default. With TF_FLASHNEXT_READOUT_FUSED=1, a CUDA prompt pass of 768 rows or more runs the BF16 hyper-connection read-out in three launches instead of five. The down projection forms the normed rows in shared memory (flashnext_hcn.cu, fn_hcn_down2/3/4), reduce_act is unchanged, and the up projection forms them again in its epilogue and mixes the four streams there (fn_hcn_up3). The writeback before such a read-out skips its normalize. Both kernels keep the chain's mma order, K-slice fold and rounding points, so every output byte equals the five launches'. tf-cuda-test flashnext-readout-fused compares them at 64 to 3,072 rows over every down tile and times both paths. Metal, HIP and a CUDA checkpoint whose read-out is MLX affine stop the start by name with the setting on.
fn_hcn_down2, fn_hcn_down3, fn_hcn_down4 and fn_hcn_up3 register as replacements: every output byte must equal fn_hc_normalize followed by the qmmf lane's fp32 down, or the qmmf lane's bf16 up followed by fn_hc_dense_mix, at six served row counts from 768 to 3,072 and on planted non-finite rows. Two planted controls must fail gate 3: fn_hcn_down3 rounding its normed rows toward zero, and fn_hcn_up3 gating its up rows before their bf16 rounding. The kernel bodies move to flashnext_hcn.cuh so the controls build from them; the engine's instances keep both control flags off. The four launches join the records whose compiler usage is pending, so device limits still check them. test-flashnext-readout-fused-host runs the down tile choice and the refusals by name without a GPU, and the CHANGELOG line carries the issue number's placeholder.
…t under 1.2.9 -- 2.43.0
….zig and cuda_prompt_wt.zig at this change
…nches resolve their image
….3 on sm_80 to sm_121
…e SMs, and the disk key reads the setting The tile kernels take the SM count at load, where the lane had it only with TF_FLASHNEXT_PROMPT_BF16 on; any tile gives the same bytes. TF_FLASHNEXT_READOUT_FUSED joins the kept-state key as bit 1 of the hc_fuse slot, so with it unset the key is unchanged. The device comparisons now run the five launches on the engine's lane, with qmmf's BF16 prompt tiles loaded, and check that lane against the plain one.
…ver 19 cells, docs and changelog numbers
safetensors.File.release asks Linux for the pages of a range it has finished with (madvise MADV_DONTNEED) and drops the file's page-cache pages. Windows has neither: the pages of a checkpoint a load has uploaded stay in the process's working set, and on a unified-memory host, where the device's memory is the system's, they crowd the allocations that come next out of the budget. The trim is the process's whole set, so it is taken once a step rather than once a shard: core's Checkpoint.release and releaseExcept, and the qwen3_5 loader's per-layer release. The pages go to the standby list, where a later read faults them back softly, so a trim that is too eager costs a refault and never a byte. platform/working_set.zig is the call, next to the other Win32 declarations, behind the sys module every module already imports; it is a no-op elsewhere, where the per-range advice already covers this.
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.
CI for a landing train: #2773 #3395 #3413 #3866 stacked on main in that order. Nothing merges from this PR: each PR above lands on its own once this tip is green, and this PR is then closed.