Skip to content

Qwen3.5/3.8 and Flash Next on CUDA: --vision reads a quantized ModelOpt tower - #3727

Merged
ashhart merged 4 commits into
ashhart:mainfrom
BadAd84:flashnext-vision-modelopt-up
Nov 20, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
BadAd84:flashnext-vision-modelopt-up

Conversation

@BadAd84

@BadAd84 BadAd84 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Terms used below: "main" is upstream TensorFold at 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7 (its tip of 2026-11-16T15:26:10Z), and "the measured head" is 391c6bf1f9592703c19c18878ad251532ad7cf24, that main plus the change and the receipt, the commit the checks and the receipt below name as measured. The pull request's head is d8608573a7366dc88cc79f21ca73e0363e5dea6f ("the head"): the maintainer rebased the change and the receipt onto upstream main at 8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8 (as d46832d6631650b2c969fa6f03e7e9bed9a398ad and c6cf7a965a55cbe206e50166602fe74b788891c7), and two commits of ours follow: 8826ad672793c0fb6f8ab5d115cbd46822c0dc20, which answers the review (the receipt README no longer claims a floating-point tower leg, since both images refused that checkpoint before loading, and it maps the head to the measured revision), and d8608573a7366dc88cc79f21ca73e0363e5dea6f, the Unreleased bullet naming this pull request. Where a check below says "this head", it means the measured head unless the bullet names the head.

What this changes

The CUDA vision tower's reader takes every linear's weight as stored bf16, so --vision on a checkpoint whose tower ModelOpt quantizes stops at the first quantised linear and names it. With this change a linear stored as MXFP8 (e4m3 codes, an e8m0 power of two every 32 inputs) or NVFP4 (e2m1 codes two to a byte, an e4m3 scale every 16 inputs, one fp32 scale a row) is decoded on the host to bf16 while the tower loads, and the tower runs in bf16 exactly as it did: same kernels, same launches, same scratch, and the same bytes on the device, because the tower's arena is sized for bf16 weights either way.

  • Issue: n/a. This reads one more stored form of weights the family already serves, behind the existing --vision flag, and adds no arithmetic to the served path (the tower runs in bf16 as before); the gate it proposes is the one below: every decoded tensor compared byte for byte with a binary64 reference on the host, and the device load, replies and contracts on the checkpoint itself.
  • Stacked on: upstream main at 8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8. The branch is the maintainer's rebase of the change (d46832d66, which was ac2070000) and of the receipt (c6cf7a965, which was 391c6bf1f, three files, no code), then 8826ad672 and d8608573a as named above. The change's five source files are the same blobs at d46832d66 as at ac2070000, and zig/src/vision is the same on both mains, so every device cell below was measured on the code this head carries; only the documentation around the change moved (docs/vision.md).
  • atc overlap --json: run last, on the head d8608573a7366dc88cc79f21ca73e0363e5dea6f with up/main at e63f26f0e6ae75f76fc2617c1f841af7adbde6e2, 00:12 to 00:13 UTC: incomplete (complete: false, with its own four limits, otherPullRequestsLimit, pullFilesUnavailable, pullRequestsLimit and timeLimit), 10 changed files and 30 overlap rows, of which 20 are working-tree rows (6 clean, 3 conflicts, 11 unknown) and 10 are the fork's trunk (PR 2044) listed against other pull requests, all unknown. The three conflicts entries are dsv41 metal: image prompts #1722, DeepSeek-V4.1: read the pack's weight spans past the page cache (core/direct_io) #1924 and Nemotron 3.5 Transcribe: audio input, the 65,536-token window, an hour of audio, MTP drafts #1632, and the only file each shares with this change is CHANGELOG.md (checked against the files of each): the ordinary case of pull requests inserting their Unreleased bullets in the same place.

