Skip to content

gpu: own shared slot row admission and operand views - #775

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
Burntgogi:refactor/issue609-c1
Oct 24, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
Burntgogi:refactor/issue609-c1

Conversation

@Burntgogi

@Burntgogi Burntgogi commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Scope

Refs #609. Implement C1 only; C2–C9 and the frozen familywide census remain unchanged.

  • gpu::model::slots owns SlotRowOrder::{Any, RetainedPrefix}, tiled/nonempty/parked-count admission, checked borrowed SlotRange id views, and shared missing-parked/duplicate-slot refusals.
  • Migrate Body35 (Any), Body38 (RetainedPrefix), Qwen3 SlotPass/SlotIn, MiMo2 tiling, GLM's missing-parked error, and model duplicate-slot errors. Remove private helper copies and duplicated tiling loops.
  • Keep caller-specific empty-pass and combined arena/head/parked errors, validation precedence, binding walks and body-side check positions. No kernel, launch, operand or graph code is changed.

Observed host verification

  • Real common slot helper tests: 2 passed. Actual retained SlotPass::check regression: 1 passed, via cargo oxide test --arch sm_86 without CUDA initialization.
  • A temporary compiled consumer admitted a real five-row Any pass, returned the original borrowed ids [12, 13, 14], rejected that parked-first pass under RetainedPrefix, and refused maximal invalid endpoints. The temporary example was removed.
  • Existing census companion plus pinned Rust AST parsers: 8 retired helpers / 85 code-bearing rows, 6 common declarations or methods / 69 rows. This excludes imports, bindings, impl scaffolding and extra moved loops: not a net-removal or performance claim. The common-owner cost exceeds the old forecast and is disclosed in existing docs/research/layer-composition.md; the frozen census JSON is untouched.
  • Actual owning just gate-app through the local box/gate wrappers: 27 passed, 0 failed, 0 ignored.
  • Formatting and comment checks passed. just pre-review exits 75 because no Claude CLI is installed; nothing was reviewed.

Device-runtime limit

No NVIDIA device/driver or configured remote GPU is available. Body35/Body38 device-backed methods, eager/captured execution and retained-prefix scheduling still need the applicable owning GPU gates; no numerical, graph operand/order/count, or performance result is claimed. The official --narrow run with all four identical scan pairs retains the full 157-recipe list: crates/gpu-mimo2/src/slots.rs has no applicable gate-path row. No mapping was added to shrink the obligations. The host gate-app passed; this is not a claim that the device recipes passed. No gate or pin was weakened.

Final review correction and reviewed-base move proof

The actual R13 finding is fixed in 43a15006d10365452f54ec422d512b3da8a23d1b: SlotRowOrder::admit and SlotRange::ids are pub(crate). Actual external callers retain only the needed public tiled_rows (MiMo2) and no_parked (GLM) methods. No public compatibility shim is retained.

The common slot contracts (2) and real SlotPass admission regression (1) passed after rebasing to the exact requested fc0537b6 base. Formatting and comment checks passed; local pre-review exits 75 (no Claude CLI, nothing reviewed). Narrowing the ids signature caused Rustfmt to add four code-bearing rows; the existing AST counter now measures 6 common units / 69 rows versus 8 retired helpers / 85, and the document is corrected. The frozen census is unchanged; these are not net-removal/performance numbers.

The original standalone admission/id-view consumer ran before internalization. Final private-method evidence is from the actual in-crate production-method tests; the earlier consumer is not presented as a supported external API.

Direct final-snapshot comparison against the review-requested base:

bash tools/canon-check.sh fc0537b6fb821beda085998718a7b44c9b8eb686 HEAD --out /home/jutai05/bloomery-contributions/ordered-767-764-xcg1_b67/609-canon-fc
narrow-scan: fc0537b6..43a15006
canon-check: 4 bins, 1448 entries: 1448 identical, 0 reordered-only, 0 differs, 0 only-on-one-side; rows equal (jit columns not compared: no-jit both)

The complete repository scan set covers all 8 kernel carriers, including the MiMo2/GLM consumers compiled through the full-feature serve target. CUDA 13.3, explicit LLVM 21, pinned oxide 87bc9518, sm_86. No selected-entry comparison or JIT/device execution is substituted for the complete scan set.

GPU eager/captured slot behavior, graph operand/order/count checks and numerical/card gates still cannot be run on this host (no NVIDIA device/driver or configured GPU remote). Identical PTX and the 27/27 host app gate are not presented as those device results. No gate criteria, mapping, pin, dependency or skip list was weakened.

Fresh official narrowing against these exact fc/base and final/head scan pairs retains all 157 recipes because the MiMo2 slot source still has no gate-path mapping. The mapping was deliberately not changed merely to reduce the obligations.

@github-actions github-actions Bot added documentation Improvements or additions to documentation 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 24, 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: two new methods expose unnecessary public API in violation of R13.

Must fix

1. Keep the admission and id-view methods crate-visible

crates/gpu/src/model/slots.rs:227 and crates/gpu/src/model/slots.rs:249: admit and ids have no caller outside bloomery-gpu. MiMo2 uses tiled_rows; GLM uses no_parked. R13 permits pub only for actual callers in another crate (kind B).
Narrow these methods now, before external consumers create compatibility obligations. Replace their definitions with:

pub(crate) fn admit(
    self,
    what: &'static str,
    rows: &[SlotRange],
    parked: usize,
) -> Result<usize, GpuError> {
    let at = self.tiled_rows(what, rows)?;
    let others = rows.iter().filter(|r| r.slot != 0).count();
    if at == 0 || parked != others {
        return Err(GpuError::shape(
            what,
            format!(
                "a pass of {at} rows with {parked} parked sequences for {others} slots past slot 0"
            ),
        ));
    }
    Ok(at)
}
pub(crate) fn ids<'i>(&self, what: &'static str, ids: &'i [u32]) -> Result<&'i [u32], GpuError> {
    ids.get(self.rows.clone()).ok_or_else(|| {
        GpuError::shape(
            what,
            format!(
                "slot {}'s rows {:?} of {} ids",
                self.slot,
                self.rows,
                ids.len()
            ),
        )
    })
}

Non-blocking

⚠ Complete the move evidence against this PR's base: crates/gpu/src/arch/qwen3moe/body38.rs:5637.
The supplied canonical comparison starts at 8d912142, while this PR's base is fc0537b6.
Run just canon-check fc0537b6fb821beda085998718a7b44c9b8eb686 and attach the owning eager/captured slot and graph-count gate output when hardware is available. These checks establish host bindings that PTX identity cannot prove.

Checked

Duplicates: 11 new items checked (6 production items, 5 test functions); no duplicate owner found. Dryer reported 0 pairs.
Complexity: MiMo2 Body::plan 20→21 and Body::enqueue_pass 17→18 inline the existing empty-pass refusal; harmless branch growth.
Silent failure: 10 migrated id/parked call sites followed; named errors propagate without defaults.
Tests: static mutation review found assertions rejecting deletion of the prefix/parked checks (model/slots.rs:213,235), a shifted slice (:250), and removal of the arena bound (slot_pass.rs:315). All 3 new tests belong to gate-gpu-lib; tests were not executed here.
Gates: no pins moved or clauses removed. Empty, reversed, overlapping and maximal ranges retain their prior validation order.
Performance: slot decode admission changes add no allocation, launch, copy or synchronization.
Escape catalog: C1–C4 do not match the diff.

Notes

The body reports host verification and no available GPU. It supplies no card gate run meeting the evidence list; GPU evidence is false.

Card check: needs-gpu. This pull request changes crates/gpu-glm5next/src/pair.rs, crates/gpu-mimo2/src/slots.rs, crates/gpu/src/arch/qwen3moe/body35_slots.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/model/slots.rs Outdated

