Testing¶
- The tiers
- Running each tier
- What the GPU tier holds the line on
- Examples, and checks at full size
- The agents' tools
- CI
- The merge train
- The performance gate
- The gates for a change to the generated code
- Reproducing
The tiers¶
Five tiers, by what they need. The first three need no GPU:
ninja -C $HK_MLIR_BUILD check-hk # lit: the dialect, passes, translation
python3 -m pytest tests/hk/ir tests/hk/codegen -q # no GPU, no torch
| tier | needs | what it catches |
|---|---|---|
mlir/test/ |
the MLIR build | op verifiers, pass results and errors, the C++ for hand-written IR |
tests/hk/ir/ |
hk._mlir | tracing, the language, pass errors from Python, generated C++ |
tests/hk/codegen/ |
hipcc | compiles; spill/occupancy gates fire |
tests/hk/gpu/ |
an AMD GPU + torch | numerics vs torch |
tests/hk/engines/ |
vLLM or SGLang importable | an engine release moving a symbol a patch rebinds |
A tier that cannot run is skipped with a reason, never silently passed. Performance has a gate of its own, ratios against the arms beside hk in one scoreboard run (the performance gate).
Running each tier¶
- lit —
ninja -C $HK_MLIR_BUILD check-hk, where$HK_MLIR_BUILDis the directoryscripts/build_hk_mlir.shbuilt in (default/dev/shm/hk-llvm/hk-build-cpXY; see building). The tests aremlir/test/Dialect,mlir/test/Transformsandmlir/test/Target, each file driven by itsRUN:line throughhk-opt,hk-translateandFileCheck(the tools). - ir —
python3 -m pytest tests/hk/ir -q. Needshk._mlir; no compiler, no GPU, no torch.HK_ARCH=gfx1201runs it for RDNA4. A test of one arch's measured data -- a shipped routing table, a tuned record, gfx1100's LDS pool or Infinity Cache -- carries@pytest.mark.arch("gfx1100")and runs as gfx1100 whatever the tier was started with; it says nothing about the other arch. - codegen —
python3 -m pytest tests/hk/codegen -q. Needs hipcc, no GPU; generates and compiles, never launches. Skipped, with that reason, when there is no working hipcc. - gpu —
python3 -m pytest tests/hk/gpu -q. Needs an AMD GPU and torch; skipped when either is missing. This is the tier that launches, and the only one that can catch an indexing error — a kernel that reads the wrong tile compiles perfectly and passes every gate.tests/hk/conftest.pypinsHK_ARCH=gfx1100unless one is set, and skips the tier, saying so, when the GPU is another arch; setHK_ARCHto the GPU's to run it there.test_flydsl_gemm.pyalso needs FlyDSL (FLYDSL_ROOT), and says so when it skips.
On gfx950 every kernel the tier runs has a native path, so a failure is a
failure. What a target lacks by design -- FlyDSL's RDNA3 GEMM on gfx950, the
strips on gfx942 -- is a skip condition in the test itself.
* engines — python3 -m pytest tests/hk/engines -q, in each engine's
venv. Every symbol a vLLM or SGLang patch rebinds, with the signature its
stand-in forwards to and the call sites the rebind must reach; a module is
skipped when its engine is not importable. SGLang's needs a GPU visible,
since it reads the arch while importing. The versions it was run against
are in integration.
* the engines' contracts run in the IR tier, with no engine:
tests/hk/ir/test_engine_facts.py judges every route that is on by default
against the engine facts recorded from each production image and each engine
version hk claims (integration)
in tests/hk/ir/engine_facts/. A changed stand-in or check that one of those
engines would refuse fails here. When an image changes, or a new one ships,
record it inside the image and commit the file:
HK_ARCH=gfx1100 python3 -m hk.integration.contract --record tests/hk/ir/engine_facts/<image>.json \
--image sha256:<digest> --deployed-on gfx1100 --role production
Nothing is launched, but give it one GPU: SGLang, AITER and some vLLM builds
read the GPU while importing, and a route recorded without one is recorded
as broken. Then add its label (its name in the support matrix), its
image_note, and any expected_refusals (a route the image breaks today,
with the reason). A fixture whose image has an engine hk does not claim lists
the ones it is for in serves (["sglang"]). An expected refusal turns off
only that route in that image; the test holds that the image's other
default-on routes are still applied. Last, regenerate
the support matrix (python3 scripts/gen_support_matrix.py):
tests/hk/ir/test_support_matrix.py fails while it is stale.
The gates are by directory, in tests/hk/conftest.py, which also puts
python/ on sys.path, so the suite runs from a checkout without installing.
A test outside those directories opts into a gate with the hipcc or gpu
marker (pyproject.toml). python3 -m pytest with no path runs tests/hk.
What the GPU tier holds the line on¶
Numerics against torch, with tolerances per dtype rather than global (bf16 carries about three decimal digits), plus a few tests with exact answers. Two of those came out of a real bug: a biased bf16 conversion that a tolerance sized for indexing errors could never have seen (Phase 6):
Two tests now hold the line, both with exact answers rather than a tolerance
(tests/hk/gpu/test_attn.py): V = 1 must come back bit-exact, and Q = 0
must give the mean of V. The file's existing RTOL = 5e-2 could never have
seen this -- it is sized to catch a shifted mask, and a half-ulp bias passed
all 31 of its cases while changing what a model said.
The GPU tier also covers the integration layer: torch.compile(fullgraph=True),
CUDA-graph capture and replay, and the strided-ViT-input contract in both
directions.
And memory safety at ragged shapes (tests/hk/gpu/test_fenced.py, group
fence): a read past a tensor's end leaves the results bit-exact -- it lands in
the caching allocator's neighbour -- until the tensor ends a segment, and then it
is a memory fault some runs and not others (mxfp8.quant in vLLM, #47). There,
every allocation of a child process comes from fence_alloc.cpp, a
CUDAPluggableAllocator over HIP VMM that ends each one flush against an
unmapped granule, so any access past any tensor faults at once, on every run, on
gfx950 and gfx1100. One child per op family (_fence.fenced_cases), every
route at M (or the sequence) 1, a tile - 1, a tile + 1, odd and the
DeepSeek-V4.1 shapes; HK_FENCE_EACH=1 runs a child per case and reports every
one that fails. A new op, or a route that takes a new ragged dimension, gets
cases there.
The default-on rule¶
An engine route (one entry of hk.integration.switches) is on by default on a
GPU when all three of these hold there:
- Its kernel is clearly better than the engine's best, at two levels. Both are measured in one process, on cold weights, against the engine's fastest kernel for each shape:
- The route: over the shapes the route takes, weighted by the time each takes in a real model's mix, the gain is 1.15x or more.
- Each shape: a shape goes to hk only if hk is faster on it, measured in context, by more than the measurement noise. A shape that is not stays on the engine, so the route is never slower on a shape it takes.
- Its correctness suite passes:
- a float64 reference;
- an exact probe (
V = 1for attention, above); - 200 repeats over outputs poisoned with NaN;
- fenced bounds (
test_fenced.py, above); - a side-stream test (a producer on a torch stream of its own);
- the final-ISA gates: spills, MFMA hazards and VOPD (the resource gates).
- One end-to-end smoke per engine: one server start with the route on, hk's call count for it above zero, and quality (GSM8K, and ChartQA for a vision model) equal to the engine's own.
The full multi-start A/B of a model (stock against hk, alternating server
starts) is measured once per release, for the public
scorecard. It is not a gate for each route. A route
that changes outputs beyond the engine's own noise stays off: the smoke's
quality check is where that shows. python3 -m hk.integration --status prints
every route's default on your GPU and the rule that decided it.
Examples, and checks at full size¶
Every kernel in examples/ is held at three tiers, through
examples/_catalog.py:
- tests/hk/ir/test_examples.py traces and translates it, and pins the facts
its docstring teaches: the GEMM's waits step down 4 then 0, the attention's
rescale is a runtime branch, and the control-flow example carries its
scalars.
- tests/hk/codegen/test_example_builds.py compiles it, with no spill.
- tests/hk/gpu/test_example_runs.py runs every script with its check against
torch.
The GPU tier's own shapes are small on purpose: they hunt indexing errors at
ragged edges, and a handful of workgroups is enough for that. It is not
enough for a race between workgroups that share a WGP. The cross-warp combine
had one for as long as hk had norms, and only a full-size run showed it
(the record). Two things
now run at the sizes a model produces:
- examples/validate.py checks every shipped op at
7-8B decoder shapes against an fp32 reference, then times it against torch.
Its exit status is the number of failures.
- tests/hk/gpu/test_phase2.py runs rmsnorm, layernorm and softmax at
8192x4096 and 16384x1024, and quantize at 4096x4096, each twice.
python3 examples/validate.py --quick --no-bench # every op checked, smaller shapes
python3 examples/validate.py # full size, then timed
The agents' tools¶
headroom, ab --json and new-op (agents) are tested in the
IR tier, without a GPU or torch:
- tests/hk/ir/test_headroom.py: kernel names from vLLM 0.31's traces (eager
and graphs), hk's and Inductor's land in their families; hk's and FlyDSL's
kernels are told from the engine's; the rank is the upper bound times a
ceiling, a ratio from another arm comes before the routing table's, the
record's ratio is used only against the kernel it measured, and with no
ratio the roofline is the ceiling; a graph trace without its replays is
blind; the CLI ranks a trace from elsewhere.
- tests/hk/ir/test_ab_verdicts.py: win, loss, tie and noise from rounds
with known spreads; rounds pair by number when one failed; every row has
the same keys; --from judges a raw file again.
- tests/hk/ir/test_new_op.py: the scaffold writes the op and its test, the
kernel traces and translates, the generated no-GPU tests pass, and the
scoreboard's --cases finds the row (tools/hk-bench/_cases.py).
On the GPU, tests/hk/gpu/test_new_op.py generates an op and runs its
check(): the exact answer bit for bit, the reference at every shape, and a
call the route declines running the reference. The scoreboard takes the
generated file as it is: scoreboard.py --cases DIR/NAME.py.
CI¶
.github/workflows/ci.yml runs the two tiers that need no GPU on pushes to
main and on pull requests, on GitHub's ubuntu-22.04 runner. A branch is
tested through its pull request (open a draft one, or
gh workflow run ci.yml --ref BRANCH), so it is not run twice; a newer push
cancels a PR's run in progress, but main's runs always finish:
- MLIR is prebuilt. It downloads MLIR 23.1.3, installed by
scripts/build_mlir.sh for that runner's CPython 3.10, from the
ci-mlir-23.1.3 release (0.9 GB). Building LLVM on the runner would take
hours.
- The dialect is built. scripts/build_hk_mlir.sh builds it against
that MLIR in about 20 seconds.
- The IR tier runs (tests/hk/ir), with tests/hk/engines, which
skips there: the runner has neither vLLM nor SGLang. The same leg builds
the cp310 wheel, retags it manylinux and runs
scripts/check_wheel_glibc.py on it: no wheel may need a newer glibc than
its tag (building).
- hipcc is installed from AMD's apt repository, as hip-dev and
rocm-device-libs of ROCm 7.1, about 2.3 GB.
- The codegen tier runs (tests/hk/codegen), under pytest-xdist.
- It is split over ten runners by a stable hash of the test id
(pytest --hk-shard I/10, tests/hk/conftest.py); the IR tier is an eleventh leg of
its own.
- Each shard keeps its own compile cache in actions/cache, falling back to any shard's.
A run restores the branch's cache, its base branch's, or main's.
- What goes cold: a kernel's cache key is hipcc plus the contents of the
headers its own compile reads, as the preprocessor lists them
(the cache). An edit to include/hk/cdna.cuh
recompiles the kernels that include it -- the CDNA ones -- and leaves the
RDNA ones cached; an edit to an rdna3/ header, the reverse.
- Warm, the tier takes about 10 seconds a shard.
- gfx1201 has legs of its own: the IR tier (IR tier, gfx1201) and the
codegen tier in four shards (codegen tier (I/4), gfx1201), both with
HK_ARCH=gfx1201 and the same ROCm 7.1 hipcc. They catch what only the RDNA4
build does wrong -- a schedule that spills there, a wait or a layout gfx12 has
and gfx1100 does not -- without a GPU. Their caches are keyed apart from
gfx1100's.
- A pull request moves a submodule's pin only on purpose and only forward
(
submodule pin,scripts/ci/check_submodule_pin.sh). If the PR pinsthird_party/HipKittensat another commit than its base, its title or body must say "HipKittens bump", and the new pin must descend from the base's (git merge-base --is-ancestorin HipKittens). A worktree's stale pin committed with an unrelated change would otherwise undo an earlier PR's library fix on main, and the tiers would not notice: the toolchains that needed the fix are not all in them.
A new MLIR, or a CPython other than the runner's, needs a new archive. Build
it with scripts/build_mlir.sh, pack the install tree with LLVM's and MLIR's
licence files, attach it to a release, and point MLIR_RELEASE and
MLIR_ASSET at it.
The GPU tier¶
HK_GPU=0 scripts/gpu_suite.sh OUTDIR runs tests/hk/gpu in groups, three
at a time on one GPU, and exits non-zero if a group failed. In CI it runs as
.github/workflows/gpu.yml, on self-hosted runners that the maintainers
operate, one job per target:
- gfx950 (MI355X) and gfx1100 (W7900D, the suite's groups sharded
over several cards): main's required checks.
- gfx950-vllm: the DeepSeek-V4.1 routes' tests and the engine contract
(tests/hk/gpu/test_engine_contract.py) in the vLLM deployment image
(vllm/vllm-openai-rocm:nightly-rocm100-…, ROCm 10). That image's compiler
is not rocm/pytorch's, and the difference has mattered three times: #35,
#39, and a dp128x224 spill. It runs the files in HK_CI_TESTS as one group
instead of the whole suite.
- gfx1201 (Radeon AI PRO R9700): the RDNA4 port's GPU tier
(below).
Every engine route that is on by default has a GPU test on every arch it is on
by default on: tests/hk/ir/test_route_coverage.py holds the table and fails
when a default-on (route, arch) has none, or when its test needs vLLM and is
not in gfx950-vllm's HK_CI_TESTS. The routes whose engine is not in a CI
image are tested through their stand-ins on the GPU
(tests/hk/gpu/test_route_paths.py): the function or method each route puts
in the engine's place, called as the engine calls it.
Each job runs the suite in a container that sees only the card it took, under
a lock of that card, so that a CI run and a measurement never share a GPU. On
the MI355X a job takes the first card of its runner's list (HK_CI_GPUS, in
order of preference) that is idle. Idle means that its lock is free, it is
not reserved ($HK_CI_LOCKS/reserved, one <card> <until, UTC> <who> a line,
for an announced window), no process of anyone's holds it (KFD), it is under
10% use and 3% VRAM, and no other CI container has it. The job log names the
card it took. A job whose container sees no GPU fails before any test runs (rocminfo must
show the card's arch). One whose tests nearly all skipped also fails (over half
skipped, or none passed). A tier that skipped everything is never green. A
job's page has its counts as an annotation and, in its summary, each group's
result and the failing tests. Its artifact (gfx950-report, gfx1100-report,
...) holds result.json, report.txt (with the tail of each failed group's
log) and the build log. The scripts the jobs run are in scripts/ci/; the
machines' names, addresses and paths are each runner's own configuration, not
this repository's.
The workflow runs on pushes to main and by hand
(gh workflow run gpu.yml --ref BRANCH, by a maintainer), and never on pull
requests: the repository is public, and a fork's code must not reach these
machines. Do not add a pull_request or pull_request_target trigger. One
run per arch and ref at a time: a push waits for the run in progress, and
replaces a push that was waiting, so commits pushed close together are tested
at the last. With a warm compile cache the suite takes a minute or two; a
change that recompiles the kernels takes about 25 minutes on gfx950 and about
30 on gfx1100. Before a pull request merges, a maintainer runs the GPU tier on
its head; gfx950 and gfx1100 must pass.
The gfx1201 runner¶
The gfx1201 job runs the GPU tier for the RDNA4 port in rocm/pytorch
rocm7.2.3 py3.12 -- the gfx950 job's image. A red gfx1201 fails the run.
The performance gate has a gfx1201 baseline,
tests/perf/baselines/gfx1201.json: gemm, attention, the norms, softmax and
the fp8 and int8 GEMMs, hk against torch, Inductor and Triton -- the arms the
job's container has. Pairs too noisy to gate are listed in the file with their
noise. Run it as gfx1100's is, by hand and alone on a card, before and after a change to a
kernel it times:
HK_ARCH=gfx1201 HK_GPU=0 scripts/perf_gate.sh
It is not part of the gfx1201 job: a card the GPU tier has just kept busy moves the large GEMMs' ratios further than the standalone baseline allows, and a required job cannot fail on a measurement condition.
The install matrix¶
.github/workflows/install.yml does what a new user does, on each supported
ROCm and GPU, from a stock image: it builds the cp312 wheel from the commit, as
a release builds it (manylinux, glibc 2.35), then in a fresh container per leg
it runs scripts/ci/install_smoke.py. Those steps are:
pip installof the wheel. The container holds nothing of hk but the wheel, the wheels the image lacks (pybind11),README.mdand the script. It has no checkout and no package index.import hkmust come from the installed wheel.- The README's quick start, as written: its
my_kernels.pyblock and itspython3 -m hk.checkcommand, read fromREADME.md.tests/hk/ir/test_install_smoke.pykeeps that extraction working on every PR. - One GPU test with an exact answer: attention with
V = 1returns exactly 1.0.
The JIT compiles with the image's own hipcc. A toolchain hk does not handle,
such as ROCm 10.1's clang 24, therefore fails here before a user meets it. A
leg whose GPU is missing fails: without one, hk.check only builds.
| leg | image | hipcc |
|---|---|---|
| gfx950, ROCm 7.2.3 | rocm/pytorch rocm7.2.3, Python 3.12 |
clang 22 |
| gfx950, ROCm 10.1.0 | rocm/pytorch rocm10.1.0, Python 3.12 |
clang 24 |
| gfx1201, ROCm 7.2.3 | rocm/pytorch rocm7.2.3, Python 3.12 |
clang 22 |
| gfx1100, ROCm 7.2.4 | the CI pod's image (rocm/pytorch rocm7.2.4) |
clang 22 |
Not covered yet:
- gfx1201 on ROCm 10.1: the image is not on its runner.
- gfx1100 in a container of its own: the pod has no container runtime, so its leg
installs with pip install --target into a fresh directory. Its ROCm is the
pod's.
- Python 3.14, which TheRock's images use: no cp314 wheel is built.
The matrix runs nightly on main and by hand, and must be green on the commit a release candidate is tagged from (releasing). It never runs on pull requests, because every leg takes a GPU.
The merge train¶
Ready pull requests are merged in batches: stacked on main in order, tested
together once (CI and the GPU tier), and squash-merged in that order if both
are green; a pull request that conflicts or turns the batch red is dropped from
it. The tool is scripts/ci/merge_train.py (--help), tested by
tests/hk/ir/test_merge_train.py.
The performance gate¶
scripts/perf_gate.sh catches a kernel that got slower. It runs alone on one
W7900D, by hand or nightly; HK_PERF_GATE=1
scripts/gpu_suite.sh runs it after the GPU tier as group perf.
HK_GPU=0 FLYDSL_ROOT=<FlyDSL checkout> scripts/perf_gate.sh [OUTDIR] # exit 1 on a regression
What it compares. The node is shared, and absolute times drift 3-5%
between sessions, more than most regressions worth catching. So the gate
never compares a time with a time from another run. It runs the scoreboard
(tools/hk-bench/scoreboard.py) with the out-of-the-box arms (hk, torch,
Inductor, Triton, FlyDSL), every case at 7 rounds of 50 calls. For each case
and each arm A it takes the ratio t_A / t_hk measured in that one run, and
tools/hk-bench/check_regression.py fails if the ratio fell below the
baseline's by more than that pair's tolerance. A slower node moves both
times and not the ratio; a slower hk kernel moves every ratio of its case.
The tuned arms are left out because they search on every run, which takes
minutes and adds a noise of its own.
Which rounds count (tools/hk-bench/_rounds.py). The scoreboard times
each arm in 7 rounds, each a profiler session of its own whose kernel
records it sums. It used to keep each arm's fastest round, and so kept a
round that could not have happened: hk's 8192x4096 RMSNorm at 97.4 us, 1.38
TB/s for the 134 MB the call moves through 864 GB/s of GDDR6, when every
other round of seven runs took 173 us. Now a round is rejected, and listed
with its reason in the run's log and --json, by any of three rules:
- records: a round whose kernel-record count differs from the arm's
usual one. A session that lost records sums fewer calls than it divides
by.
- ceiling: a round faster than the card can go at the case's footprint
(the distinct bytes the call reads and writes). Up to the 96 MB Infinity
Cache, back-to-back calls find their data resident, and the ceiling is the
fastest cache-resident rate measured on this card, 2.43 TB/s (a two-input
add at 80-96 MB, scoreboard.py --probe-ceilings; a copy reaches 1.77,
hk's 2048-row RMSNorm 1.82). Past the cache it is GDDR6's 864 GB/s
(a copy reaches 0.72-0.75, the 8192-row norms 0.78). GEMM and attention
FLOPs are held to the bf16 peak, 122.6 TFLOP/s. Each ceiling carries 15%
of headroom.
- lone: of the rounds left, the fastest when it is more than the larger
of 5% and 4x the other rounds' spread (their median over the second best)
ahead of the second best. Repeated while more than half the rounds remain.
Each round's calls are queued. A GPU spin of 1 ms a call goes first in each session, so the host has launched every call before the first runs and they run back to back, as in a captured graph, whatever the launcher costs. Without it a microsecond kernel's time was its launcher's.
An arm's time is the median of the rounds it kept, and its noise their median absolute deviation; the best kept round is reported beside it. The median cannot be set by one round.
check_regression.py holds reports to the same rules. A time in a report
that is still faster than the card can go (one written before the
scoreboard screened its rounds) is left out of a refresh, for that run and
pair only, and named in the baseline's left_out; in a check it is
IMPLAUSIBLE and the run cannot pass (exit 2). A run whose times are
another statistic than the baseline's (median of kept rounds, or best
round) is refused: every ratio would move.
Where the tolerance comes from. tests/perf/baselines/gfx1100.json is
built from several scoreboard runs, each its own process, spread over time.
For each (case, arm) the ratio is the median across runs and the noise is
the larger of two spreads: across runs, max |r_i / median - 1|; within a
run, the two arms' spreads (the median absolute deviation of their kept
rounds) summed, at their worst. Then
tolerance = max(3%, 3 x noise). A pair whose tolerance would pass 15% is
not gated, and is listed as such with its noise. The file records every
run's ratio beside the tolerance it produced. To change a tolerance,
re-measure the noise; editing the number by hand loosens the gate blindly.
Refreshing the baseline. Refresh it when the opponent changed (a new
torch, Triton or FlyDSL), when hk's kernels changed, when hk got faster on
purpose (pairs that beat their tolerance are reported as better), or for
another arch. The check prints a note for the first two: the baseline and
each run record torch's, Triton's and FlyDSL's versions, the device, a hash
of the generated C++ and hipcc flags of every hk kernel the run built or
loaded (kernels, hk.runtime.compile.built_fingerprint), and hipcc's
version (hipcc). hk's own version, the dialect's and toolchain (hipcc
with every header's contents) are recorded and not compared: they change without
the kernels changing. A HipKittens header change that leaves the generated C++ alone is the one change the note does not see.
HK_GPU=0 FLYDSL_ROOT=<FlyDSL checkout> scripts/perf_gate.sh --refresh 4
git diff tests/perf/baselines/gfx1100.json # every moved ratio is a claim
--refresh N runs the scoreboard N times (at least three) and rewrites the
baseline from them. Back-to-back runs see less drift than runs hours apart;
for a baseline that has to last, run check_regression.py --refresh on
reports from separate sessions. Read the runs before using them
(check_regression.py --audit lists every rejected round): a round faster
than the hardware can go is now rejected by the scoreboard and a time left
out by the refresh, but a spread far above its neighbours' is still the
measurement and not the kernel, and it would widen every tolerance of its
case. A refresh is a commit, with the reason in its message, and with any
run left out named there.
The gates for a change to the generated code¶
The move to MLIR was gated three times, each against the code it replaced, and the same gates are the bar for any later change to the generated C++ ("it needs Gate B again, resources first"). What each gate checks (what they found at the move is in the MLIR chapter):
- Gate A — the C++ against the code it replaces. Every shipped instantiation is rendered both ways and compared, and the whole no-GPU suite is the corpus, the error paths included: the new passes must refuse what the old ones refused, in the same words.
- Gate B — each kernel family against its old self. Every instantiation is rendered both ways; those that differ beyond names are compiled, and VGPRs, SGPRs, scratch, LDS and occupancy must match. Then the GPU tier, and old and new timed in one process, interleaved, the old as control.
- Gate C — the engine. vLLM serving Qwen3-8B with the patch, from the
tree before and after, each against stock vLLM: the routing counters must
match call for call, and the greedy output must match stock's. Run it with
VLLM_ENABLE_V1_MULTIPROCESSING=0. Without it the patch installed in the driver never reaches the model, and both arms time as stock; the tool prints the routing counters to catch exactly that.
Gate B's resource comparison needs only hipcc, and it is the part to run first: a change that spills is a wrong kernel, not a slow one (resource gates).
tools/surface/snapshot.py takes the evidence for Gates A and B on the kernels
that ship: the examples, hk.ops' row-kernel tables, and the kernels the routes
build for the target (on gfx950 K1, K2, gemm_cdna's candidates, attention, the
paged decode and int4; on gfx1100 / gfx1201 attention, K3, the paged decode,
the MoE GEMM, int4 and the GEMMs). Run it in the base checkout and in the
changed one, each with its own hk._mlir, for the same HK_ARCH, and diff:
python3 tools/surface/snapshot.py sources > base.jsonl # Gate A: every scaffold and the IR, hashed
python3 tools/surface/snapshot.py builds > base.jsonl # Gate B: resources and an ISA hash a function
python3 tools/surface/snapshot.py diff base.jsonl change.jsonl
The DSL-surface migration (design) calls these V0 (sources identical) and V1 (ISA and resources identical).
Reproducing¶
scripts/build_mlir.sh && scripts/build_hk_mlir.sh
ninja -C $HK_MLIR_BUILD check-hk
python3 -m pytest tests/hk/ir tests/hk/codegen -q
python3 -m pytest tests/hk/gpu -q # gfx1100
python3 examples/validate.py # gfx1100, full size
python3 -m pytest tests/hk/engines -q # in each engine's venv
python3 -m hk.integration.stack # vLLM's venv: the measured stack?
HK_GPU=3 scripts/perf_gate.sh # alone on one GPU, in vLLM's venv
scripts/build_wheel.sh
VLLM_ENABLE_V1_MULTIPROCESSING=0 HK_GPU_UTIL=0.85 python3 tools/hk-bench/vllm_e2e.py \
--context 1024 --batch 1,16 --tokens 72 --short 24 --reps 3 --arms stock,gemm