Skip to content

Fix build errors of GridSample and test failures in test_attention_fusion.py#27642

Merged
tianleiwu merged 2 commits intomainfrom
tlwu/fix_grid_sample_build_error
Mar 13, 2026
Merged

Fix build errors of GridSample and test failures in test_attention_fusion.py#27642
tianleiwu merged 2 commits intomainfrom
tlwu/fix_grid_sample_build_error

Conversation

@tianleiwu
Copy link
Copy Markdown
Contributor

@tianleiwu tianleiwu commented Mar 13, 2026

Description

This PR addresses a build error and subsequent test failures related to recent changes in GridSample and the transformer optimizer. Related PRs: #27201, #27556.

Changes

1. Fix GridSample Build Error

  • Removed an unused local variable mode_str in onnxruntime/core/providers/cuda/tensor/grid_sample.cc that was causing a warning (treated as error). After enabling c++20 in recent comment, this warning surfaces.
  • Ref: grid_sample.cc

2. Update GridSample Tests

  • Updated onnxruntime/test/providers/cpu/tensor/grid_sample_test_custom.inc to use default execution providers in RunTests instead of a hardcoded opset version, ensuring compatibility across different environments.

3. Revert Transformer Fusion Fallback

  • Reverted a recent change in onnxruntime/python/tools/transformers/fusion_skiplayernorm.py that enabled a fallback for SkipLayerNormalization fusion when symbolic shape inference fails.
  • This revert was necessary to avoid regressions in GPT-2 tests where model definitions contain typos that intentionally (or coincidentally) break shape inference.
  • Ref: fusion_skiplayernorm.py

4. Restore Transformer Test Parity

  • Updated onnxruntime/test/python/transformers/test_attention_fusion.py specifically test_qwen3_normalization_fusion to match the expected node counts after reverting the fusion fallback.
  • Ref: test_attention_fusion.py

Verification

  • build completed successfully.
  • onnxruntime/test/python/transformers/test_attention_fusion.py passes with "OK".

@tianleiwu tianleiwu changed the title Fix build error by grid_sample_test_custom.inc Fix build errors of GridSample and test failures in test_attention_fusion.py Mar 13, 2026
@yuslepukhin yuslepukhin requested a review from Copilot March 13, 2026 18:01
Copy link
Copy Markdown
Contributor

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 PR fixes a build error in the CUDA GridSample operator and reverts a transformer fusion fallback that caused test regressions, following up on PRs #27201 and #27556.

Changes:

  • Removed an unused local variable mode_str in the GridSample CUDA constructor that shadowed per-branch locals and caused a build warning/error.
  • Reverted the SkipLayerNormalization fusion fallback in fusion_skiplayernorm.py (from PR #27556) that broke GPT-2 tests, restoring the early-return when symbolic shape inference fails.
  • Updated GridSample custom tests and Qwen3 attention fusion test expectations to match the fixed code.

Reviewed changes

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

File Description
onnxruntime/core/providers/cuda/tensor/grid_sample.cc Remove unused outer-scope mode_str variable to fix shadowing build error
onnxruntime/test/providers/cpu/tensor/grid_sample_test_custom.inc Use default GetExecutionProviders() matching convention of all other GridSample tests
onnxruntime/python/tools/transformers/fusion_skiplayernorm.py Revert fallback: early-return when shape inference fails instead of using default skip_index
onnxruntime/test/python/transformers/test_attention_fusion.py Update Qwen3 test expectations (4 SLN, 0 SSLN) to match reverted fusion behavior

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

@tianleiwu tianleiwu enabled auto-merge (squash) March 13, 2026 20:29
@tianleiwu tianleiwu merged commit ed3f8bf into main Mar 13, 2026
104 of 105 checks passed
@tianleiwu tianleiwu deleted the tlwu/fix_grid_sample_build_error branch March 13, 2026 21:54
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.

4 participants