Skip to content

fix(pt): pass PACKED and Wigner strides in the flash-bwd tuning sweep - #6015

Open
iProzd wants to merge 1 commit into
deepmodeling:masterfrom
iProzd:0911_fix_dpa4_freeze
Open

fix(pt): pass PACKED and Wigner strides in the flash-bwd tuning sweep#6015
iProzd wants to merge 1 commit into
deepmodeling:masterfrom
iProzd:0911_fix_dpa4_freeze

Conversation

@iProzd

@iProzd iProzd commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Root cause: perf(pt): DPA4-family performance optimizations #6001 changed the two flash-attention backward kernels (_flash_bwd_kernel: new PACKED constexpr; _flash_bwd_block_kernel: 20 → 26 positional args) and updated the launcher _launch_backward, but not the two raw launches in the tuning sweep sweep_flash_bwd, which omit PACKED and the six Wigner strides.
  • Trigger: the sweep runs only in dp --pt freeze at DP_TRITON_INFER >= 2 (the perf(pt): DPA4-family performance optimizations #6001 default) when the GPU's built-in table lacks the family. perf(pt): DPA4-family performance optimizations #6001 filled the new families only for the RTX PRO 6000, so on other GPUs (e.g. H20) every default DPA4 freeze fails: TypeError: dynamic_func() missing 1 required positional argument: 'PACKED'.
  • Fix: derive packed and the strides with _rotation_strides, as _launch_backward does; no kernel, table or policy change. Test: a GPU regression test runs the real flash_bwd sweep (fails on master, passes with the fix).

Validation (H20)

  • New test: fails before the fix, passes after.
  • test_descriptor_sezm_triton.py: 37 passed.
  • Default-level dp --pt freeze (examples/water/dpa4): all six tuning groups complete.
  • test_sezm_export.py + test_dpa4_export.py: 45 passed; ruff and pre-commit clean.

Follow-ups

Summary by CodeRabbit

  • Bug Fixes

    • Improved flash-attention backward configuration sweeps to correctly handle packed layouts and Wigner strides.
    • Ensured both edge and block backward kernels receive the required layout metadata during tuning.
  • Tests

    • Added GPU coverage for real backward-sweep execution and configuration registration.
    • Validated that selected configurations come from the expected candidate sets.

`dp --pt freeze` of a DPA4/SeZM checkpoint crashed in the Triton tuning
sweep at the default `DP_TRITON_INFER=2` on GPUs whose built-in table has
no `flash_bwd_edge` family (for example NVIDIA H20):

    TypeError: dynamic_func() missing 1 required positional argument: 'PACKED'

deepmodeling#6001 added the `PACKED` rotation-layout constexpr to `_flash_bwd_kernel`
and six Wigner-stride arguments to `_flash_bwd_block_kernel`, and updated
the production launcher `_launch_backward`, but the two raw launches in
`sweep_flash_bwd` kept the old argument lists: `launch_edge` never passed
`PACKED`, and `launch` still passed 20 of the 26 positional arguments.

Derive `packed` and the Wigner strides with `_rotation_strides`, exactly
as `_launch_backward` does, and pass them to both launches. Add a GPU
regression test that runs the real `flash_bwd` sweep on a tiny shape
through `tune_missing_configs`; the existing tuning test replaces every
sweep with a fake and could not catch the signature drift.
Copilot AI lite review requested due to automatic review settings September 11, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fixes are covered by regression tests and no unresolved blocking issues were identified.

Pull request overview

Fixes Triton flash-attention backward tuning sweeps by passing required PACKED metadata and Wigner strides, with GPU regression coverage.

Changes:

  • Corrects backward kernel launch arguments.
  • Adds real sweep regression testing.
  • Validates configuration registration.
File summaries
File Summary
source/tests/pt/model/test_descriptor_sezm_triton.py Adds regression coverage for the flash-backward sweep.
deepmd/pt_expt/kernels/triton/sezm/sweep_tile_configs.py Corrects backward tuning launch arguments.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 022082c2-dc16-4e7c-b05b-d672fec4e08c

📥 Commits

Reviewing files that changed from the base of the PR and between 28b7d06 and 1ce0e2e.

📒 Files selected for processing (2)
  • deepmd/pt_expt/kernels/triton/sezm/sweep_tile_configs.py
  • source/tests/pt/model/test_descriptor_sezm_triton.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The flash-attention backward sweep now derives Wigner strides and packed-layout metadata for both launch paths. A GPU-gated test runs the real sweep and validates its registered tile configurations.

Changes

Flash backward sweep

Layer / File(s) Summary
Backward kernel launch metadata
deepmd/pt_expt/kernels/triton/sezm/sweep_tile_configs.py
The per-edge and edge-block launches use _rotation_strides for Wigner input and output strides. The per-edge launch also passes the computed PACKED flag.
Real backward sweep validation
source/tests/pt/model/test_descriptor_sezm_triton.py
A GPU-gated test runs the real backward sweep with empty built-in tables and validates registered configurations and coverage keys.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: outisli

Merge Risk: ⚪ Minimal · up to 1ce0e

The backward sweep metadata fix and regression coverage are merge-ready with no remaining actionable risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: passing the PACKED flag and Wigner strides in the flash-bwd tuning sweep.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.99%. Comparing base (28b7d06) to head (1ce0e2e).

Files with missing lines Patch % Lines
.../pt_expt/kernels/triton/sezm/sweep_tile_configs.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6015      +/-   ##
==========================================
- Coverage   77.25%   76.99%   -0.26%     
==========================================
  Files        1153     1153              
  Lines      138930   138933       +3     
  Branches     5056     5056              
==========================================
- Hits       107328   106976     -352     
- Misses      29717    30075     +358     
+ Partials     1885     1882       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@OutisLi OutisLi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sweep launch arguments match the current backward-kernel signatures and the production launcher. The added regression test exercises the real sweep and configuration registration.

The with-comm freeze failure mentioned in the follow-up notes is addressed in #6016.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants