Repository navigation
lab: add contributor-owned native HIP operator checks - #248
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: The verifier can report success using a stale host binary, and the context has a redundant marker field.
Must fix
1. Reject target overrides before selecting the host artifact
labs/hip-native/verify.py:125 An inherited CARGO_BUILD_TARGET set to the native triple sends the new host build to target/<triple>/release/. This code still executes target/release/bloomery-hip-spike. A previous binary at that path can pass all cases and be recorded against the current HEAD; the final hash check only proves that old binary stayed unchanged.
Cost: Fix this before verifier results are used as merge evidence.
Insert this guard beside the existing encoded-flags guard, before any build:
if os.environ.get("CARGO_BUILD_TARGET"):
raise RuntimeError("unset CARGO_BUILD_TARGET; verification assumes native host artifact paths")2. Remove the redundant thread marker
labs/hip-native/host/src/main.rs:57 The existing *mut c_void fields already make Context neither Send nor Sync. The PhantomData<Rc<()>> field, its initializer, and both imports add no constraint. This violates the fewest-elements requirement.
Cost: Removing them now is a five-line deletion with no API change.
Remove the PhantomData and Rc imports. Use this struct and initializer:
struct Context {
module: *mut c_void,
stream: *mut c_void,
buffers: Vec<*mut c_void>,
} let mut s = Self {
module: std::ptr::null_mut(),
stream: std::ptr::null_mut(),
buffers: Vec::new(),
};Non-blocking
⚠ Pin the divisibility check independently: labs/hip-native/host/src/main.rs:470. Deleting !k.is_multiple_of(256) at line 168 leaves every assertion green: K=255 fails the weight-length check instead. Replace the tuple with (257, 1, 1, 144), so that mutant turns red before kernel work.
Checked
Duplicates: the marker repeats constraints already supplied by the raw-pointer fields. No dryer pairs were available.
Complexity: diagnostics report new dense_ffn (41) and case (25), both combining setup, launches, and reference checks.
Silent failure: two NMSE denominator floors and four ignored HIP cleanup statuses read. Work-path HIP errors and nonfinite results return named failures.
Tests: static branch analysis confirms the divisibility mutant survives every current shape assertion; the suggested tuple detects it.
Gates: fixed NMSE <= 1e-6 is new; no existing pin or gate was relaxed in this diff.
Escape catalog: C1–C4 do not match.
Notes
dryer did not run because no changed Rust file is under crates/.
Builds and GPU tests were not run. The linked HIP result JSON is outside the supplied trees. The PR body includes no FAIL-first output for the new numerical gate.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| fn refuses_invalid_shapes_and_truncated_weights() { | ||
| for (k, r, c, w) in [ | ||
| (0, 1, 1, 0), | ||
| (255, 1, 1, 144), |
There was a problem hiding this comment.
K=255 still fails the byte-count check when the divisibility guard is removed; K=257 with 144 bytes isolates that guard.
| (255, 1, 1, 144), | |
| (257, 1, 1, 144), |
|
Addressed both must-fix items in a0d81f0. The verifier rejects CARGO_BUILD_TARGET before any build, explicitly selects rustc's host triple for every host command, and executes that triple's artifact path. PhantomData/Rc and the redundant marker are removed. Also changed the divisibility fixture to K257: deleting that guard now fails. Negative controls show target-override refusal with zero builds, and a separate local doubled-output kernel mutant fails the actual GPU comparison at NMSE0.999999753388892. The mutant is not in this PR. The corrected clean head passes all seven checks and six GPU cases, with new JSON/binary hashes. Exact-head result and negative controls. The dependent operator draft #252 was rebased and again passes18 cases. CI/review have been triggered on the corrected heads. |
There was a problem hiding this comment.
Since the last review:
- Target override finding: fixed. labs/hip-native/verify.py:109 rejects inherited targets; host commands and artifact selection use the same explicit triple.
- Redundant marker finding: fixed. labs/hip-native/host/src/main.rs:50 retains raw-pointer fields that prevent
SendandSync. - Independent divisibility test: fixed. labs/hip-native/host/src/main.rs:465 uses K=257 with an otherwise matching weight length.
Verdict: CLEAN: The earlier findings are resolved, and the incremental changes introduce no proven defect.
Checked
Duplicates: 0 new function, type or constant definitions; the redundant field and imports are removed. No dryer pairs were available.
Complexity: crapper flags dense_ffn (41) and case (25), both unchanged in this increment; no new growth to assess.
Silent failure: 0 new fallback sites. Target rejection reaches the failed-result handler and nonzero exit; missing artifacts also fail through the existing handler.
Tests: Python syntax and isolated verifier statements passed for synthetic x86_64 and aarch64 Linux triples, checking all three host commands, artifact paths and rejection before builds. Static mutation check: dropping the divisibility clause at host line 163 makes K=257 return Ok((1028, 4)), so line 470 fails.
Gates: no numerical band or pin moved; the changed shape case independently pins divisibility. No kernel or engine hot path changed.
Escape catalog: C1–C4 do not match.
Notes
dryer did not run because no changed Rust file is under crates/.
Builds and GPU tests were not run. The PR reports a doubled-output negative control; linked HIP results and logs are outside the supplied trees and were not read.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
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.
Rebase only the selected follow-up after merged #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.
What and why
Adds the contributor-owned
labs/hip-native/requested in #87. Its excluded workspace compiles Rust AMDGPU kernels, loads their ELF through HIP, and checks Q4_K × F32 and a synthetic dense FFN against the existing GGUF dequantizer with FP64 accumulation. The root manifest gains only the lab exclusion; CUDA members, dependencies, pins and release paths are unchanged.This initial operator lab does not yet port the original selected GEMV/Q8 activation path or execute a model. That follow-up remains a separate change. No libllama or alternate serving/model loop is introduced.
Validation
Base
e98d6c43f95bc75475cadaf1043c1735962dcc5d; exact source heada0d81f0667f197625f6a7ff0736e50b8a1d2fe88; full treef5c390b1d61b07fc8d6089cc0ae94962f3c7d2ae.verify.sh: fmt, host test, host/device clippy with warnings denied, both release builds, and all six GPU cases passed.Exact-head result JSON, all verification logs.
The four default synthetic cases need no model. Optional fixture: unchanged rows0..64 of
blk.1.ssm_out.weight, K6144, fromQwen3.8-27B-GSQ-RCO-IQ3_S-mtp.gguf, source SHA25658fd826723939933dc86f45b7fe04545cbc2de1c70f6fe2cdd3858c87a98c12f. Fixture SHA2569251b422a700bf27bf47512068c93f88d029dc6eba32ed516dbc067842b570ce, 221184bytes. No weights are included.Code shape
Owner: @Burntgogi. Release note: contributor AMD operator lab; no change to released engine support or performance claims.
Review corrections: CARGO_BUILD_TARGET is rejected before builds; host tests/lint/build and output paths use the explicit rustc host triple. The redundant PhantomData/Rc marker is removed. K257 independently pins divisibility. Negative controls show target override refusal, divisibility mutation failure, and an intentionally doubled-output GPU mutant failing at NMSE0.999999753388892. The correct PR head passes all six cases.