How the reader decides, and why it lives in the tower's reader:

  • zig/src/vision/qwen_cuda_weights.zig's Reader.linear reads the weight once to see its stored dtype. bf16 (and any other dtype) takes the unchanged Reader.get path, byte for byte; e4m3 is MXFP8 and u8 is NVFP4. So a checkpoint that loads today loads to the same bytes, and the seven pre-existing tests in qwen_cuda_weights_test.zig (byte identity, refusals, ownership, allocation balance) still pass against the new routing.
  • A quantised linear is checked before it is decoded: its name ends .weight, its width is a whole number of the format's scale groups, its stored plane is the shape the tower's config says, its scale tensor is e4m3 [n, k / 16] for NVFP4 or u8/e8m0 [n, k / 32] for MXFP8, and its weight_scale_2 is one fp32. Anything else stops the load naming the tensor ({name}: not a ModelOpt {kind} vision linear of the tower's shape), and an extra tensor the reader does not take still fails the existing unused-tensor check. The test runner's diagnostics check counts every error line and fails on one it does not recognise, so the refusal's own log line is covered by the refusal tests rather than only added. A W4A4 static input_scale beside a linear is read and marked used, because the tower runs bf16 and never applies it.
  • The decode is the checkpoint format's own: core/modelopt.zig's recipe comments define the two (NVFP4: FP4 weights, an e4m3 scale every 16 inputs, a global scale; MXFP8: e4m3 weights, a UE8M0 scale every 32 inputs), and core/quant/nvfp4.zig documents the stored layout (weight u8 [..., N, K / 2] even columns low, scale e4m3 [..., N, K / 16], global). zig/src/vision/qwen_cuda_dequant.zig computes each element as the product of exactly representable factors in fp32 and rounds to bf16 once, nearest even, which is the same bits as casting the format's exact value to fp32 and then to bf16, and the tests prove it against binary64 references rather than asserting it.
  • The shared ModelOpt part reader (core/modelopt_part.zig) is not reused: it covers NVFP4, per-tensor FP8 and bf16, its scale is one fp32 and its Kind has no MXFP8 arm, and it returns views for a family's own device upload while the tower needs bf16 rows into its arena. The tower's reader handles both recipes with one code path and one refusal.
  • Memory: the decode holds one linear on the host at a time (2 * n * k bytes, the merger's first projection at n = k = 4 x hidden being the largest) and frees it once the upload holds its own copy, so a failed load leaves nothing behind; the allocation-failure test walks every allocation index and requires the balance to return to zero. On the device nothing changes: Tower.weightBytes counts two bytes an element for every weight, which is what the sink is handed.
  • --vision is the only trigger. Options.vision (zig/src/families/flashnext/cuda_lanes.zig) defaults to null and is set only from the serve flag (zig/src/native/cuda_options.zig: if (o.vision) |vo| opts.vision = ...), zig/src/families/flashnext/cuda_lanes_load.zig loads the tower only inside if (o.vision) |limits|, and weights.load is called from nowhere else. A text-only serve reaches none of this code.
  • No setting is added, so there is no row in zig/src/platform/environment.zig and none in docs/environment.md, and the change reads no getenv. No .cu or .cuh is edited, so the kernel contract does not apply. No serving source is re-pinned: the only zig/src/vision-side entry in zig/tests/fixtures/gradient-serving.tsv is the kernel zig/kernels/cuda/qwen_vision.cu, which this change does not edit, and test-gradient-serving passes on this head.

Checks on this head

  • Head commit: 391c6bf1f9592703c19c18878ad251532ad7cf24, the receipt commit on the change commit ac207000030b969a259143ac32bf2eac6b5e29e7 (which, against main 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7, changes 7 files, 448 insertions and 6 deletions; the head's whole diff is 10 files, 553 insertions and 6 deletions), both author and committer BadAd84 <BadAd84@users.noreply.github.com>, signed. Every check below ran on ac2070000, whose code the head carries unchanged; git diff --check 077998f7d..391c6bf1f is clean.
  • Lean checker, python3 tools/zig/lean_check.py, one tree at a time from its own root, with the head's checker in both (byte-identical, cmp rc 0): base 077998f7d9b1 6,575 files, 221 problems; this head 6,577 files, 221 problems; lean_new.py: lean: 221 problems, 221 on the base, 0 new. The 221 are inherited (for example zig/src/server/tool_grammar.zig:79).
  • python3 tools/pr_check.py --base 077998f7d9b1 on this head: merge base 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7; 7 changed files; lean 221 vs 221, 0 new, and on the head with the receipt commit 10 changed files; lean 221 vs 221, 0 new; 0 errors, 1 warning, the advisory --pr one (this branch has no pull request number yet; the Unreleased bullet carries none and the number is added with the pull request).
  • zig fmt --check build.zig zig: clean, rc 0 with no output, locally and on the head tree on the test machine. git diff --check 077998f7d9b1..HEAD: clean.
  • Tests run, as the no-GPU workflow runs them, natively on an aarch64 Ubuntu 24.04.5 machine (NVIDIA GB10, 20 CPUs, Zig 0.17.0, -j8 --maxrss 6000000000 except -j4 where noted, umask 022, no GPU visible to the tests), on a fresh git archive tree of this head and, separately, of main, each checked blob by blob against its commit (11,834 and 11,832 entries: 0 missing, 0 extra, 0 different): zig build -Dfixed-cpu test-gradient-serving test-qwen-serving-host rc 0 (7 of 7 steps, 3 of 3 tests); zig build compile-config-server -Dtarget=aarch64-linux-gnu rc 0 (7 of 7 steps); zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu rc 0 (10 of 10 steps); zig build -Dfixed-cpu test-qwen-vision-weights-host test-environment-host rc 0 (6 of 6 steps, 25 of 25 tests, of which the vision step's own runner reports 17 passed; 0 skipped; 0 failed.), and the same vision step in the base tree rc 0 with 7 passed; 0 skipped; 0 failed., so the module this change touches passes on both sides and the ten new tests are all on the head's side of that count. zig build -Dfixed-cpu test-host --test-timeout 20m at -j4: this head rc 1, 2125/2132 steps succeeded (1 failed); 22118/22261 tests passed (142 skipped, 1 failed), the failure being listener.test.accepted IPv4 and IPv6 TCP streams disable Nagle for incremental responses in test-cuda-host (1489 pass, 8 skip, 1 fail of 1498 there), which is the test machine's own limit, not this change's: the test opens and connects an IPv6 loopback listener, and that machine boots with ipv6.disable=1. The same command on main at 077998f7d9b1 returned rc 1 as well: 2125/2132 steps succeeded (1 failed); 11844/11933 tests passed (88 skipped, 1 failed), the same single failing test (1489 pass, 8 skip, 1 fail of 1498 there; that run's executed totals are lower because it reused test steps an earlier attempt on the same tree had already passed). The failing sets compared name for name are equal: 1 in both, 0 only on either side.
  • New tests: 10, four in the new qwen_cuda_dequant.zig and six in the new qwen_cuda_weights_quant_test.zig, which qwen_cuda_weights_test.zig reaches by a comptime import block, so the step zig/build/qwen_vision_weights_host.zig compiles and the filter Qwen tower weights: runs them. Each one is shown failing on the inverse of its behaviour: each mutant is applied to its own fresh copy of this head's tree, its anchors checked to occur exactly once on this head first, and the same command run (zig build -Dfixed-cpu test-qwen-vision-weights-host -j4), against a control that is the same tree unmutated (17 passed, 0 failed). All 12 mutants fail:
Mutant What fails
the reader as it stands at main (every linear through Reader.get) the five reader tests: the ModelOpt tower, the e8m0 and activation scales, the refusal cases, bf16 beside quantized, and copy and allocation failures (12 passed, 5 failed)
a stored bf16 linear takes the MXFP8 path a tower of floating-point linears reaches the sink as stored, a linear stored as bf16 beside quantized ones is read as stored, and six pre-existing dense tests (9 passed, 8 failed)
the e4m3 normal's exponent bias off by one every e4m3 and e8m0 byte, NVFP4 hand-decoded, MXFP8 hand-decoded, the ModelOpt tower, the e8m0 and activation scales, bf16 beside quantized (11 passed, 6 failed)
an e4m3 NaN code decodes as 0 every e4m3 and e8m0 byte, NVFP4 NaN scales stay NaN and a zero scale zeroes its group (15 passed, 2 failed)
the e8m0 power's bias off by one every e4m3 and e8m0 byte, MXFP8 hand-decoded, the ModelOpt tower, the e8m0 and activation scales, bf16 beside quantized (12 passed, 5 failed)
the e2m1 nibble order swapped NVFP4 hand-decoded, the ModelOpt tower, the e8m0 and activation scales, bf16 beside quantized (13 passed, 4 failed)
the row's global scale doubled the same four tests (13 passed, 4 failed)
the per-32 e8m0 scale read by row MXFP8 hand-decoded, the ModelOpt tower, the e8m0 and activation scales, bf16 beside quantized (13 passed, 4 failed)
the activation scale read but not marked used e8m0 scale dtype and the activation scales are accepted (16 passed, 1 failed)
the MXFP8 scale accepted only as u8 e8m0 scale dtype and the activation scales are accepted (16 passed, 1 failed)
the MXFP8 scale's shape unchecked a quantized linear missing or mismatching its planes fails closed (15 passed, 2 failed)
the decoded rows not freed after the sink's copy every test that decodes a linear, traced to the allocation the change adds (11 passed, 6 failed)

Measured on this head: each mutant runs in its own cp -a of the verified tree, the lane's global Zig cache shared across the runs, and the control is the same tree unmutated (17 passed, 0 skipped, 0 failed). Two rows need their numbers read with care: where a test unexpectedly succeeds, expectError drops the fixture's Sink, so its copies leak and the leak reports are counted by the next test's diagnostics check (the 22-block line under the unchecked-scale mutant, and the "expected 0, found N" texts under the not-freed one). Both are the mutant's own failure and test-side accounting, not a defect of the reader.

  • Checks on the current head, after the maintainer's rebase and the review round (the bullets around this one are the measured head's own): python3 tools/pr_check.py --base 8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8 --pr 3727: merge base 8cbef9777b9a05dfaff99d5aa9c2ce52fe2b00f8; 10 changed files; lean 221 vs 221, 0 new, 0 error(s), 0 warning(s). On a clean x86_64 Linux machine (16 threads, Zig 0.17.0, umask 022, no GPU), on a fresh git archive tree of the head before its changelog commit: zig fmt --check build.zig zig rc 0; -Dfixed-cpu test-environment-host rc 0, 3/3 steps, 26/26 tests; -Dfixed-cpu test-gradient-serving test-qwen-serving-host rc 0, 7/7 steps, 3/3 tests; compile-config-server -Dtarget=aarch64-linux-gnu rc 0, 7/7 steps; compile-cuda-tests -Dtarget=aarch64-linux-gnu rc 0, 10/10 steps; -Dfixed-cpu test-qwen-vision-weights-host rc 0, 3/3 steps.
  • CI on d8608573a7366dc88cc79f21ca73e0363e5dea6f (the head), run on this pull request: fmt, zig, zig-b, zig-windows, pytest, benchmark-clients (ubuntu and windows), release-paths and zig-macos-dev-tools all completed successfully; host-nightly-linux and host-nightly-macos are skipped by their own conditions.
  • Not run, and why: the two-rank path (this change is in the tower's host reader, which rank 0 alone runs, and no second GPU was used), and the widest admitted stream count for the default-path cells (the window measured one and four streams). The GPU receipt is in the section below.

Receipt

  • Arms and cells (docs/receipts/flashnext-vision-modelopt/README.md, with cells.csv and exactness.md): 7 boots on one NVIDIA GB10 (sm_121) machine, one fresh server each, through the serving recipe with CHECKPOINT=nvfp4, KV_DTYPE=bf16, --parallel 8 --context 32768, --vision only where the leg is vision. Four text boots, main and this head ABBA, measure the default path; one boot of main with --vision records the load's refusal; two boots of this head with --vision record the load, the image replies and the three exactness contracts, the second without a prompt cache; the floating-point leg was not run in this window.
  • Main against branch, the default path, two runs an arm, temperature 0, the eight golden prompts as bench_concurrent.py --prompts (request i sends item i):
streams main (two runs) branch (two runs) branch vs main verdict
1 155.7 and 152.9 152.1 and 153.1 -1.1% level
4 65.5 and 64.3 64.4 and 64.3 -0.8% level

End-to-end tokens a second; the per-request decode rate and every alone check are in the receipt's cells.csv. The greedy hashes: 8 of 8 prompts carry the same token ids on all four boots. The cells cannot move for the code reason below, and their verdicts are the noise rule's.

  • Main against branch, --vision on the FP4 checkpoint: main's boot stops at the first quantised tower linear and names it, model.visual.blocks.0.attn.qkv.weight: f8_e4m3 { 3456, 1152 }, expected bf16 { 3456, 1152 }; this head's boot serves it and answers one image request with A close-up portrait captures a tabby cat with striking green eyes, gazing intently at the viewer against a softly blurred background. (147 prompt tokens, 28 completion tokens, 1.141 s). The reply is the same on a second request in the same boot, with "draft": false, on two streamed requests, and on a second boot with --prompt-cache-gib 0: twice in one boot (equal by token_sha256), with "draft": false (equal by token_sha256), twice streamed (equal by token_sha256), streamed again (equal by token_sha256) and on the second boot (equal by token_sha256).
  • The tower's memory, as the server's own startup line reports it, same image and settings with the flag off and on: CUDA sm_121 device 0 (NVIDIA GB10, memory shared with the host): model 72.71 GiB; 8 streams at once, 1.29 GiB each at a 32768-token window, of 27.9 GiB left after a 9.0 GiB reserve; prompts in passes of up to 1536 rows, a 16.0 GiB prompt cache; own glue kernels and CUDA sm_121 device 0 (NVIDIA GB10, memory shared with the host): model 74.23 GiB; 8 streams at once, 1.31 GiB each at a 32768-token window, of 26.2 GiB left after a 9.0 GiB reserve; prompts in passes of up to 1536 rows, a 15.7 GiB prompt cache; own glue kernels.
  • Exactness on the branch with --vision on, from tools/bench_concurrent.py --alone --serial and token_sha against "draft": false: drafted equals "draft": false on 8 of 8 text prompts; concurrent equals solo in 52 comparisons (0 unequal, 0 failed) at levels 1, 2 and 4 and temperatures 0 and 1.0; resumed equals fresh on 7 turns, every resumed reply equal to its fresh twin by token_ids with 0 problems and the resumed requests' cached counts [13, 16, 16, 13, 24, 18, 3406]. The same two contracts hold on the default path too (32 of 32 prompts drafted against "draft": false, every concurrent reply equal to its solo run).
  • The floating-point tower, both images, CHECKPOINT=int4, --vision: both images were refused before any weight was read, error: flashnext: config.json's quantization_config.quant_method differs from the supported Flash Next CUDA layout, so this leg has no result on this engine and is not claimed. That checkpoint is not the same language model as the FP4 one, so an equality there would have shown the unchanged reader path serving beside the quantised one rather than being compared with the FP4 reply.
  • Boxes it reaches: Flash Next on CUDA with --vision (rank 0 holds the tower), and the shared Qwen-VL CUDA tower Qwen3.5/3.8 uses. Metal and the Python engine are untouched; MLX already reads per-module quantized tower weights.
  • New switch? None. The default is the behaviour: a floating-point tower is read as stored; a ModelOpt MXFP8 or NVFP4 linear is decoded at load. No profile row, because there is nothing to set.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: the host checks above ran on the aarch64 Ubuntu 24.04.5 machine, Zig 0.17.0, CPU only, on ac2070000 and 077998f7d9b1. The device checks ran on one NVIDIA GB10 (sm_121), driver 580.178.04, kernel 7.0.0-1019-nvidia-64k, aarch64, on images built from git archive trees of both commits (blob by blob against their own git ls-tree manifests), nvcr.io/nvidia/pytorch:26.07-py3, nvcc 13.3 (V13.3.73), Zig 0.17.0, zig build -Dnvcc=/usr/local/cuda/bin/nvcc -Doptimize=fast fatbins install native. Checkpoint nvidia/Qwen3.8-Flash-Next-FP4-Local at b9ce18a6887e18c089fdea8509a33e63429a3300, and for the floating-point leg azampatti/Qwen3.8-Flash-Next-125B-A5B-INT4-AutoRound at 1464274120d36a4d8fcaa934552334a7d83ce0fd.
  • Paths and platforms the change reaches, which I ran and which I could not: the tower's reader is exercised end to end on the host, through the real safetensors reader, for both recipes, for a floating-point tower and for every refusal (test-qwen-vision-weights-host and test-environment-host pass, and test-host runs the vision tests inside its aggregate too); on the device, the load, the image replies and the three exactness contracts above, on the FP4 checkpoint; the floating-point checkpoint was refused by this engine before any weight was read, as recorded above. Not run: Metal, HIP, Windows, and the two-rank path (rank 0 alone runs the tower reader, and no second GPU was used).
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: the device pairs above are a load, sanity and determinism check, and the reason is the checkpoint's own: its snapshot stores the tower quantised, so there is no floating-point twin of this checkpoint's tower to compare replies with. Exactness itself is proven on the host, and this is the strongest evidence in the change: every tensor the reader hands the sink is compared byte for byte against a binary64 reference (core.quant.nvfp4.reference, and e4m3 times 2^(e8m0 - 127) in f64 for MXFP8), for the real reader driven through a written safetensors fixture, and a floating-point tower's bytes are compared against the stored bytes. The decode is exact by construction as well: an e2m1 code times an e4m3 scale is exact in fp32, the multiply by the row's fp32 global rounds once to fp32, and the bf16 rounding follows, which is the same bits as casting the format's exact value to fp32 and then to bf16; an MXFP8 code times a power of two is exact in fp32 with no rounding at all.
  • Decode speed before and after, from tools/bench_openai.py: the two cells above, and neither moves beyond the noise rule. The code is unreachable without --vision (Options.vision defaults to null and only the serve flag sets it), and with it the decode runs once at load on the host, before the first request: the default path executes the same code on the same bytes.
  • Prompt speed before and after: no prompt cell was taken, for the same reason: no prompt path, no kernel, no KV and no scratch size changes, and the tower's device bytes are the bf16 tower's either way (Tower.weightBytes counts two bytes an element). The end-to-end cells at one and four streams above carry the default path's figures.
  • Posted before asking for a run on upstream's machines: the window above is that receipt, run on our own GB10 with both images and the checkpoint revision named, and it states what it does not establish rather than what it cannot check.
  • Licence of any new weights or drafter, or "n/a": n/a. No weight, checkpoint or drafter is added; the decode reads the checkpoint the user already has.

Checklist

  • The title and description match the head commit, including the stack and the checks; the receipt names what a window would and would not show.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency (no device, no CUDA library: the step is a host test).
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds: this change is in the tower's weight reader at load and touches no scheduling, drafting or token path.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo: run on the device with --vision on against the FP4 checkpoint's tower, with the counts in the Receipt section above (and on the default path too).
  • No precision traded for speed. Nothing in the decode is approximate: a quantised tower has no previous behaviour to differ from, a floating-point tower's bytes are unchanged, and the tests compare both against binary64 references.
  • Decode and prompt processing are no slower than main at one stream and four streams: both default-path cells are level by the noise rule, and the code reason on the decode and prompt lines above says why no cell at any width can differ. The widest admitted width was not itself measured in this window.

BadAd84 added a commit to BadAd84/TensorFold that referenced this pull request Nov 17, 2026
@ashhart
ashhart force-pushed the flashnext-vision-modelopt-up branch 2 times, most recently from 86e139a to c6cf7a9 Compare November 18, 2026 13:10
@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84. The decoder and byte-level fixtures look sound. Please correct README.md:12 and :50: they claim floating-point serving/equality, while exactness.md says both configurations were refused before loading. Also map the current head to the measured ac20700 revision and update the check status. Unchanged runtime sources can be documented without assuming another GPU run.

  • Synthena

BadAd84 added a commit to BadAd84/TensorFold that referenced this pull request Nov 19, 2026
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thank you @BadAd84. The two README lines now match exactness.md. Nothing is left for you here.

  • Synthena

@ashhart
ashhart force-pushed the flashnext-vision-modelopt-up branch from d860857 to d86ea98 Compare November 20, 2026 08:18
@AIFlowML

Copy link
Copy Markdown
Contributor

On M5 Max with Zig 0.17.0, d86ea980 trial-merged cleanly into d26d5b06b. The initial trial merge into 124052c97 passed all 17 fixtures with zig build test-qwen-vision-weights-host -Dcpu=apple_m1 -j5 --summary all.

I also checked the MXFP8 multiply and rounding independently in scratch: all 254 non-NaN E4M3 codes crossed with all 255 finite E8M0 scales. A Python oracle used binary64 powers of two and ties-to-even BF16 rounding, including signed zero, subnormal outputs and overflow. All 64,770 BF16 bit patterns matched. The updated trial merge with the extra fixture also passed test-vision-cli-host and test-flashnext-vision-memory-host (60 tests total across the three targets). These were CPU checks of the loader and surrounding setup.

Igor Lessio - AIFLOW LABS

BadAd84 and others added 4 commits November 20, 2026 20:39
A checkpoint whose vision tower ModelOpt quantizes, as nvidia/Qwen3.8-Flash-Next-FP4-Local
stores attention as MXFP8 and the MLP and merger as NVFP4, was refused by the CUDA tower's
reader, which expects bf16 for every tensor. The tower's linears now decode on the host as
they load: an e4m3 code times the e8m0 power of two of its 32 inputs for MXFP8, and an e2m1
code times the e4m3 scale of its 16 inputs times the tensor's global scale for NVFP4, each a
product of exactly representable factors in fp32 and rounded to bf16 once, nearest even, so
a row is the stored value read as the format defines it rather than an approximation of it.

The tower still runs in bf16: its kernels, launches, scratch and rows are the ones a
floating-point tower gets, and its device bytes are the same, because the arena is sized for
bf16 weights either way. The decode holds one linear in host memory at a time and frees it
once the upload holds its own copy, so a failed load leaves nothing behind.

A floating-point tower is read as stored, byte for byte, so a checkpoint that loads today
loads to the same bytes; only a tower whose linear's dtype is e4m3 or u8 takes the new path,
and a stored plane, scale or global scale of another shape, a width that is not a whole
number of scale groups, and an extra tensor the reader does not take all stop the load
naming the tensor. Nothing of the tower loads without --vision, so text serving is untouched.

docs/vision.md says which towers CUDA reads now, and CHANGELOG names the change under
Unreleased.
…longer claims a floating-point tower leg

The floating-point tower leg was refused before any weight was read on both images, so the receipt says it has no result.
The current head is mapped to the measured revision by its source files, which are byte equal.
@ashhart
ashhart force-pushed the flashnext-vision-modelopt-up branch from d86ea98 to 9441f3b Compare November 20, 2026 20:39
@ashhart
ashhart merged commit e0ebc7b into ashhart:main Nov 20, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thank you @BadAd84. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants