mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4766] [Engine] gfx906: build dflash2 for Radeon VII #5172
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5172
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4766
Author: @nfriedly
Created: 10/31/2026
Status: 🔄 Open
Base:
main← Head:gfx906-dflash2-hip-guards📝 Commits (1)
df51f76gfx906: test STRATA_HIP_GFX906 in the dflash2 stream guards📊 Changes
1 file changed (+2 additions, -2 deletions)
View changed files
📝
src/core/dflash2.cpp(+2 -2)📄 Description
This is an extended version of #3986 (2-line change instead of 1-line, lol), related to #4156. It was necessary to build for my dual-Radeon VII system, otherwise it was taking a CUDA branch and failing.
(I believe that just setting STRATA_USE_HIP=1 would turn on other things that the Radeon VII doesn't support.)
agent-written details below.
Edit: I just noticed the agent referenced several log files. They're probably still on my system, so I can attach them here if requested. Also, this was done with the Strata v0.2.8 codebase, but I believe it applies to 0.2.9 as well.
Problem and result
I was unable to build the engine for a Radeon VII before this change:
-DSTRATA_HIP_GFX906=ONstopped insrc/core/dflash2.cppwithThe gfx906 build is a backend of its own: its compile lines carry
-DSTRATA_HIP_GFX906=1 -D__HIP_PLATFORM_AMD__=1andnever
-DSTRATA_USE_HIP(0 occurrences in the whole build log), so both#if defined(STRATA_USE_HIP)branches in thisfile were compiled as CUDA. Extending both guards to
#if defined(STRATA_USE_HIP) || defined(STRATA_HIP_GFX906)makesthe same command link (
[85/85] Linking HIP executable strata), and the engine has been servingQwen3.8-Flash-Next IQ3_XXS on 2x Radeon VII at
--max-context 131072since.Related discussion
Follow-up to #3986 (open, MarcoTool, branch
gfx906-dflash2-build): its one hunk is identical to the first hunkhere, and its build check says it was never run on a gfx906 card. #4156 (KevinX8, closed unmerged) fixes the same
failure a different way, mapping the two calls in
include/strata/platform/hip_compat/strata_hip.h; the build-checkcomment on #3986 compares the two and notes they differ at runtime (call-site guard keeps the default priority unless
STRATA_DF2_PRIO=1, the compat shim gives the highest priority by default).Neither submission touches the second guard in this file —
capture()'sfork_default— which is what is new here,along with a run on actual gfx906 hardware. If you would rather take #3986, say so and I will drop the first hunk and
rebase the second onto it.
Approach
Both guards take the form the rest of the tree already uses for this backend:
mtp.cpp:475,verify.cpp:219,expert_cache.cpp:6,prefill.cpp,generate.cpp,kv_hybrid_parity.cppand several headers all testSTRATA_USE_HIPandSTRATA_HIP_GFX906together.load()(line 198): gfx906 keeps the HIP behaviour, i.e. the drafter stream takes the default priority unlessSTRATA_DF2_PRIO=1— the same choicemtp.cppalready makes for gfx906(
#if !defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906) && !defined(STRATA_GPU_METAL), "(HIP, Metal: thedefault priority)").
capture()(line 446): gfx906 keeps one drafter stream. Without the guard it inheritsfork_default = true, theCUDA default that the comment two lines above rules out for HIP ("measured: -0.3 ms a round on an RTX 3060,
+0.0..0.7 on a Strix Halo (gfx1151), so the HIP builds keep one stream"). Vega is nearer that measurement than an
RTX 3060 is.
STRATA_DF2_FORK=1still opts back in per run.Compatibility: the change only alters a build that defines
STRATA_HIP_GFX906and notSTRATA_USE_HIP, which is thegfx906 cmake branch (
CMakeLists.txt:199,205) alone. CUDA builds define neither macro and stay on#else; the wave32HIP build defines
STRATA_USE_HIP=1(cmake/hip_backend.cmake:98) and stays on the same branch it was on. No API,flag or file changes, no unrelated cleanup.
Validation
Environment: the ROCm build container (
/opt/rocm/core-7.14, AMD clang 23.0.0git from/opt/rocm/llvm, cmake 3.28.3),STRATA_GGML_DIR= llama.cpp3cf03257f219, repo at main870aedd. Host: 2x Radeon VII 16 GB (x8 Gen3 each), 90 GiBRAM, Unraid 7.3.2, container
--ipc=host --shm-size 2g,HIP_VISIBLE_DEVICES=0,1.Passed:
cmake -S /work/src/Strata -B /work/build-906 -G Ninja -DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906 -DSTRATA_GGML_DIR=/work/src/llama.cpp -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++then
ninja -C /work/build-906 strata strata-device:[85/85] Linking HIP executable strata, 0 errors,strata38,321,920 B,strata-devicebuilt too. Log/work/logs/build2.log.-fsyntax-only, tree untouched): 3 errorsagainst
git show HEAD:src/core/dflash2.cpp, 0 errors against the patched file. This is the negative control, sothe failure is pinned to these two guards and not to something else in the build.
grep -c DSTRATA_USE_HIP /work/logs/build.log→ 0, while itsdflash2 compile line is
clang++ -DSTRATA_HAVE_DFLASH2=1 -DSTRATA_HIP_GFX906=1 … -D__HIP_PLATFORM_AMD__=1 -isystem …/include/strata/platform/hip_compat … src/core/dflash2.cpp.strata-devicelistsdevice 0: AMD Radeon VII,device 1: AMD Radeon VII(both "computecapability 9.0, 16.0 GiB") with
HSA_OVERRIDE_GFX_VERSIONunset. Serving with--pack data/packs/iq3_xxs --native <shard1> --ple-gguf <shard2> --prefill auto --spec 4 --spec-min-p 0.5 --mtp data/mtp/rt --max-context 131072 --kv int8 --kv-resident 32768 --pipeline-windows 2 --layer-split auto:~3 h of continuous agent use (engine started 17:06, log still being written at 20:07 local), 55–110 tok/s decode, 100–230 tok/s prefill, expert cache 93–98 % hit,
12–13k experts resident in VRAM (~21 GB), ~15.5 GB VRAM per card, 54–62 °C, ~355 W per card against the 500 W limit,
PCIe Gen3 x8 per card. Logs
/work/logs/strata-iq3_xxs.log,/work/logs/device.log.Failed:
/work/logs/build.log, errors at log lines 2280/2290/2297): the three errorsquoted above,
ninja: build stopped: subcommand failed. Nothing else failed — this is the pre-change state, kept asthe control. No failure observed with the change applied.
Not run:
--mtp …/data/mtp/rt), not--draft dflash2, and the engine log contains nodflashline: the code both guards select is compiled and linked,but its runtime effect (stream priority, forked context update) was never exercised on a gfx906 card. Nothing in
docs/AMD_HIP.mdordocs/OLDER_GPUS.mddocuments dflash2 on gfx906 either. So thecapture()half of this changerests on the measurement recorded in that comment plus the
mtp.cppprecedent, not on a new benchmark. I can run--draft dflash2withSTRATA_DF2_FORK=1/0on this pair if the merge decision needs that number.CMakeLists.txt:691,STRATA_BUILD_TESTS AND STRATA_ENABLE_CUDA AND NOT STRATA_HIP_GFX906), so no unit or bench targets were built orrun here.
-DSTRATA_ENABLE_HIP=ON), SYCL and Metal builds: not run, no NVIDIA card and no CUDA toolkit inthis environment. Those paths are untouched by the guard change but not re-verified.
Limits
capture()default is a consistency choice, not a measurement: nobody has measured fork vs no-fork for thedrafter on gfx906, and I did not benchmark it here.
STRATA_DF2_FORK=1restores the CUDA behaviour per run, so the change stays reversible.and only the
capture()guard kept.needs
--draft-model); this branch says nothing about that.__shared__ alignas(16) int4, #2883 reproducible releases) are untouched here.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.