Repository navigation
Conversation
Blockscale split-K uses atomic output accumulation. Four or more K partitions can complete in different orders, producing different BF16 or FP16 results for identical inputs. Clamp CK and CKTile splitK exponents to 1 after validating the requested range. Keep tuned kernel selection and the two-partition path, cap future tuner candidates, and cover direct requests for exponents 2 and 3. Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
There was a problem hiding this comment.
Pull request overview
This PR makes A8W8 blockscale GEMM deterministic when tuned configs request split-K exponents > 1 by clamping splitK to at most 1 in both CK and CKTile compiled entry points, and by preventing the tuner from exploring splitK >= 2. It also adds a regression test that exercises the previously nondeterministic tuned cases (requested exponents 2 and 3) and asserts bitwise-repeatable output versus a splitK=1 reference.
Changes:
- Clamp runtime
splitKexponent to<= 1in CK and CKTile blockscale GEMM entry points to avoid order-dependent atomic accumulation forsplitK >= 2. - Cap CK/CKTile tuning loops so they no longer generate candidates with
splitK >= 2. - Add an op test that requests
splitKexponents 2 and 3 (both backends) and verifies outputs match asplitK=1reference across repeated runs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| op_tests/test_gemm_a8w8_blockscale_determinism.py | Adds regression coverage ensuring requested splitK exponents 2/3 are effectively clamped to a deterministic path. |
| csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale.cu | Clamps splitK to <= 1 before computing KBatch for the CK blockscale entry point. |
| csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale_cktile.cu | Clamps splitK to <= 1 before computing KBatch for the CKTile blockscale entry point. |
| csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale_tune.py | Caps tuning search space to splitK <= 1 for both CK and CKTile tuning task generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
there are serveral config files have splitK=2/3 entries that were selected by the tuner precisely because they were faster. Clamping at the C++ layer silently degrades these to splitK=1 without re-tuning. We should either re-tune affected shapes or document the expected perf impact |
Clamping tuned split-K exponents without changing the selected tile materially regresses affected shapes. Replace all 431 nondeterministic CK and CKTile rows with measured exponent 0 or 1 configurations and guard against future higher split-K entries. Signed-off-by: Markus Hartikainen <[email protected]> Co-authored-by: Cursor <[email protected]>
|
The concern is valid. I enumerated every tuned blockscale row with a stored Keeping the original tile and silently changing only KBatch regressed median operator device time by 24.95% on gfx950 and 39.48% on gfx942. The p95 regressions were 106.07% and 83.78%. I retuned all 431 affected rows against deterministic exponent 0 and 1 candidates on matching gfx950/256-CU and gfx942/304-CU hardware. The raw exponent-1 and production-clamped paths differed by 8.12% at p95 on gfx950, so a new candidate is used only when it is more than 10% faster than the clamped original kernel. Otherwise the existing kernel is retained with an explicit exponent of 1. After selection, the median impact relative to the original higher split-K choices is 10.61% on gfx950 and 34.23% on gfx942. The original exponent-2/3 choices produced multiple outputs for 384 rows. All 431 selected deterministic configurations passed the BF16-cast dequantized FP32 GEMM reference check and were bitwise stable across 20 calls.
|
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
|
No activity for 15 days, so this is now labelled |
|
No activity for 15 days, so this is now labelled |
| splitK=split_k, | ||
| ) | ||
| else: | ||
| gemm_a8w8_blockscale_ck(x, weight, x_scale, w_scale, out, splitK=split_k) |
There was a problem hiding this comment.
Could we wire this regression into the standard op-test entry point? This file only defines pytest tests, while .github/scripts/aiter_test.sh invokes op tests with python3 "$file" and has no pytest dispatch for this file. Direct execution therefore exits 0 without checking the CSV split-K values, repeated-output determinism, or invalid split-K rejection. Please add a guarded pytest entry point (or an explicit CI pytest invocation) so the normal suite actually runs these regressions.
Summary
Make CK and CKTile blockscale GEMM output deterministic for configured split-K exponents greater than 1.
splitKis an exponent, soKBatch = 1 << splitK. Exponents 2 and 3 create four and eight partial sums that are accumulated into the output with atomic adds. Their completion order can change BF16 or FP16 results between identical calls.Both compiled entry points now validate the requested exponent, preserve values 0 and 1, and clamp larger valid exponents to 1. This retains the CSV-selected kernel and the bitwise-repeatable two-partition path instead of bypassing tuned dispatch.
The CK and CKTile tuning loops are also capped at exponent 1. Direct regression coverage requests exponents 2 and 3 from both entry points and compares 20 outputs against an exponent 1 reference.
This addresses the root cause behind vLLM #42240.
Validation
4 passed in 19.64s.4 passed in 541.10s.git diff --checkpassed.