Repository navigation
sdpa bwd: lead square A100 backward window graphs from a measured study - #2352
Conversation
Add 16 generated placement_table entries for sdpa_bwd_sm80 on cc 8.0 and lead them only when s_q == s_kv: class_key does not see squareness, and the earlier mixed study measured FROST slower than the backend on q < kv. Signed-off-by: 0z5a <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
@cudnn-ci-bot run python/sdpa/frost |
|
ready |
Anerudhan
left a comment
There was a problem hiding this comment.
Codex bot review · model: gpt-6-astra
Reviewed 1ff667bdd352 against base 819bb56f9e69.
Thank you for your contribution! The square-only guard keeps the measured A100 backward window classes ahead of the backend while preserving non-square and unmeasured routes. No actionable defect found in this change. I checked the full diff and a clean isolated merge with current develop.
Validation: Four focused placement/heuristic suites: 600 passed, 2 skipped at the PR head; 601 passed, 2 skipped on the merge with develop 819bb56. An independent probe using real recommendation and plan assembly covered all 16 new classes, 336 base-equal controls, 32 non-square routing checks and 16 existing other-row controls. Backend plans, knobs and OPENSOURCE selection remain intact (checklist D03/D05). Audited the supplied records: all nine frozen hashes and the applied Python tree hash match; replaying the repository generator on training data alone reproduces both outputs byte for byte. The disjoint holdout contains 128 timed square cases with three repeats and 32 untimed non-square routing checks. Recomputed author auto/default geomeans are 0.289 for BF16 and 0.358 for FP16; every timed case is faster and routing matches the stated rule. Host plan construction only, seven interleaved samples: median propose time was 12.07 us on base and 13.66 us on head for one promoted class. This is setup cost, not GPU execution time. Determinism: the promoted default SM80 path uses unordered floating-point dQ atomics. Explicit deterministic requests remain outside these placement entries and retain their prior route; the existing ordered dQ option is unchanged. No native repeatability claim is made.
Limitations: No native A100 run here. The supplied timing driver uses random backward inputs without a numerical reference and cannot establish correctness. Its reported values are medians across three repetitions, each retaining best event-timing rounds, with unlocked clocks; cold-cache and other cc 8.0 parts remain unmeasured. The author's existing python/sdpa/frost request is awaiting acknowledgment. I am reusing it. Two fork Actions runs require maintainer approval; their holds remain in place.
Approved: no P0 or high-risk P1 found. Remaining findings stay with the owner; merge timing stays with the owner.
|
Thank you for the contribution! Merged as c56f681 after verifying the approved full head and matching the final merge tree to the checked integration tree. The existing |
|
Pipeline not launched Reason: @0z5a is not allowlisted to run this bot. Ask an allowlisted maintainer to comment |
|
@cudnn-ci-bot run python/sdpa/frost |
|
Could not launch CI The bot failed before the pipeline started. The details are in the bot's log; ask a maintainer to look, then try |
Problem
sdpa_bwd_sm80is a trail-only row, so on an A100 a dense backward under a left window runs on the backend. For square graphs that is the slow choice: on a fresh holdout the default ran at a geomean of 3.46x (bf16) and 2.79x (f16) over the faster of FROST and backend, and up to 35x.Change
placement_table.py: 16 generatedalwaysentries forsdpa_bwd_sm80on cc 8.0 only. They cover bf16 and f16, d64 and d128, dense bottom-right causal with a left window, MHA and GQA, with S on and off the 128-key tile. They come fromgen.py study.json --margin 0.05 --emiton train, run from each dtype's study directory. Quotes are the only edit to the emitted lines.bwd/heuristics.py:SQUARE_ONLY_LEAD_ROWS = {"sdpa_bwd_sm80"}. In_measured_lead, a row in that set lifts only whens_q == s_kv.class_keydoes not see squareness, and an earlier mixed square / non-square study on the A100 measured q < kv graphs in these same classes up to 1.45x slower on FROST (b12 40/8 d64, q 128, kv 8960, window 8000: 7.0 vs 4.8 ms). That study failed its gate and is diagnostic only; it is why this one measures square graphs alone.class_key, because that would rekey every row's entries.lookupstill answers True), padded graphs, graphs without a window and cc 8.6 keep trailing.Measurement
Regret is a leg's time over the faster of FROST and backend, geomean (max).
lookupis True) and ran the same plan as the default. There were no errors.How the holdout was run
The first run trained, fitted and started the holdout, then hit its rental deadline after 167 of 416 holdout lines. Those lines were never scored. A second run on another A100-SXM4-40GB host ran the whole holdout from scratch on the same frozen case file, with the same fit. Its driver is the first one with the train loop replaced by checksums of the first run's generator output and a check that the applied tree reproduces the same python sha. The frozen-file check passed at its start. Both drivers, their diff and the unscored partial file are in the records.
Not measured
_measured_lead, so they were not timed.Testing
test_placement_table.py,test_sdpa_fwd_placement.py,test_sdpa_fwd_heuristics.pyandtest_sdpa_bwd_heuristics.pypass on the A100 at this commit (600 passed, in both runs), and black is clean on the three changed files.test_placement_table.pyand the two_measured_leadtests pass, andtest_sdpa_fwd_placement.py/test_sdpa_fwd_heuristics.pyfail exactly where develop itself fails there (no DSL or GPU). The rest oftest_sdpa_bwd_heuristics.pyneeds the DSL and was not run on that merge.TABLEinplacement_table.py, because all three append there. I have not run the placement tests on a merge with either.Records (machine-readable results, gate, frozen cases, train data, generator output and drivers): https://gist.github.com/0z5a/c19c233368d38573122414fa24bb5b3f