Skip to content

gpu: share Held positions and read validation - #774

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

juliankang4 merged 2 commits into
midagedev:mainfrom
Burntgogi:refactor/issue581-held

Conversation

@Burntgogi

@Burntgogi Burntgogi commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Scope

Fixes #581 (the remaining Held positions slice). Implement the approved Held position/read-check owner only; Qwen and GLM keep their program-owned Wrote tables and arena enums.

  • gpu::draft::Held owns NONE/at/cut/parts/holds, checked read admission, and overflow-safe rendering.
  • Remove Qwen Held38, its re-export/private read checker/formatter, and GLM's private Held/read-check copies. All mapped consumers use the common owner directly.
  • Snapshots retain the original Held; Wrote38 accepts the sole caller's existing u32 row count instead of reconstructing/clamping it.
  • Checked row and position arithmetic refuses stale, over-capacity, and overflowing reads as named Shape errors. No kernels, launches, graph construction, or numeric operations are changed.

Observed host verification

  • cargo oxide test --arch sm_86 -- -p bloomery-gpu --release --lib draft::tests:: -- --nocapture: 2 passed.
  • A temporary actual compiled consumer exercised Held/cut/read admission, stale reads, capacity refusal and positions crossing u32 width without CUDA initialization. Valid Held (42, 2) remained readable; stale and overflowing reads reached their named consumer errors. The temporary example was removed.
  • Actual owning just gate-app through the local box/gate wrappers: 27 passed, 0 failed, 0 ignored.
  • Formatting and comment checks passed. Existing docs/research/headpick.md documents the common owner.
  • just pre-review exits 75: no Claude CLI is installed, so nothing was reviewed.

Device-runtime limit

This host has no NVIDIA device/driver or configured remote GPU. No eager/captured GPU execution, graph operand/order/count comparison, or numerical/card-gate PASS is claimed. The host owning gate-app passed. The device owning gates include gate-gpu-qwen4exp-mtp, gate-gpu-glm5next-mtp, and gate-gpu-lib. The full official affected/narrowed gate list remains applicable; the named gates are not a substitute for that full list. This PR needs the applicable hardware evidence before landing.

Final reviewed-base move proof

Addressed the actual review on aad5417c in 78a2594904a4cd7dc37adfe49b284dc39c3d87dc:

  • The moved read contract now links Held::check_read; no check_target_rows, Held38 or held_shown reference remains in the affected source/docs.
  • Added an isolated physical-capacity regression: Held::at(1, 1), capacity 0, read (0, 1), pos0 2. Held/position checks are valid. Removing only .filter(|&end| end <= rows) makes the actual test FAIL (exit 101, a held row outside the arena: ()); restoring that guard makes both production Held tests PASS (2/2). The temporary mutant was removed before commit.
  • Rebased onto the exact requested review base, not an older comparison point.

Direct final-snapshot proof:

bash tools/canon-check.sh fc0537b6fb821beda085998718a7b44c9b8eb686 HEAD --out /home/jutai05/bloomery-contributions/ordered-767-764-xcg1_b67/581-canon-fc
narrow-scan: fc0537b6..78a25949
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 directly checks the reviewed delta, separately from the earlier 8d91214 and combined-tree results. Formatting/comment checks passed. Required local pre-review still exits 75 (no Claude CLI; nothing reviewed).

Hardware limit remains: no NVIDIA device/driver or configured remote GPU is available. GPU graph-node/operand/eager-replay/card gate results cannot be supplied here and are not inferred from identical PTX. The host owning app gate passed 27/27; that is not a GPU graph proof. Fresh official narrowing against these exact fc/base and final/head pairs retains 77 of 227 recipes (from 157), with all four scan pairs identical. No gate, pin, threshold or skip list was relaxed.

@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: the validator move leaves a contract comment pointing to a deleted function.

Must fix

1. Point the read contract to its new owner

crates/gpu/src/arch/qwen3moe/mtp38.rs:1635 still names check_target_rows, which this PR deletes. The actual validator is now Held::check_read.
Repairing the reference with the move keeps the validation contract discoverable. Replace that comment line with:

    /// the rows' ([`Held::check_read`]), media rows.

Non-blocking

⚠ Capacity refusal is not isolated by the test: crates/gpu/src/draft.rs:346. Deleting .filter(|&end| end <= rows) at line 279 leaves both tests passing. Other guards reject every invalid case. Add this assertion after let held and show FAIL-first against that mutant; it isolates the capacity guard:

        assert!(held.check_read(WHAT, "Step", 0, (0, 1), 2).is_err());

