Repository navigation
Conversation
The CUDA path took the routing width (top-10, 11 slots) and the shared expert's width (640) from constants. config.json now selects one of two supported shapes, top-10 with a 640-wide shared expert or top-5 with a 1280-wide one, and refuses any other value by the field's name. The pass reads the slots from its scratch, which is sized by the shape; the shared expert's width is its gate_proj's rows. The MTP layer routes at the main layers' top-k. A captured kernel set serves the default shape only. The default shape's launches take the same integers as before. Refs ashhart#3368
…ment names the width it reads Head.init read config.json a second time through widthsIn, after Engine.init had already selected the same shape into e.widths, so a change to one read could leave the other stale. It now takes the engine's widths as an argument, and the MTP rule is unchanged: the head's shared expert may be the main layers' width or the routed width (640), and any other row count stops the load naming mtp.layers.0.mlp.shared_expert.gate_proj. The lanes load, the drafted check and the device parity test pass e.widths. The one-row split path gathers [2, 1, width] blocks into the row the down projection reads, and that row's width is native.shared_width, not the halved per-rank width; the comment now names it. A host test pins the single reader: cuda_mtp.zig holds no widthsIn, its init takes the engine's widths, and both callers pass them. Re-pins cuda_mtp.zig, cuda_lanes_load.zig and cuda_mtp_check.zig in the serving fixture.
Retain config-driven widths beside current main scratch, pool and split paths. Follow main e172bcc perf(flashnext): a prompt pass holds 3,072 rows by default in zig/src/families/flashnext/cuda_batch.zig. Follow main e172bcc perf(flashnext): a prompt pass holds 3,072 rows by default in zig/src/families/flashnext/cuda_batch_state.zig. Follow main 95a8725 flashnext cuda: the page pool's arena maps ahead on its own thread, so no reply waits for a piece in zig/src/families/flashnext/cuda_lanes_load.zig. Follow main 630eeda flashnext cuda: head, head-group and rollback graphs replay at --tp 2 as on one GPU in zig/src/families/flashnext/cuda_launch.zig. Retake only the merged source hashes; retain main notes and width notes.
A projection whose tensors carry weight_scale_inv now loads as stored: the leading block-FP8 parts (e4m3 codes, an fp32 weight_scale_inv a 128 x 128 block) are read through core.quant.fp8 and stacked row for row into one FP8G weight, whose rows past them are zero codes and a block scale of one, and a trailing BF16 part is carried as the exact rows a second BF16 matmul computes and copied into their columns after the lane's. The arm is selected by weight_scale_inv alone, so a projection storing an MXFP8 weight_scale or affine words takes the reader it took before; no checkpoint served today carries weight_scale_inv on these projections, so their replies are unchanged, and no sum is re-ordered where the arm is taken. The pass's scratch holds the tail's rows, and a tail wider than the served one is refused. Host tests drive the store adapter, the stacking, the packers and every refusal without a device. Refs ashhart#3368
readBlock8 now takes the shared reader's optional Why, as the family's other block-FP8 readers do, and passes it through: a load logs and stops, while a test that expects the refusal gets the reason without an error-level log that Zig's runner counts as a failed step. The two pins follow. Refs ashhart#3368 (cherry picked from commit cffdaa7d56061689eb5b8af3da2a49c9aeb6031f)
readBlock8 carried its own dtype, rank, 128-block alignment and shared-k checks, and every input they refused is refused by core.quant.fp8.read and widen anyway: widen refuses exactly when a part is not a whole 128-row block (it is asked for floor(pn/128) block rows of a tensor the reader sized to ceil(pn/128)), and read refuses the dtype, the rank and a part whose k is not the stack's. So the guard cost a check per part and left a second place to keep right, against the module's own rule that the shared reader names the refusal. The parts now go straight to the reader, as the block-FP8 expert reader does, and the stack's n and k are still taken from the store to size the planes. The tail refusals are now asserted at the widths at which each check decides, so the dtype and the count are not shadowed by the length check. Refs ashhart#3368 (cherry picked from commit 4abe18c8a8c42728b4c1d22381f96ad1546b73cf)
The MXFP8 fixture's has() answered false to every name, so the test's assertion that a projection carrying weight_scale is not block FP8 could not fail and the assertion pinned nothing. A real MXFP8 or affine projection carries group-32 weight_scale and no 128 x 128 weight_scale_inv, so the fixture now answers for the name it is asked about. The mutant that has the selector ask for weight_scale instead of weight_scale_inv now fails this test. Refs ashhart#3368 (cherry picked from commit c1c6afe06b1240dc023d1b4e5652c1668243795a)
- fp8gPlanes refused a BF16 tail whose rows were not whole 128-row blocks, so INT4-AutoRound's DeltaNet in-projection stopped the load at layer 0's first mixer: its in_proj_qkv and in_proj_z are block FP8 (16,384 rows) and its in_proj_b and in_proj_a are BF16 48 rows each, a 96-row tail. - The lane does not need the tail to fill a block: the packers zero the codes and one-fill the scales of every row past the projection's own, and a tail row's zero code leaves a zero that its BF16 matmul replaces. Only the head's block boundary is required, since a tail row may not share its 128-row scale block with an FP8 row, and the 96-row tail leaves that boundary at 16,384 alone. - The new host test builds the checkpoint's own row counts at k 256 and holds the packed planes to what the head alone packs, byte for byte and scale tile for scale tile, so no FP8 row's product moves; the tail rows are the store's bytes in order. Restoring the whole-block refusal fails it. The 192-row refusal now passes whole block scales, so the boundary guard is what refuses it and not the length check. Refs ashhart#3368 (cherry picked from commit 126b95f688c8a4b655a21076d448173c39d975d3)
The CUDA path took the routing width (top-10, 11 slots) and the shared expert's width (640) from constants. config.json now selects one of two supported shapes, top-10 with a 640-wide shared expert or top-5 with a 1280-wide one, and refuses any other value by the field's name. The pass reads the slots from its scratch, which is sized by the shape; the shared expert's width is its gate_proj's rows. The MTP layer routes at the main layers' top-k. A captured kernel set serves the default shape only. The default shape's launches take the same integers as before. Refs ashhart#3368
…ment names the width it reads Head.init read config.json a second time through widthsIn, after Engine.init had already selected the same shape into e.widths, so a change to one read could leave the other stale. It now takes the engine's widths as an argument, and the MTP rule is unchanged: the head's shared expert may be the main layers' width or the routed width (640), and any other row count stops the load naming mtp.layers.0.mlp.shared_expert.gate_proj. The lanes load, the drafted check and the device parity test pass e.widths. The one-row split path gathers [2, 1, width] blocks into the row the down projection reads, and that row's width is native.shared_width, not the halved per-rank width; the comment now names it. A host test pins the single reader: cuda_mtp.zig holds no widthsIn, its init takes the engine's widths, and both callers pass them. Re-pins cuda_mtp.zig, cuda_lanes_load.zig and cuda_mtp_check.zig in the serving fixture.
ashhart#3523 was rebased onto main's ce02643 and re-pins the serving sources main moved under it, so this branch's five commits keep their content and only the stack's base moves. Two files conflicted. The scratch keeps this change's tail bytes beside the base's own terms. In the serving pins the base's rows and notes are kept, this change's six note sentences and its new cuda_projection_tail_test.zig row are applied, and every row's hash is recomputed from the merged bytes.
|
#3523 moved again, so I've re-seated this branch on its new head without rewriting anything - the head of the branch is now the merge commit One file conflicted, The merged tree is the parent's content with its move applied and nothing else: Checks on the merged head, all on a verified
I also ran the 12 mutants on this head against the block-FP8 host suite: all 12 are killed, the control passes and each anchor occurs once. Nothing here is a device result; the arm still needs a checkpoint whose projections store |
Terms used below: "upstream main" is TensorFold's
mainat281d81b8be7514145e2c72bc93db481dd72f45ee; "the parent" is pull request #3523 (flashnext-config-widths) atbbb526c112d6622ba7429e6f19548588e9d354e6; and "the branch" isflashnext-block-fp8-projections-up2, the stack on that parent whose head is2b647063c7cd9e08e708ceadb89eee604aff476e. This is a draft: it's opened ahead of the parent, and it claims no GPU receipt and no CI result.What this changes
Before, a quantized Flash Next CUDA projection was read as MXFP8 blocks or affine groups: the loader's
readMicrowantsweight_scale, andweight_scale_invappears nowhere in the projection loader, so a checkpoint whose projections are stored as block FP8 cannot be loaded at all. After, a projection whose tensors carry{prefix}.weight_scale_invis assembled from its block-FP8 parts on the existing FP8G lane: the e4m3 rows with their block scales, then the BF16 trailing parts placed after the FP8 rows with zero codes and a block scale of one, and the BF16 rows computed by a second BF16 MMA and copied over those zeros. No new kernel, no new setting, and no sum is re-ordered or rounded differently: the tail rows are the stored BF16 values.The arm is entered only when that tensor exists. No checkpoint served today stores one: the census of FP4-Local's tensors reads 0
weight_scale_invamong its 375,487 tensors.lane()checks the tail first and every existing weight hastail = null, so no launch, sum or order changes, and replies are byte-identical by construction for every checkpoint served today. The one unconditional change is memory: the scratch'stailbuffer is allocated on every checkpoint,cap * 640 * 2bytes a scratch (3,932,160 bytes at the 3,072-row default chunk, 3.75 MiB). A checkpoint that stores the tensors is served only once the later steps of the order land; this step is the loader and the lane's tail path.The change stays inside the maintainer's constraints. No setting is added: the arm is selected by a tensor's presence,
git diff --name-onlynames no environment file, anddocs/environment.mdis unchanged. No kernel or launch is new: the FP8G lane (cuda.fp8.weight), the BF16nativeMatmulandfn_copy_colsall exist on the parent, so the template's kernel-contract block is answered with n/a below. Comments are one line within 120 columns, and none of the checker's findings is in the changed files:7691 files, 165 problems, all 165 on the base, and the 8 changed Zig files carry none.cuda_batch.zigis 600 lines (591 on the parent), where the checker's limit is more than 600.CHANGELOG.mdis untouched by the branch, so the maintainer's bullet is theirs to add.What moves, file by file:
cuda_projection.zigaddsProjection.Tail, thetail/tail_wfields and their free,Planes,fp8gPlanesandfp8g;cuda_projection_load.zigaddsBlock8,isBlock8,block8Parts,readBlock8,readTail,loadBlock8and the dispatch lines inloadandloadStitched;cuda_batch.zigaddslane()'s tail branch (the FP8G rows over the whole output, the tail's BF16 matmul into the scratch,ops.copyColsover the tail's columns);cuda_batch_state.zigadds the scratch'stailbuffer and its bytes;cuda_prompt_wt.zigcaps the tail at 640 rows (the attention indexer's). The host tests are new files: the loader's tests (stored bytes against the binary64 reference, MXFP8 and affine not selected, the refusals, every partial allocation freed) and the splicer's test at the checkpoint's own shape (16,384 block-FP8 rows and a 96-row BF16 tail).zig/build/cuda.zigregisters the step anddocs/recipes/flash-next-cuda.mdnames it.flashnext-config-widths) atbbb526c112d6622ba7429e6f19548588e9d354e6, the head the maintainer re-pinned. The branch's five commits were re-seated on that head by a merge commit,2b647063c7, whose parents are the branch's previous head42ff781a5dandbbb526c112d6, so no commit was rewritten and the five keep their shas. The merge resolved one file that moved under them,zig/tests/fixtures/gradient-serving.tsv: the parent's rows, order and notes, this step's six note sentences and its newcuda_projection_tail_test.zigrow, and every hash recomputed from the merged bytes. The branch's own diff is the same 10-file stacked diff as before, 625 insertions and 9 deletions, and its tree is2f4d2bb7a3.The stack is clean against its own base:
git merge-tree --write-tree 2b647063c7 bbb526c112d6prints that tree, rc 0. It's now clean against main's tip as well:git merge-tree --write-tree 2b647063c7 281d81b8be75printsbe8ac2be17f1, rc 0. The earlier head collided with main in the serving pins, because the parent was cut on a main that has since moved. Taking the parent's re-pinned rows and recomputing the hashes from the merged bytes removed that collision, so this branch no longer adds a collision of its own to the stack.atc overlap --json: run on this head and it returnedcomplete: false(limitations=otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit), so no verdict is quoted from it. The equivalent check run here isgit merge-treeagainst main's tip281d81b8be75: no conflict, treebe8ac2be17f1095b8733b9b5d58b934294454807, rc 0. Against the stack's own basebbb526c112d6: no conflict, tree2f4d2bb7a36ff2f0443693f34f6a3af8c1906b3f, rc 0.Checks on this head
2b647063c7cd9e08e708ceadb89eee604aff476e, a signed merge commit (%G?=G). Its first parent is the branch's previous head42ff781a5d, its second is the parentbbb526c112d6. The five commits it carries are4a65f311807526a81d07f5926a7b6e44ae003f2b,bd78c69eb3d32998268062d9204a8ce4e9a5f8f8,61392bbcab644a8359b0fec9491cdf87665f468a,1cd33318b646d9c08f9f86559b42b128d39562f4and42ff781a5d71d1c7c55375bac59e30bb3bed9970, all signed with the same public identity; there's no AI attribution line, andCHANGELOG.mdis untouched by the branch (git diff --stat bbb526c112d6 2b647063c7for it is empty).python3 tools/zig/lean_check.py, on the base and this head: run in each tree from its own root with that tree's own copy, thenlean_new.pyfrom the head tree, base first and head second, as the no-gpu workflow runs it.bbb526c112d6:7690 files, 165 problemson the base,7691 files, 165 problemson the head,lean: 165 problems, 165 on the base, 0 new, rc 0.281d81b8be75:7697 files, 165 problemson main,7691 files, 165 problemson the head,lean: 165 problems, 165 on the base, 0 new, rc 0. The checker is a pure-Python scan, so both of this pair ran on an x86_64 workstation, each from its own tree with that tree's own copy.git archiveverified blob by blob against its commit, 13,483 entries, on x86_64 with 16 threads, Zig 0.17.0, the CUDA 13.3.73 compiler only and no GPU, every step under a host-wide lock:zig fmt --check build.zig zigpython3 tools/zig/cuda_common_check.pypython3 tools/zig/cuda_fragment_check.pypython3 -m unittest discover -s tools/zig -p cuda_common_check_test.py -vpython3 tools/test_pdl_early_loads.py -vpincheck (every pin row's sha256 against its file)zig build test-environment-hostzig build -Dfixed-cpu test-gradient-serving test-qwen-serving-hostzig build -Dfixed-cpu test-kernel-contractzig build -Dfixed-cpu test-flashnext-block-fp8-hostzig build compile-config-server -Dtarget=aarch64-linux-gnuzig build compile-cuda-testszig build compile-cuda-tests -Dtarget=aarch64-linux-gnuzig build --summary all -Dnvcc=<cuda-13.3 nvcc> compile-cuda-testszig build --summary all -Dnvcc=<nvcc> -Dtarget=aarch64-linux-gnu compile-cuda-testszig build --summary all -Dnvcc=<nvcc> -Doptimize=fast --prefix <prefix> fatbins install nativeThe branch's delta against the parent is those 10 files and nothing else (
git diff --stat bbb526c112d6 2b647063c7), so every file this step does not touch is the parent's at the head the maintainer re-pinned; the parent's own tests were not re-run here, and its thread carries its runs at its earlier heads. The parent's lean scan in the pair above is this run's own, frombbb526c112d6's tree, because a 0-new pair needs both sides produced on the same host.python3 tools/pr_check.py --base bbb526c112d6622ba7429e6f19548588e9d354e6on the branch's own worktree:merge base bbb526c112d6622ba7429e6f19548588e9d354e6; 10 changed files; lean 165 vs 165, 0 new,0 error(s), 1 warning(s), rc 0. The one warning is the tool's advisory that no--prnumber was passed for its Unreleased-line check, which doesn't apply to a stacked diff that leavesCHANGELOG.mdat the parent's content.weight_scale_inv.test-cuda-hostwas not re-run here: this step's list does not name it, the parent's thread quotes it at an earlier head, and the branch's delta against the parent is the 10 files above. The 12 mutants were run to a verdict on this head: 12 run, 12 killed, 0 not killed; the unmutated control passes (Build Summary: 4/4 steps succeeded). Nothing else is outstanding.Receipt
weight_scale_invon a projection, the arm is entered only when that tensor exists, andlane()checks the tail first while every existing weight hastail = null, so no launch, sum or order changes, and every greedy request's token hash is equal between main and this branch for every checkpoint served today. The one unconditional change is the scratch above. The measurement that would show the arm itself is the device cell, and its checkpoint can't be served until the later steps land.isBlock8,block8Parts,readBlock8,readTail,loadBlock8), the plane builder and the tail's upload, andlane()'s tail branch. The host tests reach all of it but the launches; the launches need a device and a checkpoint that stores the tensors. TP is not reached: the tail's width is a per-projection row count, not a rank setting.git diff --name-onlynames no environment file,docs/environment.mdis unchanged, and the arm is selected by a tensor's presence alone. No profile row is needed.git archiveof the head (2b647063c7, 13,483 entries, every blob verified) on x86_64 with 16 threads, Zig 0.17.0, the CUDA 13.3.73 compiler only and no GPU. No checkpoint was loaded: the host tests build their own bytes, and the checkpoint whose shapes the tail test uses isazampatti/Qwen3.8-Flash-Next-125B-A5B-INT4-AutoRoundat revision1464274120d36a4d8fcaa934552334a7d83ce0fd, whose row counts the test copies rather than its tensors.lane()need a CUDA GPU, no host test reaches them, and they're the first thing a device window would run.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a for every checkpoint served today, and by construction rather than by a run we skipped: with noweight_scale_invon a projection the arm is never entered,lane()runs the launches it ran before in the order it ran them, and the only unconditional write is thetailbuffer's allocation. When the arm is taken, the tail rows are the stored BF16 values (an exact widening, no re-encode), the FP8 rows keep the lane's own sums, and no sum is re-ordered; the check that would show it per column is the device cell the step still needs.tools/bench_openai.py: n/a, no checkpoint served today can enter the arm, so no cell can measure it, and the checkpoint that can is not servable until the later steps land.ttft_sfromtools/bench_cache.py --require-coldon a long prompt, or "n/a" with the reason when the change can't reach prompt processing: n/a, for the same reason; the change is at load time and cannot reach prompt processing on any checkpoint served today.Kernel contract, only when a GPU kernel is new or changed
cuda.fp8.weight), the BF16nativeMatmulandfn_copy_cols, all registered on the parent, and it replaces nothing.SUMMARYline and exit status: n/a, no new kernel. The existing contract suite runs on the head (Build Summary: 41/41 steps succeeded; 288/288 tests passed).Checklist
It names the stack, the merge that re-seated it, the lean pairs and the unrun items.
block8Parts,isBlock8andreadBlock8. On the head the step builds and passes, rc 0. Both are host tests and need no device or checkpoint."draft": false, a resumed prompt equals a fresh one, and concurrent equals solo: not measured, for the reason above and for want of a device run.--drafter, no slower than without it, greedy and sampled: not measured, no cell can enter the arm today.