Skip to content

Fix false positive grid_swizzle_conflict validation for Triton swizzled 1D grids#32

Merged
sandlbn merged 6 commits into
mainfrom
mzweilin/fix_triton_validator_swizzle_check
May 27, 2026
Merged

Fix false positive grid_swizzle_conflict validation for Triton swizzled 1D grids#32
sandlbn merged 6 commits into
mainfrom
mzweilin/fix_triton_validator_swizzle_check

Conversation

@mzweilin
Copy link
Copy Markdown
Collaborator

@mzweilin mzweilin commented May 27, 2026

This PR replaces the validator’s line-based grid heuristic with an AST-based check so it only flags actual 2D grid launches when GROUP_SIZE_M swizzling is present. The previous implementation incorrectly treated a 1D single-tuple grid lambda as 2D whenever the line contained multiple triton.cdiv(...) calls.

It also adds regression coverage for both cases:

  • a valid 1D swizzled grid that should pass
  • a real 2D grid with swizzling that should still fail

Claude Code was smart enough to identify this false positive result, but it is better to fix the bug.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates Xe-Forge’s Triton static validator to avoid false positives for grid_swizzle_conflict by replacing a line-based heuristic with an AST-based grid dimensionality check, and adds regression tests for 1D vs 2D swizzled grids.

Changes:

  • Replaced the line-count/comma heuristic for detecting 2D grids (when swizzling is present) with an AST-based analysis of grid assignments.
  • Added regression tests to ensure a 1D swizzled grid is allowed and a 2D swizzled grid is rejected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/xe_forge/core/validator.py Switches grid_swizzle_conflict detection from a string/line heuristic to AST-based detection for more accurate 1D vs 2D classification.
tests/test_validator.py Adds tests covering allowed 1D swizzled grids and rejected 2D swizzled grids.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xe_forge/core/validator.py Outdated
Comment thread tests/test_validator.py
mzweilin added 3 commits May 27, 2026 11:39
Signed-off-by: Weilin Xu <weilin.xu@intel.com>
Signed-off-by: Weilin Xu <weilin.xu@intel.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/xe_forge/core/validator.py Outdated
Signed-off-by: Weilin Xu <weilin.xu@intel.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mzweilin
Copy link
Copy Markdown
Collaborator Author

@sandlbn ready to review

Copy link
Copy Markdown
Contributor

@sandlbn sandlbn left a comment

Choose a reason for hiding this comment

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

LGTM

@sandlbn sandlbn merged commit a53b5b9 into main May 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants