Repository navigation
Conversation
…uses per-layer inputs and shared caches (ashhart#1222)
…red-layer tensors, with BF16 and 8-bit module overrides (ashhart#1222)
This was referenced Oct 26, 2026
9 tasks done
Owner
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.
What this changes
Part of #1222, stacked on #1400 (only the last commit is new).
plan.zig(twincuda_plan.zig): the names, shapes and widths a config's geometry stores, and the ones it leaves unread. For E4B: the per-layer token table, model projection and norm, each layer's per-layer gate, projection and post norm,v_projon global layers, and nok_proj,v_projork_normread on the 18 shared layers (transformers skips them too:modeling_gemma4.py, the shared layers take the owner's cache).check()refuses a missing tensor or a wrong shape by name. No loader calls it yet: each backend does when it lifts its refusal.widths.zig(twincuda_widths.zig) reads mlx-lm's per-module overrides fromquantization, as agreed in Gemma 4 E4B (NVIDIA Nemotron 3.5 Bolt E4B): per-layer inputs and shared KV, Intel Arc first #1222: a per-layer input module set tofalsestays BF16, a module may carry its ownbits; the global layers'v_projtakes its own entry. Only the per-layer input modules may be BF16, and one module cannot be named twice under the two spellings.Geometry.cacheLayers(): how many layers own a cache, so a backend sizes and snapshots only those.The twin test in
cuda.zignow also coversplan.zig/cuda_plan.zig.Receipt
Same stack receipt as #1400 (exactness, speeds, kernel contract and suites, CUDA and Metal). Specific to this PR: the E4B checkpoint written by the converter (#1403) with BF16 per-layer linears passes
check()on all 1,185 tensors; the 8-bit attention table and the dense 12B and 31B geometries (no per-layer input, no globalv_proj) are covered by the tests above.