Skip to content

core/modelopt: read MIXED_PRECISION's per-module recipes - #1023

Closed
Bizuayeu wants to merge 1 commit into
ashhart:mainfrom
Bizuayeu:pr/fp4local-recipes
Closed

Bizuayeu wants to merge 1 commit into
ashhart:mainfrom
Bizuayeu:pr/fp4local-recipes

Conversation

@Bizuayeu

Copy link
Copy Markdown
Contributor

What this changes

Adds admitRecipes to core/modelopt.zig: it reads a ModelOpt MIXED_PRECISION config (NVIDIA's FP4-Local checkpoints) into each quantized module's recipe, and refuses an entry it cannot read by its module's name (#1015). admit is unchanged, and nothing calls admitRecipes yet.

  • The recipes it reads:
    • NVFP4, with plain block scales or csf_32x2_v1 ones;
    • W4A16_NVFP4;
    • MXFP8;
    • FP8_PB_WO.
  • Each recipe's group, block and scale encoding must be the ones this engine reads; the refusal names the module and its quant_algo.
  • Recipes.of(name) finds the recipe of a module, or of a tensor under it, by the longest declared module it lies under, split at dots.
  • A single-format NVFP4 config gets admit's check and an empty table.
  • The fixture is the checkpoint's own config.json at revision 76348ddb, as fixtures/glm53_flash_nvfp4/config.json is for nvidia/GLM-5.3-Flash-NVFP4.

Receipt

  • Environment: TensorFold 9ccf4727 plus this commit, Zig 0.17.0. Host tests on x86_64 Linux, on an LF tree from git archive.
  • On nvidia/GLM-5.3-Flash-FP4-Local@76348ddb, the table holds 494 modules:
    • 42 NVFP4 with csf_32x2_v1 scales, one for each MoE layer's routed experts;
    • 77 W4A16_NVFP4: the MTP layer's experts and 76 in the vision tower;
    • 205 MXFP8: 146 in the text layers and lm_head, 11 in the MTP layer and 48 in the vision tower;
    • 170 FP8_PB_WO.
  • Exactness: n/a. Only a config check is added, and nothing calls it yet.
  • Decode speed before and after: n/a, for the same reason.
  • Prompt speed before and after: n/a, for the same reason.
  • Tests run:
    • zig build test: 84/84 steps, 1380/1387 tests passed, 7 skipped.
    • zig build test-kernel-contract, test-golden, fuzz-cortheon and a plain zig build: succeeded.
    • lean: 0 new problems (517 on main). git diff --check: clean.
    • The new tests cover FP4-Local's counts and lookups, dot boundaries, and an NVFP4 config with no recipes.
    • They also cover the refusals:
      • no quantized_layers;
      • an unknown quant_algo;
      • the slab encoding csf, and csf_32x2_v1 on W4A16_NVFP4;
      • MXFP8 with group 16 or block [1, 64];
      • FP8_PB_WO with block [64, 64];
      • an entry that is not an object;
      • a single-format config of another quant_algo.
  • Not run: GPU checks, since nothing on the GPU changes.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (A config check only; no serving code changes.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No served path changes; nothing calls it yet.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No arithmetic; the table only names each module's stored format.)
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No GPU kernel.)
  • Prompt processing is no slower than the last release. (No served path changes.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not. (Host tests on x86_64 Linux; nothing platform-specific.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (They call the new function on the fixture; before it, admit refuses the config as not NVFP4.)
  • Comments and docstrings are one line. No measurements or history in the source. (lean: 0 new problems.)
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

…s (nvidia/GLM-5.3-Flash-FP4-Local) and refuses an unreadable one by its module's name; admit is unchanged
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu for the 494-module fixture: 42 CSF NVFP4, 77 W4A16_NVFP4, 205 MXFP8 and 170 block-FP8 entries. We're taking the recipe table as a shared host foundation for 1.1.1. Review confirms longest-module lookup at dot boundaries, named refusal of unsupported declarations, and preservation of the existing single-format NVFP4 admission path. Existing readers do not start accepting mixed checkpoints merely because the table exists. The GLM mixed-format readers, stored MXFP8 MTP path, F32 norms and #1015's full model gate remain separate work. No additional change is requested for this recipe-table PR.

Posted by Ash's AI Assistant Synthena

@ashhart ashhart mentioned this pull request Oct 18, 2026
ashhart pushed a commit that referenced this pull request Oct 19, 2026
Credit: @Bizuayeu for the implementation, real config fixture and tests.
Keep legacy admit behavior and reject unsupported recipes by module name.
@ashhart

ashhart commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu. 1.1.1 ships the owned per-module recipe table, longest dot-boundary lookup and named refusals while retaining single-format NVFP4 admission. Closing for that foundation. The later 3fd16a9 corrects the CSF decoder comment; we'll carry that into 1.1.2 with your credit. Mixed-format family loading, stored MXFP8 MTP, F32 norms and #1015's full-checkpoint gate remain separate.

Posted by Ash's AI Assistant Synthena

@ashhart ashhart closed this Oct 19, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
Credit: @Bizuayeu for the implementation, real config fixture and tests.
Keep legacy admit behavior and reject unsupported recipes by module name.
@Bizuayeu
Bizuayeu deleted the pr/fp4local-recipes branch October 25, 2026 07:27
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.

2 participants