Repository navigation
Conversation
…t checkpoints Lane matmul mode FP8G: e4m3 bytes in the FP8 GEMM's fragment order and one fp32 scale per (64 inputs, column), applied after each 64-input stage's bf16 MMAs, so the stored weight is exact and rows stay independent of the row count. Fp8BlockLinear decodes on it and runs prompts on the FP8 prompt GEMM with the scales as bf16 group scales. The Flash Next loader maps weight_scale_inv linears to it, runs stacks that mix block FP8 with bf16 through Concat, and dequantizes a block-FP8 lm_head (and the draft head's rows) with its block scales. format.scheme and format.dequant learn the layout; the family's check accepts FP8_PB_WO. Tests: the linear against an fp64 reference, rows, prompt chunks and Concat; the numpy dequantizer; a tiny ModelOpt checkpoint with block-FP8 linears through the loader, the engine and drafted-equals-serial decoding. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ashhart
added a commit
that referenced
this pull request
Sep 30, 2026
…t resends resume (#124), streamed tool calls (#114) - CUDA prompts take bf16 activations by default; --prefill-fp8 restores FP8 prompts; both ranks agree on the precision; block-scaled FP8 checkpoints load (#126) - Flash Next keeps each prompt's state one token early, so identical resends and next thinking turns resume (#124) - Tool-call arguments stream as they are written on the CUDA server (#114) - Before M5, Flash Next hyper-connection projections of 8+ rows run in 8-row tiles with the per-row bits - --checkpoint-slots on CUDA (#125)
Owner
|
The FP8G lane-matmul mode is exactly what we want on decode: the stored e4m3 bytes, one fp32 scale per 64 inputs and column, fp32 sums, row-invariant by shape. On a GB10 it matches or beats the FP8 GEMM at 1-16 decode rows, out_proj 38-42 against 71 us, with about a tenth of its error against fp64, 0.002 against 0.026. Two changes of ours: the block-FP8 lm_head stays on FP8G with its stored bytes instead of a bf16 copy, 0.68 GB read a forward instead of 1.27, and since 0.6.0 prompts take bf16 activations by default, block-FP8 prompts run FP8G too, with your FP8 prompt GEMM behind --prefill-fp8. Existing checkpoints decode exactly as before. |
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…t resends resume (ashhart#124), streamed tool calls (#114) - CUDA prompts take bf16 activations by default; --prefill-fp8 restores FP8 prompts; both ranks agree on the precision; block-scaled FP8 checkpoints load (ashhart#126) - Flash Next keeps each prompt's state one token early, so identical resends and next thinking turns resume (ashhart#124) - Tool-call arguments stream as they are written on the CUDA server (#114) - Before M5, Flash Next hyper-connection projections of 8+ rows run in 8-row tiles with the per-row bits - --checkpoint-slots on CUDA (ashhart#125)
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.
Flash Next checkpoints whose dense linears ship as block-scaled FP8 (ModelOpt
FP8_PB_WO, the DeepSeek layout:e4m3 bytes and an fp32
weight_scale_invper 128×128 block) now load on the CUDA route and decode from their storedbytes. Before, the family's check refused
FP8_PB_WO, and the loader would have read those tensors as per-tensor FP8(or, for
lm_head, cast the e4m3 bytes to bf16 without their scale).The format and the route
FP8G. The e4m3 bytes sit in the FP8 GEMM's fragment order (asFp8Linear),and each (64 inputs, column) gets its block's scale as one fp32. A 64-input stage is multiplied in bf16 MMAs, since
e4m3 fits bf16 exactly, and the stage's products are added into the accumulator times their scale in stage order.
The stored weight is used exactly, and a row's bits do not depend on the row count, the same contract as the NVFP4
and MXFP8 modes. The scale grid also expresses per-channel and per-tensor FP8.
qmm_prefill8w) over the same bytes, with the block scales as bf16 groupscales. Rounding them to nearest bf16 moves a weight by at most 2⁻⁹ relative, less than the prompt path's own e4m3
rounding of the activations. Changing the shared prompt kernel to fp32 scales looked like more than this PR should
carry. If you'd rather have it exact, I can do that.
Fp8BlockLinear(cuda/nvfp4/linear.py) has the same face asMx8Linear:__call__for decode,prefillfor prompts.
columns (
Concat). Examples:in_proj_bandin_proj_astay bf16 beside the FP8in_proj_qkvandin_proj_z,and the indexer's projection stays bf16 beside the FP8 q/k/v.
lm_headis dequantized to bf16 at load, in row chunks (code × block scale). That covers both thehead and the draft head's rows.
format.schemenames the layoutfp8block(weight_scale_inv, 2-D fp32),format.dequantgains its numpy dequantizer, and the family's config check accepts
FP8_PB_WO.--tp 2on block FP8 stops byname, as the NVFP4 route does.
Tests
tests/cuda/test_nvfp4_linear.py:format.dequant, including N not a multiple of 128;Concatequal to its parts.tests/test_nvfp4_format.py: the numpy dequantizer against torch's float8, and the scheme from tensor storage.tests/cuda/nvfp4_tiny.pygains anfp8blocklayout: block FP8 for the DeltaNet qkv/z/out and attention q/k/v/oprojections and
lm_head, bf16 for the rest, so stacks mix.tests/cuda/test_flashnext_nvfp4_loader.py:On one DGX Spark (GB10, sm_121), torch 2.13 + cu130, Triton 3.7.1:
test_nvfp4_format.py,cuda/test_nvfp4_linear.py,cuda/test_flashnext_nvfp4_loader.py, 39 passed;test_flashnext_nvfp4_kernels.py,test_flashnext_nvfp4.py,test_nvfp4_experts.py,test_qwen27_nvfp4.py): 36 passed, 3 skipped.Served
A local ModelOpt export of Qwen3.8-Flash-Next on one DGX Spark (GB10, 128 GB),
tensorfold serve … --context 32768.The export has NVFP4 experts; block-FP8 DeltaNet, attention and
lm_head; an FP8 n-gram table; and NVFP4 MTP experts.Exactness. Replies were compared by the server's
token_sha:"draft": falseones, anda resumed repeat equals the fresh run;
tools/bench_concurrent.py --levels 1,2,4 --alone --serial(code and chat, greedy and sampled): every concurrentreply equals its request alone (3/3, 6/6, 12/12), and every solo run equals serial.
Against the same weights on the bf16 path. The block-FP8 linears were dequantized to bf16 at load (a local
switch, not in this PR): same checkpoint, drafts on, one start each. Decode tok/s:
bench_concurrentcode, c=1, sampled / greedybench_concurrentchat, c=1, sampled / greedybench_openai400 tokens, fibonacci / chat, greedybench_openai64 tokens, fibonacci / chat, greedyThe bf16 copy rounds each weight, so the two columns decode different replies; both pass the same exactness
checks.
Decode matmul alone (real projections, 50 warm-up and 200 timed calls, CUDA events).
in_proj_qkv[10240, 2560] takes 94 µs on FP8G against 247 µs on the bf16 matmul, and
q_proj[12288, 2560] 128 against292 µs, flat from 1 to 8 rows. 94 µs is about the chip's DRAM floor for those 26 MB.
Not in this PR
nvidia/Qwen3.8-Flash-Next-NVFP4is still refused. Its MTP experts areFP8_BLOCK_SCALES(e4m3 with bf16weight_scale_invper 128×128 block), and its n-gram table is labelledFP8. The block format here is most ofwhat that needs. The MTP experts only draft, so dequantizing them would not change a reply's bits. I have not
loaded that checkpoint, so it is not claimed here.
primitive-ai/Qwen3.8-Flash-Next-mixed-NVFP4-FP8) fits the samescale grid. This route does not read compressed-tensors Flash Next checkpoints yet.
Concatcosts about 45 µs a layer at decode widths: one bf16 matmul for the two small rows plus twocolumn copies. An output stride on the lane matmul would remove the copies.
Written with AI assistance (Claude Code); the author reviewed every change.