Skip to content

core: step5's bf16 logprob row moves to lanes.logprob, six families stop importing step5 - #4950

Open
jschmied wants to merge 1 commit into
ashhart:mainfrom
jschmied:struct/step5-row-to-core
Open

jschmied wants to merge 1 commit into
ashhart:mainfrom
jschmied:struct/step5-row-to-core

Conversation

@jschmied

@jschmied jschmied commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Head: ab60da2e66 (one commit on main a0f809ea09).

Six families took their logprob row from another family's backend: flint, llama, minimax_m3, ricursive, spark25 (metal_backend.zig) and hy4_flash (serve_metal.zig) each had const row = @import("../step5/backend.zig").row;. This is the second cleanup named in #4804 ("step5's row helper, used by six families' backends, moves to core").

  • row (bf16 logits → LogprobRow: fp64 normalizer, count best ids, ties to the lower id) moves from families/step5/backend.zig to core/lanes/logprob.zig as bf16Row, next to Row and Row.fromWords. Its test moves with it.
  • step5 and the six families now alias it: const row = lanes.logprob.bf16Row;. Every call site is unchanged.
  • The body is the same code: top is now max_top (the same constant, logprob.zig is where it lives) and step5's private logit is bf16 there. No logic change.
  • Core already had no bf16 row builder. native/xpu_logrow.zig has an f32 one, which this does not touch.

Not included: step5 and gemma4 also import qwen3_5/backend.zig for draw. That is not the same kind of helper: draw is Qwen's wrapper over core's lanes.sampling_row.draw that renames the errors (NonfiniteQwenLogits, NoAllowedQwenToken). Pointing step5/gemma4 at core directly would change their error names, so it stays for a separate decision.

Structure check (zig_deslop.py, the #4804 checker), before and after

Before (main a0f809ea09):

== field-leak: 15 family -> family reaches
- families/flint -> families/step5: 1 files (backend.zig)
- families/hy4_flash -> families/step5: 1 files (backend.zig)
- families/llama -> families/step5: 1 files (backend.zig)
- families/minimax_m3 -> families/step5: 1 files (backend.zig)
- families/ricursive -> families/step5: 1 files (backend.zig)
- families/spark25 -> families/step5: 1 files (backend.zig)

After (ab60da2e66):

== field-leak: 9 family -> family reaches

No -> families/step5 lines remain; the module cycle is unchanged (1 group of 8, not touched here).

Verification on ab60da2e66

  • Full x86 CI set (zig build -Dfixed-cpu test-host test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths, check-native-cuda-host compile-cuda-tests, tools/pr_check.py, zig fmt --check build.zig zig, git diff --check, lean): X86-ALL-GREEN. Build Summary: 2535/2535 steps succeeded; 26669/26832 tests passed (163 skipped), cuda-host 17/17, pr_check lean 165 vs 165 with 0 new, fmt and diff-check clean.
  • Byte-identity, GB10 (sm_121, CUDA 13.0, ReleaseSafe): zig build native of main a0f809ea09 and of this head, both built in the same worktree path, give the same tensorfold-native: md5 d5ca6a3f63f8 for both. The build is deterministic only at a fixed path: the same commit built in another worktree path gives a different md5 (checked on the first head 3ea80bd2dc: same path as main b557b90de594 = main, other path 47f65ed984be).
  • The moved code is Metal-only in six of the seven files, so it compiles only on a Mac (M3 Pro, macOS, Zig 0.17.0, -Dcpu=apple_m1):
    • zig build native: 66/66 steps on this head and 66/66 on main a0f809ea09, same session and flags. compile-step5-host, test-flint-draft-host and test-core-lane are green too (83/83 tests).
    • test-step5-host does not compile, on this head or on main: zig/src/core/checkpoint_metal.zig:5:20 and 6:28, "no module named 'core' available within module 'root'" (root zig/step5_family_tests.zig). On main a0f809ea09 alone it fails with the same two errors (8/11 steps). Those imports came in with ec277c16b; the step5 test module has no core. Not from this PR; it needs core added to that test module, which I'll leave to a separate fix unless you want it here.
    • Planted control (first head 3ea80bd2dc, not committed): bf16Row changed to bf16RowX in flint and hy4_flash. zig build native goes red with exactly those two, flint/backend.zig:9:26 and hy4_flash/serve_metal.zig:600:26 "no member named 'bf16RowX'". zig build tensorfold stays green with the plant, so native is the step that compiles these files; the Linux cross-build never analyzes them either.
  • The step5 unit test moved unchanged into core/lanes/logprob.zig and now runs in every lanes test build (the x86 test step above).
  • Rebase: opened on main a0f809ea09; the first head 3ea80bd2dc was on 0b39f4d64e. One conflict, minimax_m3's import block (main added round_costs); both lines kept. rebase-gates.py said DEVICE (Metal), so the Mac native build, x86 and native md5 above were all rerun on ab60da2e66.

Not applicable

No new kernel, refusal, env flag, opt-in path or served behaviour: this is an import move. The equality against main is the byte-identical tensorfold-native above, so seeded, resume and concurrency runs, a parity-controls line and speed rows do not apply; the planted control is the compile one above.

Proposed CHANGELOG line (Unreleased, Changed): - Core: the bf16 logprob row moved from step5 into lanes.logprob; six families no longer import step5's backend (#4950).

Refs #4804, #2251

…top importing step5

flint, llama, minimax_m3, ricursive, spark25 and hy4_flash took their logprob row from
families/step5/backend.zig. The helper is now lanes.logprob.bf16Row, next to Row itself;
step5 and the six families alias it as before. Same code, no logic change.
@AIFlowML

Copy link
Copy Markdown
Contributor

I tested ab60da2e668b1a4fea234fa2ce05525de5c8abc6 after #4878 (6cdbccbb4f746600fb93c93299c6aa2ec0d39b31) on main 4c79cfe346d3c239ff7dfd7aa694df799755bafa. Both trial merges were clean. The import checker confirms the six family-to-Step-5 edges are gone. zig test zig/src/core/lanes/logprob.zig passed 2/2, including the moved bf16 test. zig build test-shared-lane-regressions-host -Dfixed-cpu passed 516 with one skip on the combined tree.

One inherited macOS host failure showed up: zig build test-step5-host -Dfixed-cpu fails on both clean main and the combined tree because checkpoint_metal.zig imports core, which the standalone step5_family_tests.zig module doesn't supply. In scratch, pointing the family test at the existing engine module in zig/build/step5_host.zig restored 69/69 on both trees. Adding core to the old standalone root instead causes duplicate ownership of checkpoint_metal.zig. This looks like separate host-fixture work. The tests here did not run Metal inference.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you, @jschmied. The BF16 conversion, normalizer and insertion sequence are unchanged, and the six family edits only replace the alias. The moved test and relevant Metal build results are recorded. This looks ready to land; the inherited standalone test-module issue remains separate.

  • Synthena

This branch has not been deployed

No deployments
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