Repository navigation
[HIP] [OPUS] [FlyDSL] Add OPUS FP4 indexer writer and shared BF16 GEMM weights - #7798
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
|
@aiter-bot review |
@yhl-amd — please take a look. Triage: if GLM serves but its output is malformed it may be the ATOM framework (@valarLip); if the box, GPU, disk or network is unhealthy it may be the machine (@gyohuangxin). Re-comment |
Add optional gfx950 BF16 preshuffle support to skinny and unsplit full-tile HGEMM. Preserve raw defaults, handle strided 3D inputs, and add 52 qualified GLM/K3 shuffled tuning rows with focused eager/graph coverage.
Prepare the standard AITER BF16 weight layout before warmup and use it in both Mono Q paths and native prefill/fallback. Remove the private packed copy, preserve storage identity, and guard unsupported deployments and older AITER. Requires ROCm/aiter#7798 commit 9beaa73de1. Validated with 630 focused ATOM tests and 40 TP8 indexer graph cases. Document accepted native GEMM tradeoffs and remaining full-model qualification.
Add measured M10240/M16384/M32768 rows for N4096 K1536/K2048. All 138 tested ASM/FlyDSL candidates pass; independent native tgemm lookup and mutable graph replay validate the six persisted rows. The existing shuffled ASM 256x256 kernel remains best in this sweep; raw and existing smaller-M rows are unchanged.
Bring #3042 and #3099 into whx/k31-perf for recipe F8 Implements wuhuikx/LLM-Booster#496. Merges #3099 at 945cf21 and #3042 at 0b27b59 into whx/k31-perf, so prefill tasks measure on the code recipe F8 runs. The OPUS FP4 indexer cache is selected with --index-cache-layout mfma and needs an aiter with ROCm/aiter#7798. Conflict resolution: - kimi_mla_gdn_attn.py build_kv_cache_tensor keeps #3042's index_scale alongside both sides' index_cache. - sparse_indexer_fp4.py assert_fp4_indexer_supported takes #3042's packed_writer without prefill_ubatching, which #3136 removed. - test_lmcache_mp_native_scheduler.py keeps #3136's _shipped_tokens and #3042's block_ids assertion. - test_lmcache_mp_builder_views.py drops a stale atom.utils.tbo stub. - test_dsa_indexer_fp4_layout.py skips the HIP writer test through import_guard where Triton or AITER is absent. GSM8K 5-shot on recipe F8 (without --spec-decode-acceptance-length), n=1319: flexible-extract 0.9727, strict-match 0.9719 (stderr 0.0045).
|
@aiter-bot review |
|
aiter-bot — queued behind 1 review(s); expect to start in about 22 min. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
[ROCm/aiter] PR #7798 — [HIP] [FlyDSL] Add OPUS FP4 indexer writer and shared BF16 GEMM weights
Review (advisory):
Validation (deterministic): NOT RUN — triage found 3 candidate test targets and no unique one (op_tests/test_flydsl_hgemm.py, op_tests/test_indexer_qk_rope_quant_and_cache.py, op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py) and auto-validation is disabled (REVIEW_AUTO_VALIDATE=0) — environment gap, not a PR defect
Perf (advisory): NOT RUN — no perf target selected (same 3 candidates, none unique) and auto-validation disabled; the PR's own tables (writer vs the superseded #7730 Triton writer, 9 AB/BA samples; shared vs raw native, 11 AB/BA samples/shape) are head-side measurements, not re-run here
Size: 1016 lines / 13 files — over the review bar
Design (advisory): SPLIT — the HIP OPUS FP4 writer (aiter/ops/cache.py, csrc/include/cache.h, csrc/include/rocm_ops.hpp, csrc/kernels/cache_kernels.cu, op_tests/test_indexer_qk_rope_quant_and_cache.py) and the FlyDSL/asm shared BF16 GEMM weights (aiter/ops/flydsl/gemm_kernels.py, gemm_a16w16_gfx950.py, gemm_a16w16_skinny_gfx950.py, aiter/tuned_gemm.py, the two model_configs CSVs, op_tests/test_flydsl_hgemm.py) are independent seams sharing no symbol — the repo's own CI guide asks for one backend tag per PR and this title carries two
Human: recommend valarLip review whether one shuffle_weight (16,16) BF16 weight shared between the native GEMM and Mono is the right contract for GLM-5.3 / K3.1 Pro indexer layers given the PR's own M32768 numbers, and whether the OPUS FP4 page/scale layout in csrc/kernels/cache_kernels.cu is the right writer contract for ATOM#3042
📝 [verified] The shuffle_weight (16,16) offset math now lives in three places — aiter/ops/shuffle.py (the permute), aiter/ops/flydsl/kernels/gemm_a16w16_gfx950.py and gemm_a16w16_skinny_gfx950.py (the DMA offsets, verified to agree today) — so a future shuffle_weight layout change must be mirrored in both kernels or the GEMM silently reads garbage from correctly-shaped weights. Author must cross-reference the three sites (or hoist the tile math into one shared helper) so a layout change cannot miss a kernel.
…3042) * feat(mono): extend DSA FP8/FP4 indexers and qlen-6 verification Add OPUS-compatible MXFP4 cache plumbing, wider decode and verify planners, graph-time local short-context execution, and conditional DSA reset. Include regression tests, a standalone GLM benchmark, and the complete FP8/FP4 performance comparison with known short-context regressions. * style: format DSA Mono kernels and benchmark tests Apply Black without changing the Python AST of any formatted file. * perf(mono): tune graph-local qlen-6 indexer for short contexts * perf(mono): enable K3.1 Pro short-context indexer tuning Publish FP8/OPUS FP4 measurements with separate provenance for fresh DCP1 and prior DCP8 results. Adapt checkpoint loading to nested text configuration and preserve the existing model identifiers. * fix(indexer): bind K3 FP4 cache planes with OPUS layouts Bind packed K3 index keys and scales, publish both planes, and include them in PAGE-unit ownership and copies. Map MFMA logical blocks onto OPUS physical page-64 groups while preserving block-table IDs and V4.1 page-8 behavior. Initialize the scale tensor before KV pool binding and cover the layout contracts with regression tests. * fix(dsv41): align Mono reference scorer with FP4 weight ABI Unfold K1's scaled FP32 index weights and cast them to BF16 for the OPUS FP4 debug scorer, passing the scale explicitly. Preserve the FP8 weight path and add regression tests for both contracts. This only changes the debug-check path. * test(mono): trim redundant DSA indexer coverage * Optimize DeepSeek V4.1 Mono scoring and TopK * Support standalone LMCache MP for OPUS FP4 DSA Mono Allow standalone LMCache MP with shared DSA and K3 Mono while retaining other connector and plugin restrictions. Snapshot DSA FP4 layout to separate OPUS and legacy cache namespaces, and reject worker layout mismatches. Add focused gate, namespace and opaque plane relocation coverage. Verified with 501 regression tests and TP8 GLM-5.3-MXFP4 / K3.1 Pro CPU cache reload smoke tests. * Support TP8 DCP8 LMCache MP for GLM and K3 Use global-token block boundaries while preserving per-rank PAGE shards and native checkpoint images. Disable TP rank collapse under DCP and isolate interleave-specific cache namespaces. Validate with 1374 passing cross-feature tests, 168 DCP1 configuration parity checks, and TP8 DCP8 GLM/K3 OPUS FP4 full-model CPU reload smoke tests. * Address DSA Mono layout, writer and coverage review * Use AITER HIP OPUS writer for DSA FP4 native paths * [Mono] Share shuffled BF16 indexer weights with native GEMM Prepare the standard AITER BF16 weight layout before warmup and use it in both Mono Q paths and native prefill/fallback. Remove the private packed copy, preserve storage identity, and guard unsupported deployments and older AITER. Requires ROCm/aiter#7798 commit 9beaa73de1. Validated with 630 focused ATOM tests and 40 TP8 indexer graph cases. Document accepted native GEMM tradeoffs and remaining full-model qualification. * [Mono] Keep local tuning artifacts out of the indexer PR Remove benchmark harnesses, measured JSON, historical docs, and standalone kernel-debug tests from the final tree. Retain compact layout, admission, buffer, weight ownership, and LMCache/DCP regression coverage; consolidate shared-weight checks into the existing hook suite. No production code changes. 714 focused tests pass. * Address DSA Mono review with CPU planners and separate V4.1 scope * test: consolidate DSA indexer regression coverage * Fix DSA score-grid cache identities and review leftovers * Fix DSA local-step compilation identity and cache reset layouts * Derive OPUS cache shapes and test local reset symbols on CPU * Forward merged writer options and align the FP4 cache interface Pass scale_layout and rope_dim on all HIP writer calls. Use None for absent index scale planes and the shared scale_block_bytes name while retaining explicit MFMA admission. Re-export CPU symbol naming, handle a missing K3 layer stack, and read established DCP Config fields directly. Update the focused regression fixtures and checks. * Fix LMCache test Config fixtures for direct DCP fields * Preserve OPUS scale tensor inputs during compiled warmup
Summary
Companion for ROCm/ATOM#3042, based on main
1350defcfe: HIP OPUS writer support plus the shared BF16 indexer-weight GEMM extension. Supersedes the now-closed Triton alternative #7730; it does not depend on that PR. ATOM84ae29323requires the shared-weight support in9beaa73de1. Deploy matching AITER Python sources and a rebuiltmodule_cacheextension.indexer_qk_rope_quant_and_cachewithscale_layout="opus"andrope_dim=0/64for GLM-5.3 / K3.1 Pro-style DSA indexers.[M,2,32,H/16]; K data/scales[pages,4,64,16]/[pages,2,32,4], matching OPUS MQA.Shared BF16 Indexer Weights
9beaa73de1: optionalflydsl_hgemm(..., bpreshuffle=True)for gfx950 BF16 skinny/unsplit full-tile GEMM, using AITER's standard(16,16)shuffle. Raw defaults remain unchanged; strided 3D inputs cannot fall through toF.linearon shuffled bytes.86719be77ffills the missing M10240/M16384/M32768 points: 58 tuning rows total, 29/model, through M32768. N4096, K2048/GLM or K1536/K3. Existing raw and smaller-M rows are unchanged.out=, unsupported-policy and raw-layout checks pass. The large-M sweep checks 138 ASM/FlyDSL candidates (23/shape), all passing; six fresh nativetgemmdispatch runs verify the persisted rows and graph replay with changed inputs.Independent persisted-config verification below: checkpoint BF16 weights, gfx950, 11 alternating AB/BA samples, 32 calls/graph x 16 replays. Positive latency change means slower than unshuffled native. No whole-model claim.
M32768 remains about 9.4% slower for K3 and 7.2% for GLM versus raw native. This is an existing shared-weight tradeoff, not a regression introduced by these six CSV rows.
Validation
gfx950 in
jun_atom2:f1485d59f, FlyDSL 0.5.0): 1183 regression tests pass. Eight native-forward graph cases cover NoPE/RoPE64, DCP1/DCP8 adapter semantics, and full/short slots. Every replay emits one HIP writer and checks Q/K data, scales, untouched rows and changed Q/weights/slots. DCP world size is mocked in this integration test.git diff --checkpass. Full-model accuracy/performance and multi-rank DCP have not been rerun for this PR.Writer Performance
Microseconds: Triton / HIP (HIP latency change). BF16 inputs, 50% owned K slots, three missing tail slots, all Q computed. Median of 9 alternating AB/BA samples, 32 writer calls/graph, 20 replays/sample. Writer only, no MQA/TopK/communication.
M=8 remains 0.09-0.47 us slower than Triton despite splitting Q/K work; this is not a claim of a universal speedup or full-model improvement.
CI fallback-test fix (
e93ae5e9de)The OPUS stale-row fallback test still mocked
tuned_gemm.get_gfxafter dispatch moved toget_gfx_runtime. Update that mock to the runtime architecture probe while preserving its framework-fallback and single-warning assertions. The preceding Standard Tests job failed only this case (36 passed, 9 skipped). The failure reproduces at the PR sources; after the fix, the file passes 28 tests with GPUs hidden (18 GPU tests skipped), and the current head passes 37 tests on gfx950 (9 skipped). Black and Ruff pass. This commit changes one test line and does not alter GEMM dispatch or kernels.