mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #325] [CLOSED] AMD working on Windows (9070XT tested) #2578
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#2578
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/325
Author: @dvasdekis
Created: 10/1/2026
Status: ❌ Closed
Base:
main← Head:amdwin-integration📝 Commits (9)
2373c75HIP: run Qwen3.8-Flash-Next on Windows gfx1200/gfx1201 (port of #247)2d3cde5HIP/Windows: batch expert copy dependencies in long prefill4a48bb1HIP: add staging ownership regression test and document opt-ine1809f3HIP/Windows: select the GPU by its HIP ordinal, not the registry indexe9dcc9cbench: RX 9070 XT / gfx1201 / Windows numbers, and #302 measured here7a22596HIP/Windows: docs, the requested _WIN32 gate, and a test for the mapped-alias finding700fe1abench: a checkable quality suite for head-to-head model/quant comparisonse15d329expert cache: hold back what is allocated after it, on one GPU as on twofcf7cf1bench: context x quant decode matrix, and the harness traps that produced it📊 Changes
31 files changed (+1733 additions, -228 deletions)
View changed files
📝
.gitignore(+3 -0)📝
CMakeLists.txt(+15 -1)📝
README.md(+6 -4)➕
bench/cell_bench.py(+146 -0)➕
bench/context_bench.py(+68 -0)➕
bench/quality_suite.py(+72 -0)➕
bench/repeat_bench.py(+46 -0)➕
bench/results/2026-09-30-rx9070xt-windows/README.md(+95 -0)➕
bench/results/context-matrix.md(+68 -0)➕
bench/results/context-matrix.txt(+25 -0)📝
cmake/hip_backend.cmake(+21 -5)📝
docs/AMD_HIP.md(+83 -5)➕
docs/HIP_WINDOWS_PREFILL.md(+59 -0)📝
include/strata/core/device.hpp(+5 -0)📝
include/strata/hip_compat/cuda_runtime.h(+8 -0)📝
include/strata/kernels/cpu/expert_layout.hpp(+1 -1)📝
serve/server.py(+19 -2)📝
setup.py(+294 -43)📝
src/core/device.cu(+10 -0)📝
src/core/device_main.cpp(+33 -1)...and 11 more files
📄 Description
Windows HIP for gfx1200/gfx1201 (port of #247) + the GPU-selection fix
Windows HIP was explicitly out of scope in
docs/AMD_HIP.md. This adds it, on top of@main at
30ec18e. It carries @jagsan-cyber's #247 work (its one substantive commit,aea1ec1, re-resolved onto current main), @araujoluks's #302, and two fixes thatneither had.
Kept deliberately opt-in, defaults unchanged, and nothing on the NVIDIA or Linux HIP
paths is altered.
What this adds
Context x quant: generation speed measured on an RX 9070 XT, 64GB DDR5
Generation tok/s:
setup.pyfinds the card through thedisplay-class registry (PCI device id, then driver name), and resolves a ROCm tree:
an installed ROCm 10
rocm-sdkor HIP SDK first, otherwise AMD's TheRock wheelsinto
.venv.--backend hiponSTART-HERE.bat, chosen by itself when there is nousable NVIDIA card.
clang++compiles the host code too and the CUDA shim is force-included with/FI.The
.cusources are unchanged;hip_backend.cmakestill just setsLANGUAGE HIP.hipErrorInvalidValueset, which the next kernel's check would turn into an exit.Cleared after a successful GEMM, gated on
_WIN32— clearing it on Linux couldhide a real error there, so the Linux build keeps reporting it as before.
iq_pack.py), so a 3-shardGGUF packs natively, and an F32
ple_conv1dis converted to FP16 at startupbecause the convolution kernels read FP16.
STRATA_HIP_COPY_BATCH/STRATA_HIP_STAGE_BATCH/STRATA_HIP_STAGE_COPY_BATCH, defaults unchanged at1/1/1, guarded by
STRATA_USE_HIP && _WIN32.The GPU-selection bug (#247 and #302 do not have this)
setup.pydetects AMD cards by display-class enumeration;HIP_VISIBLE_DEVICEScounts the devices the HIP runtime enumerates. The orders differ whenever an
integrated GPU is present — the iGPU takes ordinal 0 and pushes the discrete card
to 1. setup then handed the engine the registry index, so on a PC with an iGPU the
engine was pointed at the iGPU.
This is not hypothetical; it is what happens on the test machine.
setup.py --checkselected index 0 for the RX 9070 XT, while the runtime reports:
The arch check then refuses the iGPU, so the failure lands after install, after
the ~58 GB download, and reads as "the Windows AMD port is broken" rather than "your
GPU numbering shifted by one". Any AMD PC with an iGPU hits it.
device_count()andstrata-device --list-devicesenumerate without tripping thearch check (which throws for a card the binary has no code for — exactly what a
listing needs to show).
setup.py:hip_ordinal()resolves the card's HIP ordinal and records it aship_ordinalin the engine config, warning when it differs from the registryindex.
serve/server.py:hip_visible()prefers it, falling back for configswritten before this (correct only without an iGPU).
It matches the card by the architecture on the line after its
device N:header.Matching on the name is wrong (the registry and runtime names differ), and matching
"does the arch string appear anywhere" is worse: the iGPU's arch-problem message
names this build's architectures, so
gfx1201 in linematches the iGPU. Thatmistake made the first version of this return 0.
Also fixed
hipHostGetDevicePointerreturns the host pointer on Windows, not a device-sidealias — measured, both addresses print as
0x304000000(
tests/hip/mapped_alias). A non-null alias is therefore not evidence of a usablemapping, so
native_head.cpponly takes the mapped-alias path when the pointer isgenuinely distinct and otherwise copies the token embedding into VRAM.
native_head.cpp's destructor freeddev_owned_and thendev_, butload()onlyever sets one, so a device-resident table was freed twice.
iq_pack.py: thetmp.replace()completion mark (#173) is preserved. #247's hunksilently drops it, which would let a torn
native_experts.txtbe read as a finishedpack.
Not fixed, deliberately
tests/hip/handofffails on gfx1201/Windows ("separate copy/ring timeout") for thesame mapped-alias reason — a
DeviceToDevicecopy into a host address publishesnothing. It passes on Linux. The engine does not use that copy path on Windows (its
arena arrives via
cudaHostRegistered pinned memory), and fixing it properly meansgiving the handoff a real device-side buffer, which is a change to the production path.
Recorded in
docs/AMD_HIP.mdrather than papered over.Test
Windows 11, AMD Radeon RX 9070 XT (gfx1201, 16 GB, 32 CUs), Ryzen 7 7800X3D,
63 GB RAM, ROCm 10.2.0a20260930 in
.venv, engine 0.1.30, this branch.START-HERE.bat --backend hipcompiles cleanly, including theFetchContentedpinned llama.cpp/ggml as HIP. Both were open questions; both are fine.
strata-device --selftestpasses: arena alignment, the NaN poison path, over-allocationrefused.
ctest: 42 of 46 pass, 1 skipped, 4 failed. The failures arehip_handoff(above) and
ple_parity/expert_parity/pool_test, which all readpack/full/experts.bin, a model fixture this checkout does not carry — the samethree are already documented Linux exclusions for the same reason.
9.59 GiB VRAM, 503 MiB free, 29.2 tok/s decode, ~181 tok/s prefill. Correct
answers (
17*23→ 391, capital of France → Paris, validreverse_string).Numbers and method in
bench/results/2026-09-30-rx9070xt-windows/.On #302's benchmark
#302 reports +62% PP / −38% TTFT. Measured here: +4.6% cold prefill (173 → 181
tok/s, 4 trials/arm, median, per-trial random salt so the prefix cache cannot serve
it,
STRATA_PREFILL_TIMING=1both arms).The counters show #302 doing exactly what it was written to do — dependency waits
collapse 8,270 → 1,034, matching
completion_batch=8— but "wait copy" is only2.2–2.3% of GPU time in both arms, so there was almost nothing there to win. #302's
figure came from Q2_0, where copy-wait was 2,746 ms of a 6,144 ms prefill. On a 16 GB
card holding 5,047 of 12,288 experts the run is bound by gdn (42% of GPU time), qsa
proj (13%), dequant (11%) and the gemms (11%). A user with less VRAM has more expert
traffic and will see more of #302's benefit. It is a correct change at the wrong
bottleneck for this configuration, which is why the opt-in defaults stay 1/1/1.
The expert cache could take the VRAM allocated after it (fixed here)
Found by running the full model on a 16 GB card, not by reading the code. At
IQ3_XXS the engine sized a 6,124-slot expert cache (9.92 GiB), printed
"almost ready", and died:
The penalty history is 0.1 MiB and under 128 KB was spare.
stage_room()alreadyreserves for exactly this on the layer split - it holds back
kWindowMibandkDrafterMibbecause the verify windows, drafter and head are all allocated aftera stage's cache is sized. The single-GPU path reserved
vram_reserve_mibalone,so a profile-sized cache took the rest. The Coder survived only because its cache
is 0.33 GiB smaller.
kPostCacheMib(192) besidekWindowMib/kDrafterMib, held back on thesingle-GPU path too. 192 covers the measured 74.1 MiB of verify windows at
n_embd 2560, the penalty history, and the R4 hit-path scratch (which scales with
n_embd).
kDrafterMibis deliberately not re-added -mtp_bindis this run'sown figure for those bytes.
cudaMemGetInfoand capped againstvram_reserve_mibalone, handing the slack straight back. Same fix.At the default reserve, with no
--vram-reserve-mib:That is more cache than the
--vram-reserve-mib 2048workaround managed(5,303 slots), so this is not headroom traded for capacity. Coder unaffected:
4,946 slots, 693 MiB free, still serving.
This is a pre-existing bug on the NVIDIA path too - nothing here is HIP-specific -
so it is worth a look even if the rest of this PR is not taken.
Credits
@jagsan-cyber for #247 (the Windows ROCm resolution, the MSVC
/FIbuild, the sticky-error, the multi-shard pack), @araujoluks for #302, and @Niko1221 for the
#247discussion that pointed out a Windows-HIP-only PR was welcome. The arch check,
gfx1101/gfx1102dp4a targets and the #173 pack fix in this branch are currentmain's, kept over #247's older copies of those hunks.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.