ROCm: add gfx906 wave64 support and distributed long-context scaling#574
Open
mayor686 wants to merge 7 commits into
Open
ROCm: add gfx906 wave64 support and distributed long-context scaling#574mayor686 wants to merge 7 commits into
mayor686 wants to merge 7 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change enables and tunes the ROCm backend for gfx906 GPUs: Radeon VII,
Radeon Pro VII, Instinct MI50, and MI60. These devices use fixed 64-lane
wavefronts and cannot use the gfx11 WMMA builtin or the rocWMMA architectures
used by the existing gfx1151 path.
The port provides a wave64-safe compatibility implementation for the exact
16x16 half x half -> float WMMA subset used by ds4, fixes logical-wave32 masks
and broadcasts, and adds native gfx906 paths for Q8 decode, F16-pair decode,
router evaluation, and short-cache attention scoring.
The final revision also removes two distributed-memory bottlenecks:
slices as well as on the coordinator.
It also stabilizes live KV reuse across tool-call continuations. Tool schemas
are now rendered deterministically when clients send the same tool set in a
different order or serialize semantically identical JSON object keys in a
different order. Schema property order remains intact because ds4 uses it for
DSML argument ordering, while malformed duplicate names/keys are deliberately
not normalized.
On the tested six-GPU host, resident weights now support at least 750K context
without changing KV precision. With a 2 GiB routed-expert cache per process,
the server reaches the model's native 1,000,000-token context limit.
Validation system
--offload-arch=gfx906The capacity PP6 layout gives the 32 GiB coordinator layers 0:12 plus
embedding/output and gives the five 16 GiB workers six layers each. The speed
profile uses a balanced 8 + 7x5 split at 32K context.
run.shexpresses thisas a configurable device/layer route rather than assuming six GPUs or a fixed
enumeration. Inter-stage activations use 16 bits.
Performance and capacity
max_err=0, 8,192 valuesThe controlled legacy-vs-gfx906 workgroup A/B improved end-to-end decode by
5.0%. Isolated Q8 decode improved 18.5%; F16-pair results were bit-identical
and improved at the real 256/512/1024-row shapes. Removing global kernel
serialization accounts for the larger gain over the original setup.
Balancing the resident PP6 route removes the coordinator prefill bottleneck:
the same 2,418-token prompt improved by 50.1%, while decode remained neutral
within run-to-run variance. The balanced split is therefore the default speed
example; the conservative capacity split remains available for large contexts.
Long-context allocation and live-session results:
Before local-slice KV allocation, 290K opened the HTTP server but failed on
the first worker session with an out-of-memory error. After the change, all
contexts in the table created a distributed session and completed inference.
The 1M result validates capacity and a live request; it is not a claim that a
full one-million-token prefill was timed.
SSD streaming uses the original quantized expert bytes, so it changes capacity
and latency rather than model precision. A deterministic
temperature=0,no-reasoning comparison returned the same output (
391) in resident and SSDmodes for the same arithmetic prompt.
Changes
rocm/ds4_rocm_wmma_gfx906.cuh, selected only for gfx906.a hardware wave64.
make gfx906, architecture-selectable ROCm targets, and real-deviceWMMA, Q8, F16-pair, router, attention, and long-context regressions.
for the layer range owned by the local distributed process.
mapping their full routed layers.
instead of silently falling back to an unsafe full-layer mapping.
device/layer routes, including GPU counts other than the validated PP6 host.
tool continuations retain the live KV prefix instead of cold-prefilling the
conversation again.
omitted reasoning, and interleaved requests; avoid canonicalizing ambiguous
duplicate tool names or JSON keys.
TRACE_FILEwithout changing the default runtime behavior.
Validation
Distributed end-to-end checks used
run-speed.shandrun-context.sh.run-context.shpasses the same 2 GiB cache policy to every process. A negativetest with 1 GiB / 151 experts exits cleanly and reports the required minimum of
256 experts / approximately 1.69 GiB for this model.
A final resident test allocated a 300,000-token server context and asked the
loaded DeepSeek-V4-Flash model to implement a single-file terminal task manager.
The API returned HTTP 200 with
finish_reason=stopafter generating 1,322tokens at 13.5 token/s. The unmodified generated source passed Python compile
and functional tests for add/list/done/stats/remove, stable IDs, JSON output,
invalid IDs, corrupt databases, invalid priorities, and atomic-save cleanup.
Live tool-continuation regression testing used a 300,000-token resident server
and real SSE assembly. An 18-call
readresponse generated 751 DSML tokens;the continuation changed only the JSON key order of an otherwise identical
schema and reused all 1,417 live-prefix tokens, prefilling only the 239-token
tool-result suffix. A larger test reversed all 30 tools in a 4,392-token
continuation and reused 4,374 tokens, writing only 18 new tokens. Before schema
canonicalization, both reorderings caused a full cache miss.
Negative controls confirmed that actual description/tool changes, DSML
property-order changes, omitted thinking content, and an interleaved unrelated
request still invalidate the live KV. Parsing and canonicalizing 30 tool schemas
measured approximately 0.23 ms per request over 5,000 iterations.
The complete seven-commit series was additionally applied with
git amto afresh clone of
antirez/ds4at80ebbc3; that clone passedmake gfx906 -j16,the ROCm long-context regression, and all gfx906 wave64 shim tests.
Reproduction
Edit
MODEL_PATHinside the desired launcher; no external environment setup isrequired:
The included ROCR device map is specific to the validated 5 x 16 GiB plus
1 x 32 GiB topology and must be adjusted when HSA enumeration differs.
Known limitations
slower than resident weights. Larger caches trade VRAM for hit rate.
PCIe topology; the test covers allocation, route creation, and live decode.
improve quality-adjusted throughput in this configuration.
replaces it, and thinking-mode continuations must replay required reasoning.