/// Admit a nonempty pass and one parked sequence per range past slot 0,
/// after checking tiling and the arena's order requirement.
pub fn admit(

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.

R13: all callers of this method are inside bloomery-gpu; keep it crate-visible.

Suggested change
pub fn admit(
pub(crate) fn admit(

Comment thread crates/gpu/src/model/slots.rs Outdated

impl SlotRange {
/// This slot's operand ids, with an invalid range refused by slot name.
pub fn ids<'i>(&self, what: &'static str, ids: &'i [u32]) -> Result<&'i [u32], GpuError> {

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.

R13: this id view has no caller outside bloomery-gpu; keep it crate-visible.

Suggested change
pub fn ids<'i>(&self, what: &'static str, ids: &'i [u32]) -> Result<&'i [u32], GpuError> {
pub(crate) fn ids<'i>(&self, what: &'static str, ids: &'i [u32]) -> Result<&'i [u32], GpuError> {

@Burntgogi
Burntgogi force-pushed the refactor/issue609-c1 branch from ea2ee88 to 43a1500 Compare October 24, 2026 13:27
@Burntgogi

Copy link
Copy Markdown
Contributor Author

Addressed R13 in 43a15006: admission and id-view methods are crate-visible; the two methods with actual external MiMo2/GLM callers remain public. All three actual production-method tests passed after rebasing to the requested fc0537b6. The direct complete 4-bin/8-carrier comparison is now included in the PR body for this exact final revision, together with the corrected 69-row common-owner measurement and explicit GPU-runtime limit. Official narrowing still retains all 157 recipes; no gate mapping was added to evade that result.

@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.

Since the last review:

Verdict: CLEAN: The visibility defect is fixed; the interdiff introduces no must-fix defect.

Non-blocking

⚠ Complete the owning slot/graph evidence: crates/gpu/src/arch/qwen3moe/body38.rs:5637.
The supplied comparison reports all 1,448 entries identical against fc0537b6.
PTX identity does not validate host bindings. Attach the applicable eager/captured slot and graph operand/order/count gate commands and output when hardware is available.

Checked

Duplicates: 0 new items in the interdiff; no new owner added. Dryer reported 0 pairs.
Complexity: crapper flagged MiMo2 Body::plan 20→21 and Body::enqueue_pass 17→18. Their empty-pass branch growth was already reviewed; neither changes in this interdiff.
Silent failure: 0 new sites. Both narrowed methods retain named errors; invalid id ranges reach callers as GpuError::Shape.
Tests: no new or changed tests. Existing assertions reject a dropped retained-prefix/parked-count check, shifted id slice, or removed arena bound. Static mutation review only; tests were not run here.
Gates: no pins or clauses changed. The body reports the exact-base canonical move proof.
Adversarial checks: no external caller needs the narrowed methods; empty/reversed ranges and a misplaced retained slot 0 retain their guards.
Performance: visibility and documentation edits add no per-token work.
Escape catalog: C1–C4 do not match.

Notes

The body reports host tests and no available NVIDIA device. It contains no card gate run meeting CONTRIBUTING's evidence list; GPU evidence is false.

Card check: needs-gpu. This pull request changes crates/gpu-glm5next/src/pair.rs, crates/gpu-mimo2/src/slots.rs, crates/gpu/src/arch/qwen3moe/body35_slots.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)

@Burntgogi

Copy link
Copy Markdown
Contributor Author

Final cross-change compatibility check (not a GPU runtime claim): the tested combined source tree is exactly the conflict-free merge of final public heads 78a2594904a4cd7dc37adfe49b284dc39c3d87dc and 43a15006d10365452f54ec422d512b3da8a23d1b.

git merge-tree --write-tree 78a2594904a4cd7dc37adfe49b284dc39c3d87dc 43a15006d10365452f54ec422d512b3da8a23d1b
04a918993c5bbd335844ca3ce0a023a37be5dc0f

Local test commit 6e0041f1ca8eb816db9f32f37c3c4e0f02ea39f0 has that same tree; no unpublished source difference is hidden in this combined check. This includes the already-landed context guard, CLI/Metal startup correction and typed router policy, plus both final refactor review corrections.

Actual combined checks: Held 2/2, slot contracts 2/2, real SlotPass 1/1, actual owning just gate-app 27/27. The rebuilt real generate_qwen3moe executable accepts all ten option-shaped prompt values as data and reaches its named n=0 refusal after tokenization; genuine --levers and --records-schema still exit 0 with byte-identical SHA-256 outputs to the baseline. Authenticated sparse metadata inputs are plan/tokenizer-only; no weight inference is claimed.

Direct complete comparison of the final combined snapshot:

fc0537b6..6e0041f1
canon-check: 4 bins, 1448 entries: 1448 identical, 0 reordered-only, 0 differs, 0 only-on-one-side; rows equal (jit columns not compared: no-jit both)

All 8 kernel carriers are covered. This composition check supplements, not replaces, each PR's direct reviewed-base proof or its still-unrun physical GPU/graph gates.

@juliankang4
juliankang4 merged commit a3353a0 into midagedev:main Oct 24, 2026
8 checks passed
@juliankang4

Copy link
Copy Markdown
Collaborator

@Burntgogi Thanks for the contribution. The review is done, so I'm merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 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.

2 participants