Skip to content

chain: the nemotron_h walk, plans and reader leave crates/gpu; the hybrid trunk is a common owner in chain - #848

Closed
midagedev wants to merge 5 commits into
mainfrom
mac-nemo1
Closed

midagedev wants to merge 5 commits into
mainfrom
mac-nemo1

Conversation

@midagedev

Copy link
Copy Markdown
Owner

The Nemotron-H decode walk, its layer plans and its reader lived in crates/gpu, so a second backend (Metal) could not run the same walk. This change lifts them to crates/chain:

  • crates/chain/src/hybrid/: the trunk a hybrid (Mamba-2 + attention) model shares: HybridOps (11 methods), the plans, the reader and the walk.
  • crates/chain/src/arch/nemotron_h/: what only Nemotron-H forces (its layer kinds, its plan).
  • crates/gpu/src/arch/hybrid.rs: mamba_layer and gqa_layer split into in/core/out; the wrappers keep their signatures. nemotron_h/program.rs implements HybridOps for CUDA.
  • tools/families.tsv: the new globs.

Proof (move class): just canon-check a9753394e --worktree: 4 bins, 1633 entries, 1633 identical, rows equal. The last two commits (the module moved from chain/src/arch/hybrid to chain/src/hybrid, and rustfmt) change only paths in host code; no kernel can move [derived].

Gates: chain tests 36 passed (13 new). A fixture batch of the callers and lib tests: 10 items, red 0. Real tier gate-gpu-nemotron-e2e rc 0: 380 graph nodes and the ids equal the base's. FAIL-first: 39 of 39 chain mutants red; three CUDA mutants (skip ffn_core, drop the V append, flip the residual rail one layer late) are red in the e2e gate.

gate-gpu-nemotron-h-moe-card32 is red on base too ("stage map: 53 layers vs 52"); #843 owns it.

The box gates ran on base a975339; the next train batch re-runs them on main.

AI use: written and checked with Claude Code.

🤖 Generated with Claude Code

midagedev and others added 3 commits October 27, 2026 03:00
…ehind HybridOps; hybrid.rs's mamba and GQA layers split into in/core/out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…side arch/, and its tests build tensor names with blk

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: the gpu crate imports a module path that does not exist at this head, and NoLeg plus the test-file helpers are proven copies of code already in chain.

Must fix

1. crates/gpu does not compile: stale import path

crates/gpu/src/arch/hybrid.rs:41 imports chain::arch::hybrid::plan. The module moved to chain::hybrid (crates/chain/src/arch/mod.rs lists only nemotron_h and qwen3moe; no arch/hybrid exists). Every CUDA body that uses arch/hybrid.rs (nemotron_h, nemotron_h_moe) fails to build. program.rs:20-21 and body.rs already use the new path, so the move commit missed this line. The canon-check and box gates in the PR body ran on base a9753394e, not on this head: re-run just canon-check and gate-gpu-nemotron-e2e on the fixed head.
Fix:

use chain::hybrid::plan::{MambaPlan, NopeGqaPlan};

2. NoLeg is a second copy of the qwen3moe port

crates/chain/src/hybrid/walk.rs:21-59 equals crates/chain/src/arch/qwen3moe/walk.rs:30-68 except two strings. The doc comment says "a second copy until one common owner takes both". The rule in this project is common code first; the dryer score is 1.00. Both copies must change together when the arena rule changes, and the open bound is a safety check.
Fix: one crates/chain/src/noleg.rs with pub(crate) struct NoLeg<E> { rows: usize, what: &'static str, _error: PhantomData<fn() -> E> }, new(what, rows), and the Port impl using self.what in the open and refused texts. Delete both local copies (about 40 lines) and update the two pinned error strings in the walk tests.

3. Test helpers decl and header are copied

crates/chain/src/hybrid/test_file.rs:10-25 is identical to crates/chain/src/arch/qwen3moe/read.rs:631-647.
Fix: move test_file.rs to crates/chain/src/test_file.rs, declare #[cfg(test)] pub(crate) mod test_file; in lib.rs, and delete the two functions from the qwen3moe test module (import crate::test_file::{decl, header}). Net: fewer lines.

Non-blocking

⚠ Evidence list: the body has no nvidia-smi line and no pair of commit hashes for the A/B, so gpu-evidence cannot be granted.

Checked

  • Duplicates: 14 new items checked. Hits: NoLeg (item 2), test helpers (item 3). Dryer pair 3 (mamba_at/attn_at, program.rs:61-73) matches two different Layer variants: not one fact, no finding.
  • Complexity: crapper flagged nothing.
  • Silent failure: 6 sites followed (at, NoLeg::open, mamba_at/attn_at/mlp_at mismatch, layer_plans refusal). Each returns a named error.
  • Tests: mutants planted in words (drop embed, swap last, wrong op order, accept m = rows + 1): each turns a walk test red. The CUDA Program has no host test; the PR cites the e2e mutants.
  • Performance: decode step; launch order and count are unchanged by the split, no new alloc or sync per layer, NoLeg::new is a stack value. No term to write.
  • Gates: no pins moved. Escape catalog: no match.

Card check: needs-gpu. This pull request changes crates/gpu/src/arch/hybrid.rs, crates/gpu/src/arch/nemotron_h/body.rs, crates/gpu/src/arch/nemotron_h/mod.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Comment thread crates/gpu/src/arch/hybrid.rs Outdated
use crate::tensor::{Pitched, dtod_2d};
use crate::weights::{DevWeight, Weights};
use crate::{DeviceTensor, Gpu, GpuError, Q8Act, Window};
use chain::arch::hybrid::plan::{MambaPlan, NopeGqaPlan};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chain::arch::hybrid does not exist; the module is chain::hybrid, so the gpu crate does not build.

Suggested change
use chain::arch::hybrid::plan::{MambaPlan, NopeGqaPlan};
use chain::hybrid::plan::{MambaPlan, NopeGqaPlan};

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: the import fix landed, but NoLeg and the test helpers are still copies of code already in chain.

Since the last review:

  • Must fix 1 (stale chain::arch::hybrid::plan import): fixed. hybrid.rs:41 now uses chain::hybrid::plan.
  • Must fix 2 (NoLeg): still open.
  • Must fix 3 (decl, header): still open.
  • ⚠ Evidence list: still open.

Must fix

1. NoLeg is a second copy of the qwen3moe port

crates/chain/src/hybrid/walk.rs:21-59 equals crates/chain/src/arch/qwen3moe/walk.rs:30-68 except two strings. The doc comment says "a second copy until one common owner takes both". The open bound is a safety check, so both copies must change together. Doing it now costs about 40 fewer lines; later, a third family copies it again.
Fix: one crates/chain/src/noleg.rs with pub(crate) struct NoLeg<E> { rows: usize, _error: PhantomData<fn() -> E> }, new(rows), and the same Port impl, with fixed text chain::NoLeg in the open and refused errors (Port::refused has no self, so a per-walk name field cannot reach it). Delete both local copies and update the pinned error strings in both walk tests.

2. Test helpers decl and header are copied

crates/chain/src/hybrid/test_file.rs:10-25 is identical to crates/chain/src/arch/qwen3moe/read.rs:631-647.
Fix: move test_file.rs to crates/chain/src/test_file.rs, declare #[cfg(test)] pub(crate) mod test_file; in lib.rs, delete the mod test_file line at hybrid/mod.rs:14 and the two functions from the qwen3moe test module, and import crate::test_file::{decl, header} there and in hybrid/read.rs:153 and nemotron_h/read.rs:83. Net: fewer lines.

Non-blocking

⚠ Evidence list: the body has no nvidia-smi line and no pair of commit hashes for the A/B, so gpu-evidence cannot be granted. The canon-check and box gates ran on base a9753394e, and the last review found this tree did not compile in crates/gpu. Re-run just canon-check and gate-gpu-nemotron-e2e on the final head and paste the output.

Checked

  • Duplicates: new commit adds 1 line, an import path; no new item. Dryer pairs 1 and 2 (NoLeg) confirmed by reading both sides: must fix 1. Pair 3 (mamba_at/attn_at) matches two different Layer variants: no finding.
  • Complexity: crapper flagged nothing.
  • Silent failure: the new commit adds none.
  • Tests: no test changed in the new commit.
  • Gates: no pins moved. Escape catalog: no match.

Card check: needs-gpu. This pull request changes crates/gpu/src/arch/hybrid.rs, crates/gpu/src/arch/nemotron_h/body.rs, crates/gpu/src/arch/nemotron_h/mod.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@midagedev

midagedev commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner Author

Fixed in 1b05f11:

  1. crates/chain/src/noleg.rs holds the one NoLeg port; both walks use it. Its open and refused errors read chain::NoLeg; the pinned strings in both walk tests follow.
  2. crates/chain/src/test_file.rs (#[cfg(test)]) holds decl and header; the qwen3moe reader tests, the hybrid reader tests and the nemotron_h reader tests import it.

Net: 18 lines in, 119 out 70 lines in, 122 out (the first count was taken before the import fixes). Second M1 Pro: cargo test -p bloomery-chain 36 passed, clippy -D warnings rc 0. Box: just check rc 0 (chain and gpu checked).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: both earlier must-fix items are fixed, and the new commit adds no defect.

Since the last review:

  • Must fix 1 (NoLeg copy): fixed. One owner now, crates/chain/src/noleg.rs:11. Both walks import it and the local copies are gone.
  • Must fix 2 (decl, header copies): fixed. One owner now, crates/chain/src/test_file.rs:10. The qwen3moe copy is deleted and the hybrid and nemotron_h tests import it.
  • Evidence list: still open (see Non-blocking).

Non-blocking

⚠ Evidence list: the body has no nvidia-smi line and no pair of commit hashes. The canon-check and box gates ran on base a9753394e, not on this head. The last two commits only move host code, so the risk is low, but gpu-evidence cannot be granted. Re-run just canon-check and gate-gpu-nemotron-e2e on the final head and paste the output with the card line.

Checked

  • Duplicates: the new commits add NoLeg and test_file as the single owners. Grep for struct NoLeg, fn decl, fn header in crates/chain: one hit each. The dryer pair in program.rs:61-66 and 68-73 was read in the first round (two different Layer variants): no finding.
  • Complexity: crapper flagged nothing.
  • Silent failure: 0 new sites. The refused error now carries chain::NoLeg and not the walk's name; the walk tests pin both strings.
  • Tests: the two pinned strings in both walk tests moved with the code. Mutant: the open bound 1..=rows changed to 1..rows turns the 17-column and 2-unit assertions red.
  • Gates: no pins moved. WHAT is still used in both walks (hybrid/walk.rs:55, qwen3moe/walk.rs:58), so no dead constant. Escape catalog: no match.

Notes

CTX/diagnostics.md: both tools ran.

Card check: needs-gpu. This pull request changes crates/gpu/src/arch/hybrid.rs, crates/gpu/src/arch/nemotron_h/body.rs, crates/gpu/src/arch/nemotron_h/mod.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@midagedev

Copy link
Copy Markdown
Owner Author

Superseded by #1192: the same lift redone on today's main (the branch was 1168 commits behind). The design is the same; #1192 carries the hybrid.rs changes main gained since.

@midagedev midagedev closed this Nov 11, 2026
midagedev added a commit that referenced this pull request Nov 11, 2026
…ain::hybrid, chain::arch::nemotron_h); the gpu body implements HybridOps (nemotron_h::Program) and its step is the walk

The hybrid trunk (Mamba-2 and NoPE attention) gets the shape qwen3moe has: HybridOps is the op list a backend
implements, LayerPlan the per-layer plan read from the file's header, Walk the one order (embed, each layer's
in/core/out, head) over runtime::sched. Nemotron-H's MLP layer is the family's Ffn. crates/gpu's mamba_layer and
gqa_layer split into in/core/out parts; the wrappers keep their signatures, so nemotron_h_moe is unchanged.
The body resolves its layers from the plans (Names::mamba_of, attn_of). NoLeg and the test header builder move to
chain::noleg and chain::test_file, shared with qwen3moe.

A move: the same launches in the same order. Redo of #848 on today's main (the imatrix, NVFP4 and out-gate
sites of hybrid.rs carried over). 13 chain tests, each with its mutant under .mutants/nemolift-*.patch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CjHkkjGpdUeLi6Z7fiwRXH
@midagedev
midagedev deleted the mac-nemo1 branch November 11, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant