-
Notifications
You must be signed in to change notification settings - Fork 70
perf(kda): preserve SM90 workspace byte layout with bulk copies #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fkuner
wants to merge
7
commits into
inclusionAI:main
Choose a base branch
from
fkuner:codex/sm90-flashkda-raw-workspace
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74af6d6
perf(kda): use raw bulk copies for SM90 workspace
33f8da1
fix(kda): align intracard pre-scan workspace loads
6987386
chore(bench): preserve prefill dispatch behavior
4e67e4f
fix(kda): support bulk-copy election across CuTeDSL versions
3ad91f2
docs(bench): record SM90 raw workspace A/B
a3f2e39
docs(bench): add SM90 NCU spot check
38093d2
style(kda): satisfy ruff import formatting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # SM90 Raw Workspace Transport A/B | ||
|
|
||
| This benchmark isolates the FlashKDA workspace-transport change from | ||
| intracard context parallelism. Both runs use the same process configuration, | ||
| inputs, and GPU; only the cuLA checkout changes. | ||
|
|
||
| | Item | Value | | ||
| |---|---| | ||
| | Baseline | `d78f0075c69135fe191358fe8daf10e7383009d4` | | ||
| | Optimized | `4e67e4f55d241af600235898b55cde09bd90c165` | | ||
| | GPU | NVIDIA H200, SM90, 143,771 MiB device memory | | ||
| | Driver / CUDA | 570.148.08 / CUDA 13.0.48 | | ||
| | PyTorch | `2.8.0a0+34c6371d24.nv25.8` | | ||
| | CuTeDSL | `nvidia-cutlass-dsl==4.6.1` | | ||
| | FLA | `flash-linear-attention==0.5.0` | | ||
| | Inputs | BF16 Q/K/V/gate, FP32 state, H=64, D=128, `safe_gate=True` | | ||
| | CP mode | Serial K1+K2 (`use_intracard_cp=None`, planner resolves to a trivial plan) | | ||
| | Timing | 25 warmup + 100 measured iterations, IQR-mean CUDA events | | ||
| | Command | `python benchmarks/bench_kda_sm90_prefill.py --mode both` | | ||
|
|
||
| The test machine is an **H200**, and these results belong to the H200 SM90 | ||
| benchmark set. | ||
|
|
||
| ## Fixed length | ||
|
|
||
| | B | T | Baseline cuLA (ms) | Optimized cuLA (ms) | A/B | | ||
| |---:|---:|---:|---:|---:| | ||
| | 1 | 512 | 0.1241 | 0.1276 | 0.973x | | ||
| | 1 | 1024 | 0.1831 | 0.1583 | **1.157x** | | ||
| | 1 | 4096 | 0.6480 | 0.5704 | **1.136x** | | ||
| | 1 | 8192 | 1.2716 | 1.1108 | **1.145x** | | ||
| | 1 | 16384 | 2.5193 | 2.2082 | **1.141x** | | ||
| | 2 | 512 | 0.1365 | 0.1294 | **1.055x** | | ||
| | 2 | 1024 | 0.2431 | 0.1972 | **1.233x** | | ||
| | 2 | 4096 | 0.8974 | 0.7174 | **1.251x** | | ||
| | 2 | 8192 | 1.7648 | 1.4348 | **1.230x** | | ||
| | 2 | 16384 | 3.5085 | 2.8760 | **1.220x** | | ||
|
|
||
| ## Variable length | ||
|
|
||
| | Distribution | Sequences / total T | Baseline cuLA (ms) | Optimized cuLA (ms) | A/B | | ||
| |---|---:|---:|---:|---:| | ||
| | uniform | 10 / 4096 | 0.4746 | 0.3842 | **1.235x** | | ||
| | random | 10 / 4096 | 0.5537 | 0.4550 | **1.217x** | | ||
| | skewed | 10 / 4096 | 0.6640 | 0.5754 | **1.154x** | | ||
| | uniform | 20 / 4096 | 0.4621 | 0.3752 | **1.232x** | | ||
| | random | 20 / 4096 | 0.5487 | 0.4406 | **1.245x** | | ||
| | skewed | 20 / 4096 | 0.6717 | 0.5904 | **1.138x** | | ||
| | uniform | 10 / 8192 | 0.9028 | 0.7349 | **1.229x** | | ||
| | random | 10 / 8192 | 1.0406 | 0.8582 | **1.213x** | | ||
| | skewed | 10 / 8192 | 1.2627 | 1.0924 | **1.156x** | | ||
| | uniform | 20 / 8192 | 0.8594 | 0.6886 | **1.248x** | | ||
| | random | 20 / 8192 | 1.0135 | 0.8260 | **1.227x** | | ||
| | skewed | 20 / 8192 | 1.2605 | 1.1314 | **1.114x** | | ||
| | uniform | 10 / 16384 | 1.7411 | 1.4488 | **1.202x** | | ||
| | random | 10 / 16384 | 2.0374 | 1.6995 | **1.199x** | | ||
| | skewed | 10 / 16384 | 2.4653 | 2.1679 | **1.137x** | | ||
| | uniform | 20 / 16384 | 1.6536 | 1.3662 | **1.210x** | | ||
| | random | 20 / 16384 | 1.9532 | 1.5986 | **1.222x** | | ||
| | skewed | 20 / 16384 | 2.4597 | 2.2102 | **1.113x** | | ||
|
|
||
| ## Summary and numerical accuracy | ||
|
|
||
| - 27/28 configurations are faster; the only regression is B=1, T=512, | ||
| where the difference is within small-kernel launch noise. | ||
| - Geometric-mean A/B speedup is **1.1778x**; summing all measured cuLA | ||
| latencies gives a **15.45%** reduction. | ||
| - The optimized run reports `relative_rms_error` 0.004573–0.004924, | ||
| `rel_max` 0.007772–0.015000, and `mean_diff` 1.1e-5–1.3e-5 against | ||
| FLA. The baseline run reports the same accuracy values to the printed | ||
| precision, so the raw byte transport does not change numerical behavior. | ||
| - Flash-Flash-KDA reports isolated H100 workspace-transport reductions of | ||
| 23%, 34%, and 37% for fixed, uneven packed, and uniform packed CHUNK=16 | ||
| inputs. This cuLA result is a complete CP-off prefill A/B on a different | ||
| GPU and workload mix; it is therefore a comparable direction-of-gain | ||
| check, not an exact reproduction of those percentages. | ||
|
|
||
| ## Nsight Compute spot check | ||
|
|
||
| NCU 2025.3.0 (`--set full`, `--launch-count 2`, filtering the generated K1/K2 | ||
| names) profiled the first fixed shape, B=1, T=512, H=64. The six `ctc__*` | ||
| metrics were unavailable on this H200 setup, but the kernel duration and | ||
| L1-TEX/XBAR counters below were collected in both reports. | ||
|
|
||
| | Metric | Baseline | Optimized | Change | | ||
| |---|---:|---:|---:| | ||
| | K1 GPU duration | 41.152 us | 27.680 us | **-32.7%** | | ||
| | K2 GPU duration | 76.416 us | 75.072 us | **-1.8%** | | ||
| | K1 + K2 duration | 117.568 us | 102.752 us | **-12.6%** | | ||
| | K1 global-op-TMA-store XBAR bytes | 52.43 MB | 27.26 MB | **-48.0%** | | ||
| | K2 global-op-TMA-load XBAR bytes | 70.32 MB | 45.15 MB | **-35.8%** | | ||
|
|
||
| These counters show the same signature as the latency A/B: the main saving is | ||
| in K1's workspace stores, while K2's total duration changes little because | ||
| the recurrence and retained TMA loads remain unchanged. NCU does not expose | ||
| the internal TensorMap segment count directly, so the evidence is the | ||
| observable duration and transport counters rather than an inferred segment | ||
| number. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might not need to add a new BENCH_SM90_RAW_WORKSPACE md, just update the newest perf data in the
READMEandBENCHMARK_H200.The delta speedup against the newest flashkda could be recorded in the PR description.