Repository navigation
Description
I would like to contribute a native AMD path that keeps Bloomery's Rust model/session owners. On one RX 7900 GRE, an isolated Rust device/host prototype now loads an AMDGPU ELF through HIP and passes Q4_K and FFN numerical checks. This is operator feasibility evidence; it is not a native Bloomery model forward, a complete transformer block, or serving throughput.
Source: Rust HIP lab, commit 3a17df85, based on main 1cba9707. It is excluded from the default CUDA workspace. Both device and host code are Rust; the CPU reference uses Bloomery's existing GGUF dequantizer with FP64 dot accumulation. The earlier Bloomery HTTP/libllama adapter uses a different model forward and is not this native backend proposal.
Hardware/toolchain
- RX 7900 GRE, 16 GiB,
gfx1100; i5-12600K; 64 GiB RAM. - Repository-pinned
nightly-2026-08-28,rust-src, targetamdgcn-amd-amdhsa; Rust GPU-kernel ABI and LLVM AMDGPU code generation. - HIP runtime from the local ROCm SDK. Package versions inspected at publication:
rocm-sdk-core,rocm-sdk-devel,rocm-sdk-libraries-gfx110X-dgpuall7.10.0a20251120(Python distribution versions, not an official-release claim). - Each kernel uses a 64-thread workgroup. The Rust host owns the module, stream and buffers on one thread and synchronizes before destruction.
Measured numerical results
The fixed acceptance is finite outputs and NMSE <= 1e-6. Activations are F32. Reference weights are the same packed Q4_K bytes, dequantized with Bloomery's CPU reader.
| case | K / output rows / input columns | NMSE |
|---|---|---|
| synthetic Q4_K | 256 / 7 / 1 | 3.702660797383163e-14 |
| synthetic Q4_K | 512 / 64 / 1 | 1.375607993838801e-12 |
| synthetic Q4_K | 512 / 64 / 32 | 6.689703539606927e-13 |
| actual 27B projection slice | 6144 / 64 / 1 | 2.331305569619408e-12 |
| actual 27B projection slice | 6144 / 64 / 32 | 2.0990081683686894e-12 |
| synthetic dense FFN | width 256 | 7.959878245021427e-14 |
The real slice is blk.1.ssm_out.weight from Qwen3.8-27B-GSQ-RCO-IQ3_S-mtp.gguf: 64 rows, Q4_K, K=6144; slice SHA256 9251b422a700bf27bf47512068c93f88d029dc6eba32ed516dbc067842b570ce. It does not stand for the whole model's mixed quantization.
The copy checks are bit-exact. Three repeated launches reuse explicit buffers. The FFN chain is RMSNorm → gate/up → SwiGLU → down → residual, with no intermediate host copies. Allocation counts cover buffers this host explicitly issues, not driver internals. The prototype does not reproduce the CUDA body's Q8 activation scratch or quantized-dot order, so no CUDA/HIP bitwise or generated-token equivalence is claimed.
Reproduction/evidence
Lab build/run commands, six-case result JSON, and evidence index include the source/binary hashes and build/test logs. No model weights or extracted weight binaries are uploaded. Host shape refusals, host/device clippy, formatting and comment checks passed. Rust target documentation describes this tier-3 target.
Would a Rust-native HIP backend be within the project's scope? If so, I propose first agreeing a backend boundary for buffers/windows, streams/events, launches and capture that keeps GpuModel/app::Session, model forward, expert placement and state owners. Then match the activation layouts and attach attention/GDN, state reset/checkpoints and one complete block before a whole forward or performance claim. HIP would be the first target; Vulkan is not validated by this experiment. The existing CUDA kernels, PTX/module loading and capture need a deliberate port and must retain their gates.
I can continue this path once the intended boundary and kernel/toolchain policy are settled. The published snapshot preserves the tested base; it is not presented as rebased on today's main.
Activity
midagedev commentedon Oct 12, 2026
Thank you. The operator results and their conditions are clear, and the lab is outside the CUDA workspace. Whether and how a HIP backend fits the tree is a design call for the maintainer. We will answer here in our morning (KST).
midagedev commentedon Oct 12, 2026
Thank you for the careful operator work and the clear evidence boundary.
We will not take a HIP backend into the tree now. A second device backend doubles the kernel, gate and release work, and the current tree is still CUDA-only by design. Please keep the lab in your fork. This issue stays as its record and link.
If a native AMD path becomes a goal later, these Q4_K and FFN operators and their checks are the starting point. We will say so here first.
midagedev commentedon Oct 12, 2026
화이팅이요!!
midagedev commentedon Oct 12, 2026
We would like to take this in. Since we have no AMD card, your card is the gate, and we check what we can.
labs/hip-native/, excluded from the workspace, so the CUDA build and release are unchanged.verify.shthat runs your checks and writes a result JSON: source tree hash, binary hashes, card, ROCm version, and each case's result. Each PR carries that JSON from its head commit. We check that the hash matches, and run fmt, clippy and the comment check on our side.Next steps, at your pace:
crates/gpu/src/kquant/sel.rs) for gfx1100 through a thin shim, and pass your checks.This replaces our earlier answer. (Reply drafted with AI help.)
midagedev commentedon Oct 12, 2026
제가 어서 amd gpu를 저렴이라도 들여야겠어요 ㅎㅎ 검증이 일이라! 일단은 검증을 해주시는 방향으로 제안드려 봅니다. 잘 부탁드립니다!
Burntgogi commentedon Oct 14, 2026
Rebased once more onto the latest common-context changes, and reran the exact-head verification (the earlier source/result snapshot remains in the evidence branch history). Implemented the requested initial lab against main
ae09980c1754dfb01fbeff6f642b9c0c53ecf30f, and reran its GPU checks on the exact source head.f7cb7d92951a02aae985269f8d3da9d30d86673a; repository tree:97acd6c5e414cbaa3bfc960969549f238c716d4d.labs/hip-native/is an excluded nested workspace. Parsed root-manifest comparison and Cargo metadata confirm unchanged CUDA workspace members/dependencies/pins, with only the added lab exclusion.verify.shchecks clean source, fmt, host tests, host/device clippy with warnings denied, both release builds, and the numerical GPU cases. It writes HEAD/tree, binary SHA-256, actual device/runtime, per-command logs and per-case JSON outside the checkout. The dirty-source refusal was exercised too.gfx1100), pinned nightly 2026-08-28 / LLVM 23.1.0; HIP runtime/driver API version70253210. All six cases passed the unchanged NMSE <= 1e-6/finite band; largest NMSE2.331305569619408e-12. They include real Q4_K rows at K=6144, 1 and 32 activation columns, and the synthetic dense FFN. The existing Strata process remained running; no speed claim.Exact-head result JSON, logs and source artifacts, readable patch series. The Git bundle preserves the exact commits named by the JSON; it requires base
ae09980cand passesgit bundle verify. No model weights are published. The optional fixture is rows 0..64 ofblk.1.ssm_out.weight, K=6144, fromQwen3.8-27B-GSQ-RCO-IQ3_S-mtp.gguf(source SHA-25658fd826723939933dc86f45b7fe04545cbc2de1c70f6fe2cdd3858c87a98c12f). Its packed bytes have SHA-2569251b422a700bf27bf47512068c93f88d029dc6eba32ed516dbc067842b570ce; default synthetic checks need no external file.Publication blocker: opening the implementation PR is currently blocked by my CLI OAuth token lacking
workflow. GitHub rejected both the branch push and its supported fork-sync endpoint because the fork predates upstream.github/workflows/labels.ymlchanges. I have not changed upstream workflows. The evidence branch above only adds artifacts to an already-published fork history, so its upload succeeded. I have requested authentication refresh and will open the implementation PR when it is available; this artifact report is not an implementation PR.Scope remains the agreed initial operator lab. Its scalar Q4_K × F32 kernel is not the original CUDA selected GEMV/Q8 activation port, and no full-model forward/token equality/native AMD serving is claimed. Next: existing selected GEMV through a thin shim, then identical-file full-model comparison, then the backend boundary discussion, in the order you requested. I will own the lab.
midagedev commentedon Oct 15, 2026
Thanks for the thorough write-up. You kept to the agreed operator-lab scope, and the unchanged CUDA workspace check plus the exact-head evidence make it easy to review. The next steps you listed (existing GEMV through a thin shim, then a same-file full-model comparison, then the backend boundary discussion) sound good.
The push rejection looks like the fork predating the upstream workflow changes, so refreshing the token or re-syncing the fork should clear it. When you open the PR, please rebase it onto the latest main. We're wrapping up the 0.3.3 release right now, so review may slip a little until that's out.
(Comment written by the bloomery AI assistant.)
Burntgogi commentedon Oct 15, 2026
Implemented the next agreed operator experiment: the original selected Q4_K down walk through a small HIP shim.
The source imports nine arithmetic functions directly from
crates/gpu/src/cores.rsat build time, with a source-drift check. The shim preserves Q8 activation planes, the selected row/slot relationship, 256-thread blocks / logical warp32 XOR reduction, explicit CUDA-contract FMA order, HOST skips and sticky fault word/layer masks. The existingqdot::card_q8_1_scalarprepares activations on the host; the existingcard_q4k_dot_row_scalaris the bitwise oracle. Device activation quantization remains a later step.Rebased both the initial lab and this separate follow-up onto main
5e837723d31cf860088c96197ba4be52d47c3c3d. Follow-up source headce87db9ac79c8e9b8658578b2b0289498c326119, tree6cb5112e68870bd117126a15b166771035d81eda; only nine lab files differ from the initial lab. Root workspace/pins/release paths are preserved.Exact-head verification on RX7900GRE/gfx1100 passed all seven command checks and 18 GPU cases: the unchanged six scalar/FFN cases plus twelve selected cases, 108 selected launches. They cover K256..20480, actual K6144 packed rows, partial block rows, duplicate/reordered IDs, distinct/zero/subnormal activation columns, NaN-scale propagation, HOST sentinels, invalid IDs and earliest-layer sticky faults. Every finite selected output is bit-identical to the existing host oracle; the compiled wave probe is32. This is host-oracle/HIP equality, not a measured CUDA/HIP runtime or whole-model/token comparison. No performance number; the existing Strata service stayed running.
Exact-head verification JSON, source bundle/patch, generated original arithmetic and all logs. No weights are included. Bundles preserve the source commits and require base5e837723.
The initial lab's new head is
0edd7afb0b96caaa80dee55f5c2679d8374e7cdc; its own six-case JSON is separately attached. Implementation PR publication is still waiting for GitHub CLI's device authorization to return a token withworkflow; the first code expired and the refreshed flow is pending. The evidence branch uses already-published history, so both implementations remain reviewable meanwhile.Ordered stages1–5 plan and whole-forward/runtime audit. A SHA-verified ordinary Qwen3.5-0.8B candidate is prepared for the later whole-forward experiment; its tied Q8_0 embedding/head is an explicit dependency. No backend boundary or native AMD serving support has been added yet.
Burntgogi commentedon Oct 15, 2026
The GitHub authorization blocker is resolved. The initial contributor lab is now a real implementation PR: #248, head
dac2c4e6e3b7f20a3ccaf90c0058e66639c01116, rebased on maine98d6c43. Its exact-head six-case HIP verification and root checks passed; the PR links the JSON/logs.The original selected-Q4 experiment is separately reviewable as draft #252, depending on #248. Head
4c35e4f0625adb61ba5acffe59352e3db0762c87passed all seven verifier checks and18 GPU cases, including12 selected cases/108 launches. It retains host Q8 preparation and bitwise comparison to the existing qdot oracle; this is still operator evidence, not CUDA/HIP runtime or whole-model equivalence. No speed result is claimed.Current exact-head evidence, concrete AMD whole-forward dependency/port plan. The latter maps the exact0.8B candidate's Q6/Q8, embedding/head, GDN, attention, arena and CUDA resource dependencies before proposing a common backend boundary.
The ordered continuation is initial PR review → operator follow-up → the agreed A6000 dense validation → AMD full-forward/common Session integration → matched serving benchmarks. The existing Strata service has not been stopped, and native AMD model serving remains unfinished.
midagedev commentedon Oct 20, 2026
Thank you for #476. We read it against our code-shape rules (
docs/rust-quality.md) and AGENTS.md. It holds up well: one// SAFETY:perunsafeblock,unwraponly in tests andbuild.rs, no comment-rule hits, named refusals, one shared NMSE gate, and it reuses the common readers. Production code is untouched.Two problems are on our side:
regexto a crate the lab uses. YourCargo.lockis now stale, soverify.py(--locked) fails on current main. The host crate still checks clean without--locked. We will refresh the lock.Small notes, none blocking:
host/build.rsreadsFIT_RESERVEout ofcrates/gpusource as text. We can move the constant into a crate the lab can depend on.Plan::open(~215 lines) andrunner::step(~200) are long for R12. The probes have ~70 uncheckedas u32casts (R5).#![allow(internal_features)]indevice/src/lib.rshas no reason (R16).#476 said it does not close this issue, but GitHub closed it at merge. Should we reopen it?
(Drafted with AI help.)
Burntgogi commentedon Oct 20, 2026
Yes, please reopen #87 as the tracking issue for the excluded HIP lab and the next backend-boundary discussion.
#476 completed the agreed full-forward comparison for the pinned model and fixed prompts documented in the PR. It did not add a production HIP backend, Session integration, or native serving support.
Thank you for refreshing the lab lock and adding the lab lock/format checks to t0. I saw those changes on main; I am not treating the earlier GPU evidence as verification of the latest main.
I will keep the non-blocking R5/R12/R16 notes as a separate lab follow-up, with fresh exact-head evidence for any changes. For FIT_RESERVE ownership and the backend boundary, I would like to agree the scope here before changing the production backend interface.
My next planned contributions are #530, followed by #528, as separate PRs. Thank you again for reviewing and maintaining the integration.