mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1297] [CLOSED] HIP: on-device autotuning for gfx1100 decode (kernel shapes, draft and CPU settings) #3368
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#3368
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/1297
Author: @xyzzing
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:refile-744-autotune📝 Commits (3)
66092b4strata-hip-decode-autotune.patch applied onto its base4da9c5923b447bdecode tuning: selection-space identity, dispatch-knob refusal, one rows list, true-default baseline33a73c5tune_decode: the verify-window mix becomes a flag; staging knobs measured on gfx1100📊 Changes
15 files changed (+2078 additions, -75 deletions)
View changed files
📝
CMakeLists.txt(+11 -0)📝
docs/AMD_HIP.md(+2 -1)➕
docs/AMD_HIP_AUTOTUNE.md(+117 -0)➕
include/strata/kernels/decode_tuning.hpp(+111 -0)📝
include/strata/kernels/iq_kernels.hpp(+12 -0)📝
setup.py(+30 -13)📝
src/kernels/cuda/iq_kernels.cu(+237 -27)➕
src/kernels/decode_tuning.cpp(+172 -0)📝
src/program/generate.cpp(+4 -0)➕
tests/core/decode_tuning_test.cpp(+89 -0)📝
tools/calibrate.py(+131 -33)➕
tools/hip/autotune.py(+321 -0)➕
tools/hip/test_autotune.py(+146 -0)➕
tools/hip/tune_decode.cpp(+574 -0)📝
tools/test_calibrate.py(+121 -1)📄 Description
Re-file of #744 — that PR was auto-closed on 2026-10-06 when this repository's main history was cleaned up (per the maintainer's note there, not a rejection). Original discussion: #744.
One deliberate change from the original PR: the original branch carried the 0.1.27-era patch (
6947459) as-is. This re-file ships the ported and measured version instead (fork-side, 2026-10-05): the tool re-applied onto the current engine line, with the kernel side re-checked against what upstream evolved since 0.1.27 (the recorded on-card campaign kept every shipped kernel shape — the tuner's value on this machine was proving it per-machine, not changing anything). Docs (docs/AMD_HIP_AUTOTUNE.md+ thedocs/AMD_HIP.mdpointer) are included; the fork-only doc row from the original branch is not.Re-base notes, explicitly:
tools/calibrate.pygrewhost_worker_extras()/extra_workerson main since the port; the reconciliation keeps main's CPU-worker machinery and adds the port's backend/draft/sweep surface on top (the stub tests updated to match). The (fork-only) GFX1100.md row of the original branch is dropped as noted. Gates on this base: full HIP build green;decode_tuning_testall checks pass;tools/hip/test_autotune.py+tools/test_calibrate.py34 passed.The measured verdict from the port campaign stands: on this gfx1100 the sweep kept every shipped kernel-shape default (byte-gated, 7/7) and the settings layer at the shipped defaults (67.1 tok/s vs 65.0/66.1 swept) — the tool's value is proving it per machine.
Summary
On-device decode autotuning for the AMD HIP backend (gfx1100): per-shape rows-per-block tuning for the decode expert kernels and
iq_mmvq(bitwise-exact variants only), a guarded tuning-table format, an on-device tuner, and an orchestrator that sweeps kernels, draft floor, CPU workers, and drafting windows with the user's own prompts. Settings-layer sweeps (--spec,--suffix-draft,--spec-min-p, workers) now work on HIP too, andcalibrateis HIP-aware (keeps the config's--pcie-frac).Both layers keep answers exactly the same: kernel variants are byte-compared on-device and end-to-end; the settings layer is greedy-verification-exact.
Measured on the target hardware (RX 7900 XTX 24 GB, IQ3_S, ROCm 7.1.1)
--spec-min-p 0.70= 63.1 tok/s vs baseline (~+10%), token-identity verified end-to-end — adopted in our serving config.strata-<model>.autotune.json) carries every measurement.Notes
4da9c59); a rebase onto current upstream main is queued (the files the patch touches are untouched by 0.1.36–0.1.38's kernel changes, so the rebase should be mechanical).Prepared with an AI engineering agent (GLM-5.3 / Z.ai) under human direction; every number is from our own recorded runs.
The second commit: the seam rework
Kernel-selection-space token
Why: Between the original PR and this re-file, the decode kernels were reworked for sub-warp/
EXACT_Nbehavior while using the same compiler and HIP runtime. The old table identity — arch + runtime + compiler hash — would have accepted a table whose measured choices no longer describe the current build.What: The table header gains a 4th token: the kernel-selection-space token. This build reports token
2(see the wrong-space refusal in the measurements). Tables made before this token existed, or made for a different token, refuse as stale and tell the user to run the tuner again.Dispatch-knob refusal
Why: The tuning table measures the default decode dispatch. If a rerouting knob changes the dispatch path, the measured rows no longer describe the launch being made.
What: The table refuses to activate when any of these knobs are set:
STRATA_OLD_IQ_MMVQ,STRATA_NO_SUB16_GU,STRATA_IQ_STAGE_GRID=0,STRATA_IQ_STAGE_GRID_MMVQ=1,STRATA_EXPERT_V2/V2K,STRATA_TSUM,STRATA_GROUPED_V1. The refusal is one stderr line; defaults stay in effect.One rows list
Why: The compiled-in rows sets previously lived in two places: parser validity and launcher switches. Those could drift.
What: Parser, launchers, and the tuner now derive the rows lists from one X-macro pair in
decode_tuning.hpp:STRATA_EXPERT_ROWS_VARIANTSandSTRATA_MMVQ_ROWS_VARIANTS.True-default baseline
Why: The tuner’s default candidate and bitwise reference were the explicit-rows pair
(8,8). That is not the launch the engine actually makes when no table is active.What: The default candidate and bitwise reference are now the engine’s real entry points:
native_expert_grouped/iq_mmvqwith no table. The default pair also skips the bitwise self-check: comparing it to itself decides nothing, and excluding it would crash the chooser.Doc updates
Why: A table row and the default geometry can both contain a number like
16, but they do not mean the same mechanism.What: Docs now state:
16in a table and16in the default’s geometry are different mechanisms;Measurements (RX 7900 XTX, gfx1100, ROCm nightly SDK)
decode_tuning_test(parser + every refusal, CPU-only)decode_tuning_teston this branch build23b447b; log in footeriq_parity/native_grouped_parity/iq_multi_parityon card23b447b; log in footernative_grouped_paritythrough an ENGAGED 1-row tabledecode tuning: 1 shapes from ... (gfx1100, runtime 71726392)23b447b; log in footermade for kernel selection space 99, this build is 2 (the kernels changed): run the tuner again; stale pre-space header ->made before the kernel selection space was tracked - the kernels have changed since; knob set ->STRATA_NO_SUB16_GU reroutes the decode dispatch away from what the table measured; defaults ran in every refusal23b447b; log in footerdefault chain 67.9-73.1 us, best 8/8, kept the default, 0 shapes changed23b447b; log in footerarm =
tools/hip/tune_decode+autotune.pyon this branch's build (23b447b) through the HIP pipeline against the nightly SDK; full log and refusal transcripts in the fork-side record (artifacts/rocm/results/record-autotune-refile-gpu-20261007.json).The campaign result is a null: the 0.1.31–0.1.39 kernel evolution and the sub-warp rework's hardcoded conclusions already win here. The tool's value is per-machine verification: it shows the defaults are fastest, byte-checked, and it tunes where they are not. The HIP-runtime field tracks the loaded runtime library: the same binary reported
70152802against the systemlibamdhip64and71726392against the SDK one, reported in the same card record; tune and run with the same library the engine loads.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.