Skip to content

fix(stinkytofu): count a ds credit wait as elapsed time; merge CDNA5 DAG Phases C and D - #14805

Merged
KKyang merged 2 commits into
developfrom
users/kkyang/stinkytofu-time-model
Nov 2, 2026
Merged

KKyang merged 2 commits into
developfrom
users/kkyang/stinkytofu-time-model

Conversation

@KKyang

@KKyang KKyang commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Closes #14731

Motivation

In the gfx1250 DAG scheduler a ds_load that waits for a free credit charged the wait to a separate scheduling budget and left the clock, the credit queue and the queued WMMA cover untouched. Inside a WMMA window that over-charged the next ds_load (the queue never aged); outside a window the wait was not counted at all, so queuedCoverCycles() could be overstated. The two cases were also handled by two phases (C inside the window, D outside) that ran the same pick and the same wait handling.

Technical Details

Two commits.

  • refactor: merge Phases C and D into one NonWmmaFill pick. Only Phase C advanced time when nothing was pickable. The merged rule picks once and, inside a window with nothing pickable, advances to the oldest queued WMMA's end and picks once more. The generated gfx1250 asm is identical to develop on all 21 perf yamls. The "Phase C / D" row of the pick table in the DAG AGENTS.md now describes the single phase.
  • fix: a ds credit wait is elapsed time. Every wait (ds credit, RAW, hazard) advances the timeline, so the credit queue ages and the cover shrinks by the wait. The ds fit check reads coIssueCyclePos_ directly. dsSchedulingBudgetUsed_ and chargeDsCreditWait are removed. This is a behaviour change, not a refactor: the asm differs from the previous commit on 16 of the 21 gfx1250 perf yamls, all MAF yamls included. The barrier, signal and tensor_load positions in the main loop are unchanged on the MAF yamls, mxf8_tn_medium and bbs_tn_medium; f8_tn_medium moves its barriers by 4 to 5 WMMAs and mxf4_tn_medium its first barrier by 2.
  • Tests. WmmaRefill_FixedBatchIssuesBatchSizeWmmasPerRefill and WmmaRefill_DynamicFillsToTarget expect WddWWWWWWWWWddWWdddd instead of WddWWWWWWWWWdWdWdddd: after a credit wait the queue has aged, so the next load needs no refill WMMA in front of it. The counts of loads and WMMAs are unchanged.
  • Not in this PR. The refill and the ds pacer still use different units (cycles and WMMA counts); that is a separate topic. The three *_finetune* yamls carry ds knob values tuned against the old accounting and may need a retune.

Test Plan

StinkyTofu unit and FileCheck suites. Asm comparison against develop on the 21 gfx1250 perf yamls (maf, mab, medium). Hardware A/B against develop on every yaml whose asm differs, with interleaved develop/branch runs in both orders and output validation on.

Test Result

Unit tests: 1842 of 1842 pass. Performance results are recorded in the JIRA ticket for this work, not in this description.

Status

Draft. The description matches the code on the branch.

Submission Checklist

…Fill pick

Phase C (inside a WMMA window) and Phase D (outside) ran the same pick and the same
wait handling; only Phase C advanced time on a miss. Fold them into one pick that,
inside a window with nothing pickable, advances to the oldest queued WMMA's end and
picks once more. No behaviour change.

The "Phase C / D" row of the pick table in the DAG AGENTS.md now describes the single phase.

Checked: gfx1250 asm identical to develop on all 21 perf yamls (maf/mab/medium),
StinkyTofu ctest 1826/1826.
A ds_load that waited for a free credit used to charge the wait to a separate scheduling
budget (dsSchedulingBudgetUsed_) and leave the clock, the credit queue and the queued WMMA
cover untouched. Inside a WMMA window that over-charged the next ds_load (the queue never
aged), and outside it the wait was not counted at all, so queuedCoverCycles() could be
overstated.

Every wait (ds credit, RAW, hazard) now advances the timeline in the one NonWmmaFill rule:
the credit queue ages and the cover shrinks by the wait. The ds fit check reads
coIssueCyclePos_ directly; dsSchedulingBudgetUsed_ and chargeDsCreditWait are removed.

This is a behaviour change, not a refactor: the generated asm differs from the previous
commit on 16 of the 21 gfx1250 perf yamls (all MAF yamls included). The barrier, signal and
tensor_load positions in the main loop are unchanged on the MAF yamls and on mxf8_tn_medium
and bbs_tn_medium; f8_tn_medium moves its barriers by 4 to 5 WMMAs and mxf4_tn_medium its
first barrier by 2.

WmmaRefill_{FixedBatch,Dynamic} expected shapes change from WddWWWWWWWWWdWdWdddd to
WddWWWWWWWWWddWWdddd: after a credit wait the queue has aged, so the next load needs no
refill WMMA in front of it.

ctest: 1842 of 1842.
@therock-pr-bot

therock-pr-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: shared/stinkytofu/src/transforms/asm/dag/CDNA5.hpp, shared/stinkytofu/tests/unit/asm/DAGSchedulerPassTest.cpp; no test file found
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #14805      +/-   ##
===========================================
- Coverage    77.35%   77.33%   -0.02%     
===========================================
  Files         2894     2894              
  Lines       487162   487192      +30     
  Branches     73731    73720      -11     
===========================================
- Hits        376823   376767      -56     
- Misses       85448    85540      +92     
+ Partials     24891    24885       -6     
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 50.96% <ø> (ø)
TensileLite-Unit 84.03% <ø> (ø)
hipBLAS 90.62% <ø> (ø) Carriedforward from 20910a1
hipBLASLt 68.35% <ø> (-0.24%) ⬇️
hipCUB 82.68% <ø> (ø) Carriedforward from 20910a1
hipDNN 86.96% <ø> (ø) Carriedforward from 20910a1
hipFFT 42.66% <ø> (ø) Carriedforward from 20910a1
hipRAND 76.12% <ø> (ø) Carriedforward from 20910a1
hipSOLVER 69.67% <ø> (ø) Carriedforward from 20910a1
hipSPARSE 87.03% <ø> (ø) Carriedforward from 20910a1
rocBLAS 69.15% <ø> (-0.04%) ⬇️ Carriedforward from 20910a1
rocFFT 47.23% <ø> (ø) Carriedforward from 20910a1
rocRAND 57.32% <ø> (ø) Carriedforward from 20910a1
rocSOLVER 76.74% <ø> (ø) Carriedforward from 20910a1
rocSPARSE 83.54% <ø> (ø) Carriedforward from 20910a1
rocThrust 93.15% <ø> (ø) Carriedforward from 20910a1

*This pull request uses carry forward flags. Click here to find out more.
see 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KKyang
KKyang merged commit 8731419 into develop Nov 2, 2026
209 of 226 checks passed
@KKyang
KKyang deleted the users/kkyang/stinkytofu-time-model branch November 2, 2026 00:43
KKyang added a commit that referenced this pull request Nov 2, 2026
…s pacer's line (#14813)

Refs #14730

Stacked on #14805 (base branch `users/kkyang/stinkytofu-time-model`);
review that one first. This PR's own diff is the two commits after it.

## Motivation

A ds_load's right to issue in the gfx1250 DAG scheduler was assembled
inline from three pieces: the mode2 WAR gate (a heuristic that holds a
load back until enough matrix ops have issued after its WMMA reader),
the overlap check against the queued WMMAs' sources, and a "relief" that
lifts the gate when the region is behind its ds rate. The relief used a
second, region-wide rate (`expectedDs = dsTotal * wmmaIssued /
wmmaTotal`) that the ds pacer does not share: the pacer plans by stage
and batch, so the two could disagree about whether a load is due.

## Technical Details

Two commits.

- **`refactor`: one predicate for the ds WAR gate.** `warGateRelieved()`
and `dsWarClear(ds)` name the checks; the candidate test is `pickedDS &&
dsWarClear(pickedDS)`. Same checks in the same order. The generated
gfx1250 asm is identical to the previous commit on all 21 perf yamls.
- **`fix`: lift the gate from the ds pacer's own line.**
`DsSpreadPacer::behind()` is the number of loads the even line has
placed by the current batch minus the loads the stage has issued; the
gate is relieved when it is positive. Without a pacer plan there is no
relief. `expectedDs` is removed. This is a behaviour change, not a
refactor: the asm differs from the previous commit on 8 of the 21
gfx1250 perf yamls (`bbs_tn_m64_mab`, `bbs_tn_mab`, `bbs_tn_medium`,
`f8_tn_mab`, `mxf4_tn_mab`, `mxf8_tn_mab`, `nvf4_tn_mab`,
`nvf4_tn_maf`); the other 13 are identical.
- **Tests.** `relief_releases_a_region_behind_its_ds_rate` now follows
the pacer's batches (two loads after four WMMAs, one after eight, the
last when WMMA #1's gap closes at ten).
`stamps_survive_a_wmma_free_region` moves to its own file,
`dag_mode2_war_gate_stamps.stir`, and runs with `--no-ds-spread`: with
the pacer, the relief lifts the gate after the first batch and hides
what that case checks (gate stamps survive a region cut). Its assertions
are unchanged.
- **Not in this PR.** #14730 also asks for one model of the hazard
across the pacer's release time, the pipe-op gate and the queued-WMMA
overlap. The pacer's release time (`earliestAt`) is a planning input and
not a gate, the pipe-op gate is a tested heuristic that measurably
helps, and the overlap check is the hardware truth, so they are not
merged here.

## Test Plan

StinkyTofu unit and FileCheck suites. Asm comparison against the
previous commit on the 21 gfx1250 perf yamls (maf, mab, medium).
Hardware A/B against the previous commit on every yaml whose asm
differs, with interleaved runs in both orders and output validation on.

## Test Result

Unit and FileCheck tests: 1846 of 1846 pass. Performance results are
recorded in the JIRA ticket for this work, not in this description.

## Status

Draft. The description matches the code on the branch.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(stinkytofu): decide whether a ds credit wait should advance time in the CDNA5 DAG

2 participants