Skip to content

gpu: the nvtier arena takes its pages from a PageSource - #844

Merged
midagedev merged 1 commit into
mainfrom
mac-tier1
Oct 26, 2026
Merged

midagedev merged 1 commit into
mainfrom
mac-tier1

Conversation

@midagedev

Copy link
Copy Markdown
Owner

The tier arena's memory had one hard-coded source: pinned CUDA host pages. A Mac (unified memory) or another backend needs to hand the arena pages it already owns. This change puts that behind a PageSource / ArenaPages trait, with two kinds: Anon (the arena maps its own pages) and Provided (a backend gives them). ArenaMem::provided refuses by name a length or alignment the arena cannot use. The CUDA source (PinnedSource, PinnedPages) lives in crates/gpu/src/model.rs, so the host side of the arena has no CUDA code in it.

Proof (move class): just canon-check a9753394e --worktree: 4 bins, 1633 entries, 1633 identical, rows equal. No kernel and no launch moved.

Gates: just affected gave 169; the four scan pairs are identical, so the narrowed list is 111. Fixture tier: 76 items, red 0. gate-gpu-lib 420 passed. Real tier gate-gpu-nvtier rc 0.

FAIL-first: four new clauses (a_provided_arena_*). Two mutants (the length/alignment check off; the device address read as 0 and MADV_DONTNEED on provided pages) turn 3 and 4 tests red, as predicted.

The box gates ran on base a975339. This rebase on main moves their keys; the next train batch re-runs them.

AI use: written and checked with Claude Code.

🤖 Generated with Claude Code

… provided), the pinned CUDA source beside the model

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 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: CLEAN: the change moves the arena's page source behind a trait. I found no failure path, and the behavior matches the old Pinned path line by line.

Non-blocking

⚠ The new traits have one production implementer: crates/gpu/src/host/nvtier.rs:293 adds ArenaPages and PageSource, and only PinnedSource in crates/gpu/src/model.rs:1901 implements them outside tests. The Metal crate does not reference the tier yet, and docs/research/metal-offload.md:194 plans an enum kind Shared, not a trait. The test source HostSource is the only second implementer. Keep this only if the lift of the tier core follows soon. Otherwise a Shared enum variant is one element, not two traits plus a Box<dyn>.

⚠ Comments still say "pinned arena" for the provided case: nvtier.rs:2375 ("none on a pinned arena") and nvtier.rs:2496 describe give_back, which is now the Provided rule. The head comment was already updated to "provided". Make these two match it. docs/research/metal-offload.md:194 still names ArenaKind::Pinned and ArenaMem::pinned.

⚠ GPU evidence is partial: the body gives the base hash a9753394e only, no nvidia-smi line, and no command output. The body says the head moved by a rebase, so the box gates ran on a different tree. This does not change the verdict. The CONTRIBUTING.md evidence list is the reference.

Checked

  • Duplicates: 7 new items checked (ArenaPages, PageSource, PinnedSource, PinnedPages, arena_kind_of, ArenaMem::provided, eight_tier_over), none duplicated. dryer reported 0 pairs.
  • Complexity: crapper flagged no function.
  • Silent failure: 3 sites followed. A length mismatch and a misaligned base are assert!s (active in release) and name the source. device_base() == None reaches card_arena() and device_slot() as None, and the test pins it. give_back on Provided is Ok(()), the same as the old Pinned.
  • Behavior equivalence: dev_at(skip) equals the old dev_at(base - host_at(0)), and skip is the old alignment offset. Pinned-memory drop order is unchanged, since MappedHost moved into the Box.
  • Hot path: none (carve and load time only). give_back still matches on the enum, with no dyn call per step.
  • Tests: for the length check, a mutant that drops the bytes() == len assert turns ..._refuses_pages_of_another_length red. For the alignment check, a dropped assert turns ..._first_byte_off_the_direct_alignment red. For give_back, a mutant that advises provided pages zeroes the HostPages map, so "after a give-back" fails. For the device address, a base of 0 turns Some(DEV + at) red.
  • Gates: no pin moved, none removed.
  • Escape catalog: no pattern matched (no shell in the diff).

Notes

Aim: no finding came from dryer or crapper.

Card check: needs-gpu. This pull request changes crates/gpu/src/host/nvtier.rs, crates/gpu/src/model.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)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant