perf(tensilelite): build client MX inputs once per launch and reuse them across solutions #14725
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #14725"
general
weight: 0.35
yzhang93
JIRA ID : AIHPBLAS-5431
Motivation
Tuning MXFP8 kernels for gfx950 (for example with geko, which starts one
tensilelite-clientper generation) spends most of each launch preparing inputs. With HostPreSwizzle scales the client:For a 2.3 GB batched MXFP8 problem, input preparation takes about 30 s of a 33 s launch, 10x the 3 s BF16 needs for the same problem and tiles. This PR roughly halves the launch time and cuts the per-candidate overhead from 0.29 s to 0.16 s.
Technical Details
Two commits, both limited to the TensileLite client's
DataInitialization:1. Reuse MX inputs across solutions of the same problem (
DataInitialization.hpp).preSolutionre-initializes MX inputs only when the problem or the solution's MFMA K changes. With validation off,prepareGPUInputsno longer re-runsinitializeCPUInputson every run.2. Build MX inputs once per launch (
DataInitialization.cpp,DataInitializationHelpers.hpp):- The canonical pass is skipped when the data and scale descriptors are unchanged.
- The swizzled GPU scale is built from the canonical copy instead of regenerating the data.
detail::naturalMXScaleFromCanonical(the inverse ofrestrideMXScaleBufferKFast) recovers the scalesgenerateMXInputemitted.detail::swizzleNaturalMXScaleappliesgenerateMXInput's swizzle with the same grid. For gfx950 that is{MN, K blocks}, with K blocks taken along the operand's K dimension, so it is correct for every transpose. Generation is seeded, so the bytes match regenerating with the layout.- The
mx-data-generator=0path, which kept its own per-batch copy of the natural scales to swizzle, now uses the same helpers.- 2D MX scales (
MXBlockFree > 1, #13630) already swizzle the downsampled canonical copy, so only their generation is skipped on unchanged descriptors.Test Plan
tensilelite-tests,DataInit_test.cpp, 34 new):-
SwizzleNaturalMXScaleTest(32 cases):swizzleNaturalMXScaleapplied togenerateMXInput's unswizzled scales must equal whatgenerateMXInputemits with the layout. It covers gfx950 and gfx1250, A and B, both transposes, FP8 and FP4, and K = 512 and K = 576 (padded K blocks). A sentinel byte checks the swizzled size.-
NaturalMXScaleFromCanonical(2 cases): must invert the K-fast restride and copy the prefix otherwise.tensilelite-testssuite on MI355X, develop vs this PR.--prebuilt-client):common/gemm/gfx950/subtile_mxfp4.yaml(NT, full validation),common/gemm/gfx950/mx32f8_tn.yaml,common/gemm/gfx950/fp8_mxfp4_bf16_tn_act.yamlandcommon/ductile/gfx950/f8_tn_mx_subtile.yaml.num-elements-to-validate=128, MXScaleFormat 1. MI355X, 256-core host, ROCm 7.2. Medians of 3 runs on an otherwise idle GPU, and of 6 runs for three concurrent launches on separate GPUs (as when several tuning jobs share a host). "Setup" is the time to the first result row. The BF16 reference uses the same problems, bias/activation and macro tiles with MFMA 16x16x32 and DepthU 64/128 (20 candidates, so its launch time is not comparable).Test Result
subtile_mxfp4.yaml.| config | validated results |
| --- | --- |
|
common/gemm/gfx950/subtile_mxfp4.yaml| 9,937 ||
common/gemm/gfx950/mx32f8_tn.yaml| 34,816 ||
common/gemm/gfx950/fp8_mxfp4_bf16_tn_act.yaml| 360 ||
common/ductile/gfx950/f8_tn_mx_subtile.yaml| 1 |subtile_mxfp8_multi_du_multi_partition.yamlandmxfp4_fp8_bf16_tn_act.yamlfail during kernel generation (IndexErrorin the subtile kernel writer) on both, before the client runs.| problem | | develop | + commit 1 | + commit 2 (this PR) | BF16 reference |
| --- | --- | --- | --- | --- | --- |
| 1152x64x384x5120 (A: 2.3 GB) | launch | 33.0 s | 31.7 s | 15.4 s | |
| | setup | 29.9 s | 29.8 s | 13.5 s | 3.1 s |
| | per further candidate | 0.29 s | 0.16 s | 0.16 s | 0.22 s |
| 5120x64x384x576 (padded K blocks) | launch | 18.0 s | 17.7 s | 9.5 s | |
| | setup | 15.8 s | 16.1 s | 7.9 s | 2.2 s |
| | per further candidate | 0.20 s | 0.13 s | 0.13 s | 0.14 s |
| 1152x64x384x5120, three concurrent launches | launch | 45.6 s | 43.3 s | 18.5 s | |
With validation off (
num-elements-to-validate=0, 2 runs), setup goes from 36–37 s to 12.9 s for 1152x64x384x5120 and from 20.5–23.4 s to 7.7 s for 5120x64x384x576, with the same per-candidate times.Submission Checklist