⚠ Attach the move proof against this PR's base: crates/gpu/src/arch/qwen3moe/mtp38.rs:1683. The reported scan starts at 8d912142, while the review base is fc0537b6. The move class requires identical scans and preserved host dispatch structural checks. Verify the reviewed delta before relying on the cached result; attach the output and graph-node/eager-replay checks:

just canon-check fc0537b6fb821beda085998718a7b44c9b8eb686

Checked

Duplicates: 11 new/moved items checked; no duplicate owner remains. Dryer's one pair maps different program-owned arena enums; sharing it requires extra abstraction.
Complexity: crapper flagged no changed functions.
Silent failure: 3 sites followed. Failed conversion and read admission reach named Shape errors; cut saturation discards revoked rows.
Tests: static mutation review. Changing line 245's <= to < fails the first test; dropping line 294's held-range guard fails the second. Removing line 279's capacity filter survives.
Gates: no pins moved; the two arithmetic tests were relocated and extended.
Performance: decode/prefill read admission adds no successful-path allocation, launch, copy or synchronization.
Adversarial checks: stale rows after cuts or sequence swaps, row overflow, position overflow and snapshot bounds are rejected before copying.
Escape catalog: no patterns matched.

Notes

Tests and scans were not rerun during this source review. The PR explicitly reports no device execution; card-gate evidence is absent.

Card check: needs-gpu. This pull request changes crates/gpu-glm5next/src/body.rs, crates/gpu-glm5next/src/nextn.rs, crates/gpu-glm5next/src/pair.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/draft.rs
#[test]
fn target_reads_refuse_unheld_or_overflowing_ranges_before_copy() {
const WHAT: &str = "draft read";
let held = Held::at(1, 1);

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.

Isolate arena capacity so deleting its guard fails this test.

Suggested change
let held = Held::at(1, 1);
let held = Held::at(1, 1);
assert!(held.check_read(WHAT, "Step", 0, (0, 1), 2).is_err());

@Burntgogi
Burntgogi force-pushed the refactor/issue581-held branch from aad5417 to 78a2594 Compare October 24, 2026 13:20
@Burntgogi

Copy link
Copy Markdown
Contributor Author

Addressed the actual review in 78a25949: fixed the validator contract link and isolated the capacity guard with a real FAIL-first/PASS-after regression. Rebased to the requested fc0537b6 and completed the direct full scan-set comparison for this exact final revision; detailed commands, outputs and the unchanged GPU-hardware limit are now included directly in the PR body (not only behind an evidence link). The fresh official narrowed list retains 77 recipes.

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

  • Fixed: the read-contract link now names Held::check_read at mtp38.rs:1635.
  • Fixed: the capacity assertion isolates the missing guard at draft.rs:348. The body reports FAIL-first against its removal.
  • Partly fixed: the exact-base move scan is supplied. Host graph-node and eager/replay checks remain open at mtp38.rs:1683; the author states the hardware limit.

Verdict: CLEAN: the previous must-fix is resolved, and the interdiff adds no proven defect.

Non-blocking

⚠ Complete the host dispatch move proof: crates/gpu/src/arch/qwen3moe/mtp38.rs:1683. The reported exact-base canon scan establishes identical PTX. The move class also requires preserved graph-node counts, eager/replay behavior and the end-to-end set. Attach those owning-gate outputs when hardware is available to complete validation before merge.

Checked

Duplicates: 0 new definitions in the interdiff. Dryer's pair was read; the two tables map different program-owned arena enums and require no shared abstraction.
Complexity: crapper flagged no changed functions; the interdiff adds one assertion sequence.
Silent failure: 0 new sites. The isolated over-capacity read reaches a named Shape error before copying.
Tests: static mutation check of draft.rs:279. Removing only the capacity filter admits the new input, so expect_err at line 349 fails. The PR reports the compiled mutant failing and both restored tests passing.
Gates: no pins, thresholds or cases removed or relaxed.
Adversarial checks: valid held positions with zero physical capacity are rejected; stale and overflowing reads remain guarded. The new hunk changes no production execution.
Escape catalog: no patterns matched.

Notes

Rust tests and scans were not rerun during this source review. The PR explicitly reports no device execution and carries no card-gate evidence.

Card check: needs-gpu. This pull request changes crates/gpu-glm5next/src/body.rs, crates/gpu-glm5next/src/nextn.rs, crates/gpu-glm5next/src/pair.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 9d74e3b 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.

Draft walk: lift the remaining per-model draft types into one owner

2 participants