Skip to content

lab: port the original selected Q4_K walk through HIP wave32 - #252

Merged
juliankang4 merged 3 commits into
midagedev:mainfrom
Burntgogi:contribution/hip-q4-selected-20261015
Oct 16, 2026
Merged

juliankang4 merged 3 commits into
midagedev:mainfrom
Burntgogi:contribution/hip-q4-selected-20261015

Conversation

@Burntgogi

@Burntgogi Burntgogi commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Selected Q4_K down-row walk through the existing excluded AMD HIP contributor lab. Parent #248 is merged. This PR merged source eaa04a5e1ce69347f3a78569c9c2052eb5d2e337 as e195c9e6af40372d56543c779f52222e3cf5955e while the subsequent current-main validation was running.

The lab extracts nine original functions from pinned crates/gpu/src/cores.rs at build time and refuses source drift. The HIP shim preserves packed Q8 planes, row/slot addressing, 256-thread blocks with logical warp32 reduction, original FMA order, HOST skips, sticky earliest-layer faults and per-layer masks. Existing qdot scalar routines prepare activations and provide the oracle. No engine/CUDA kernels or numerical bands changed.

Review correction: upload allocates once and reuses the existing fallible overwrite transfer/synchronization owner; the duplicate copy path is removed.

Merged-head and subsequent rebased validation evidence

The merged head eaa04a5 passes all 7 verifier checks/18 actual GPU cases, including the restored control linked below. Separately, the subsequent branch on main cca9bea, source 3395e11d3c8e5f8a90dde16b1459883f54b953d5, tree 6df2410d1a35442f17fd0c3207e7187dc520cf72, also passes all 7/18 in a clean checkout. 3395e11 is not the PR's merged head. Hardware: RX7900GRE / gfx1100 / wave32; HIP runtime and driver 70253210.

  • Seven verifier checks passed: format, host tests, warnings-denied host/device clippy, device build, host build, actual GPU execution.
  • All 18 GPU cases passed. Existing scalar/FFN cases retain finite/NMSE <= 1e-6; selected cases retain bitwise finite results, NaN propagation and exact fault/mask/sentinel contracts.
  • Includes K=6144 packed rows (64 rows), SHA-256 9251b422a700bf27bf47512068c93f88d029dc6eba32ed516dbc067842b570ce. No weights uploaded.
  • Existing Strata service was not stopped or changed. No throughput, whole-model AMD support, generated-token or serving result is claimed.
  • Real HOST negative control: removing only the HOST exemption leaves the six preceding verifier checks green, then actual GPU execution exits 1 at the unexpected expert-id fault. Restoring clean eaa04a5 passes all 7 checks/18 cases again; the final rebased 3395e11 independently passes all 7/18.

Final exact-head result and all verifier logs · HOST mutant result/log/patch · restored control.

Command (SDK environment as recorded in the logs):

labs/hip-native/verify.sh /absolute/new/evidence-directory \
  --q4-rows /absolute/Q4_K.bin --k 6144 --rows 64

Merged head eaa04a5 is preserved on Burntgogi/bloomery:archive/hip-selected-before-current-main; the original pre-rebase head remains on archive/hip-selected-before-20261016. The later 3395e11 validation branch is retained separately. This is a bounded operator lab, not an AMD inference backend.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 15, 2026
@Burntgogi
Burntgogi force-pushed the contribution/hip-q4-selected-20261015 branch from 4c35e4f to 0d534cd Compare October 15, 2026 07:28
Rebase only the selected follow-up after merged midagedev#248. All nine extracted bodies, the selected entry, and the two scalar oracle entry bodies are unchanged from the arithmetic baseline; only unrelated core helpers changed. Build, lint, tests and GPU verification intentionally unrun for coordinated final verification.
@Burntgogi
Burntgogi force-pushed the contribution/hip-q4-selected-20261015 branch from 0d534cd to b3774b8 Compare October 16, 2026 19:13
@github-actions github-actions Bot removed the tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo label Oct 16, 2026
@Burntgogi
Burntgogi marked this pull request as ready for review October 16, 2026 19:15

@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 new upload helper duplicates the typed host-to-device transfer owner.

Must fix

1. Reuse overwrite for initial uploads

labs/hip-native/host/src/selected.rs:85 repeats labs/hip-native/host/src/selected.rs:95: the same typed source, byte span, transfer direction and error propagation. This is a kind B duplication under R14.
Reuse removes an unsafe copy site and its repeated invariant now, without adding an owner. Replace upload with:

fn upload<T: Copy>(context: &mut Context, values: &[T]) -> Result<*mut c_void, String> {
    let ptr = context.alloc(std::mem::size_of_val(values))?;
    overwrite(context, ptr, values)?;
    Ok(ptr)
}

Non-blocking

⚠ Record FAIL-first evidence: labs/hip-native/device/src/selected.rs:113. The body reports passing runs but no failing mutant run for the new contracts. Temporarily replace id != u32::MAX with true; the isolated HOST case must fail. Record that failure and the restored pass while this change is under review.

Checked

Duplicates: upload and overwrite repeat the same typed transfer; the proposed fix reuses overwrite.
Complexity: new case = 52 combines setup, selection runs and fault checks; new Plan::validate = 22 checks dimensions and spans. run rises 14 → 16 through two fallible calls.
Silent failure: 3 refusal paths followed. Source drift panics, invalid expert ids raise faults, and refused activation scales propagate NaN to an explicit check.
Tests: static inspection confirms short-span assertions reject dropped span checks. Removing the HOST exemption reaches the unexpected-fault rejection at host/src/selected.rs:343. GPU tests were not run here.
Gates: NMSE remains 1e-6; bitwise, sentinel and fault checks are added. No existing pins moved.
Escape catalog: no matching patterns.

Notes

dryer did not run because no changed Rust file is under crates/.
The linked GPU result and logs are outside the supplied trees and were not inspected.

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

@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 incremental change removes the duplicate transfer and preserves its behavior.

Checked

Duplicates: 0 new items; the transfer now has one owner. No dryer pairs were supplied.
Complexity: diagnostic flags concern unchanged functions; this diff adds no branches.
Silent failure: 2 fallible calls followed; allocation, copy and synchronization errors propagate. Empty uploads still return the named zero-allocation error; failed uploads remain owned by Context.
Tests: no tests or assertions changed. No build or GPU tests were run.
Gates: no bands, pins or assertions changed.
Escape catalog: no matching patterns. Only standalone lab setup changed; no engine hot path changed.

Notes

dryer did not run because no changed Rust file is under crates/.
The linked GPU result and logs are outside the supplied trees and were not inspected. The body identifies source b3774b8, not the current head.

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

@juliankang4
juliankang4 merged commit e195c9e into midagedev:main Oct 16, 2026
6 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants