mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #353] [CLOSED] DeepSeek: hipBLASLt solution table for dense prompt GEMMs (AMD, opt-in) #482
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#482
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/mw00/project-maya/pull/353
Author: @boxwrench
Created: 10/21/2026
Status: ❌ Closed
Base:
main← Head:pr/ds4-dense-lt📝 Commits (1)
68ae860DeepSeek: hipBLASLt solution table for dense prompt GEMMs (AMD, opt-in)📊 Changes
4 files changed (+264 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+5 -0)📝
README.md(+5 -0)📝
docs/SETTINGS.md(+17 -0)📝
src/ds4/ds4_model.cu(+237 -0)📄 Description
DeepSeek: hipBLASLt solution table for dense prompt GEMMs (AMD, opt-in)
What it does
DeepSeek-V4.1-Flash's prompt path reconstructs its dense weights to FP16 and multiplies them with the vendor BLAS
(
cublasGemmEx; hipBLAS on AMD). On a HIP build with hipBLASLt,MAYA_DS4_DENSE_LT=1now asks hipBLASLt for up toeight heuristic candidates, times each candidate on the real shape and stride the engine is about to use, and keeps
the fastest in a process-local table. Later calls with the same
(device, N, K, rows, ldx, ldy, pointer alignment)reuse it.
The switch is off by default and opt-in. Unset or any value other than
1keeps the existing call. The gfx1151numbers below are large enough to consider an architecture-scoped default later, but this PR keeps opt-in: one
machine/ROCm build on this branch and the first-use cost are not enough to change an existing user's path. It only applies
to prompt dense GEMMs with
beta == 0and at least 32 rows; decode shapes and the routed experts are untouched. Thetable is built on first use and is included in that prompt's time (a few seconds on a long prompt). The NVIDIA path is
unchanged: the HIP-specific code and the call sites are inside
#if defined(STRATA_USE_HIP) && defined(STRATA_HIPBLASLT_AVAILABLE),and the CUDA build preprocesses
ds4_model.cuto the same output as before this change. AMD builds without hipBLASLtalso keep the old path.
The CMake change links
roc::hipblasltand definesSTRATA_HIPBLASLT_AVAILABLE=1formaya-ds4only when thehipBLASLt package was found, so a HIP build on a machine without it still configures and builds.
The handle and workspace are per
(device, stream), and calls that share them are serialized on the host andsubmitted to that stream, so one state is never used by two devices or streams at once. Every setup and timing call
(descriptor, layout, preference, heuristic query, events, allocation, matmul) is checked; a failed candidate is not
published, a failed setup/timing is not cached, and the call returns to the existing BLAS call with one log line. A
forced hipBLASLt failure test (every
hipblasLtMatmulreturning an error) completed the 8K arm with exit 0, thefallback line, and the same 128 token IDs.
Hardware
gfx1151, Linux.temperature 0),--dspark none, prompt skip on (v1.1.20 default), 128 output tokens. The engine wasdriven with raw token IDs, so the server's chat template and its thinking-off switch do not apply; no thinking
markers were injected.
Before / after
One process per arm, the switch's first-use table included in every "on" number. The same-config A/A floor is two
"off" runs.
The two off runs and the on run at 2K are 20.030 / 20.237 and 18.014 s; at 8K the recheck's two off and two on runs are
49.739 / 48.932 and 44.684 / 43.446 s; at 32K 158.901 / 161.121 and 140.460 s. Each "off" time in the table is the mean
of the two off runs; throughput is the mean of their reported rates, and each 8K "on" time is the mean of its two runs.
The 8K gain is 7.3x its 1.64 % off/off floor (the two 8K on runs span 2.8 %). The 2K and 32K rows are the earlier
measurement on the same branch before the ownership/error-handling fix; the 8K row was re-run on the fixed build.
Median clocks over the timed prompt windows moved by at most 3.6 % between arms (below the 5 % comparison threshold),
and the minimum MemAvailable was 19.88 GiB at 32K (21.39 GiB at 2K, 20.81 GiB at 8K), above the 16 GiB guard.
The engine's prompt stage split moves where the change should: at 8K, attention (which includes the dense
projections) falls 21.2 / 21.2 s -> 15.5 / 14.8 s, while routed experts stay within 3 % (22.8 / 22.2 -> 22.5 / 22.0 s)
and routing + shared moves up 4.9 / 4.8 -> 6.2 / 6.1 s. At 32K, attention falls 72.9 / 74.1 -> 49.5 s, experts 67.6 / 68.5 -> 68.1 s, and
routing + shared 16.2 / 16.5 -> 19.7 s. These stage totals are consistent with the intended reduction in dense GEMM time.
Output identity
128-token greedy identity, comparing the printed token IDs of the off and on runs:
engine's 2K free-running decode is not deterministic between processes on this box. The on run differs from the
first off run at 76 positions, inside that run-to-run spread; this is not evidence for or against the switch.
The switch can change the last bits of a GEMM (a different candidate's summation order), so the last-bit difference
is expected; the 8K and 32K greedy sequences do not change. This is a greedy identity check, not a task-suite or KL
certificate; see "What was not measured".
How to reproduce
Build (Linux, ROCm with hipBLASLt):
Run one arm (the prompt IDs are the ones used here;
--idstakes a comma-joined list):Use
--max-context 40960 --no-expert-cacheandDS4_AHEAD=0 DS4_SPEC_Q=0for the 32K recipe (the same 12,288 MiBreserve as above; this Q8 pack used that reserve at every length). The 32K run needs
more IDs than one argument holds on this box, so the measurement used a local
--ids-fileCLI fixture (the ids-filehunk of our bench fixture, not part of this PR). The switch logic is the same. The final branch reads the aliased
STRATA_DS4_DENSE_LTrather thanMAYA_DS4_DENSE_LTdirectly (rechecked at 8K: 42.872 s vs 43.395 s on the earlierbuild). The final source also adds the per-(device, stream) state and the checked setup/timing path; it was rebuilt on
the Strix Halo machine and the 8K row above plus the forced-failure run were made with that build. The stream query is skipped when the
switch is off, and a failed query falls back.
What was not measured
first-use selection included) measured dense LT 2.1 % slower at 8K and 2.3 % slower at 32K on gfx1201, so
this switch should stay off there; the gain above is a gfx1151 result.
build or GPU run on this branch.
the same process can reuse matching entries; its latency was not measured here.
prompts and generations.
Upstream notes
MAYA_DS4_DENSE_LTto match the other DeepSeek settings. The code readsSTRATA_DS4_DENSE_LTandmain()'senv_aliases()maps theMAYA_*name onto it, as for the other settings, soboth spellings work.
(device, stream), and is not written to any vendor tuning file. It uses a32 MiB workspace cap and frees the temporary output scratch after selection; successful state lives for the
process.
docs/SETTINGS.mdhas the DeepSeek row; the README's Tuning bullet points to it.CHANGELOG.mdandVERSIONareuntouched, as the maintainer writes those.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.