Skip to content

Add remaining high-priority rewriter extended tests#2899

Merged
gramalingam merged 5 commits intomainfrom
rama/tests2
Apr 23, 2026
Merged

Add remaining high-priority rewriter extended tests#2899
gramalingam merged 5 commits intomainfrom
rama/tests2

Conversation

@gramalingam
Copy link
Copy Markdown
Collaborator

Summary

Add 22 extended tests across 8 test files covering the remaining high-priority gaps identified in the rewriter test gap analysis.

New test files

File Tests Rule module
_cast_constant_of_shape_extended_test.py 5 _cast_constant_of_shape
_fuse_conv_affine_extended_test.py 5 _fuse_conv_affine
_redundant_scatter_nd_extended_test.py 3 _redundant_scatter_nd
_rotary_embedding_extended_test.py (rules/fusion) 3 PartialRotaryEmbedding23Fusion
_gqa_extended_test.py (rules/fusion) 2 GroupQueryAttentionFusion
gqa_extended_test.py (ort_fusions) 1 gqa ORT fusion
gqa_packed_qkv_extended_test.py (ort_fusions) 1 gqa packed QKV
cos_sin_cache_extended_test.py (ort_fusions) 2 cos_sin_cache

Key patterns used

  • @script() API with op.Constant(value=...) for embedded constants
  • Symbolic dimensions ("B", "S") where appropriate
  • Numerical validation via ORT or ONNX reference implementation
  • Negative tests: non-constant operands, padded convolutions, missing prerequisites, mismatched boundaries
  • Script generator with traced-if for clean negative test model construction

Modified existing file

  • _rotary_embedding_models.py: Added _make_partial_rotary_script(mismatched) generator for clean negative test construction

Follow-up to PR #2896.

gramalingam and others added 4 commits April 22, 2026 03:56
…les)

Extended test coverage for:
- CastConstantOfShape: dtype variants (int32, float64, bfloat16), same-dtype positive
- FuseConvAffine: non-constant weight/bias/scale negatives, padded pre-conv negative
- RedundantScatterND: axis=0 dynamic positive, partial indices negative, shape mismatch negative
- PartialRotaryEmbedding23: positive with dim attr validation, boundary mismatch negative, already-has-attr negative
- GQA (rules/fusion): wrong group count negative, different head config positive
- GQA (ort_fusions): no RotaryEmbedding negative
- GQA packed QKV: misaligned slice boundaries negative
- cos_sin_cache: non-constant inv_freq negative, constant inv_freq positive with ORT validation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Also adds a positive test with numerical validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…alue_info

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add _make_partial_rotary_script(mismatched) to _rotary_embedding_models.py
that uses a traced-if to generate matching or mismatched slice boundaries.
This replaces the graph-mutation approach in the test with a clean model
built directly from @script().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread onnxscript/rewriter/rules/fusion/_gqa_extended_test.py Fixed
Comment thread onnxscript/rewriter/ort_fusions/cos_sin_cache_extended_test.py Fixed
Comment thread onnxscript/rewriter/ort_fusions/gqa_extended_test.py Fixed
Comment thread onnxscript/rewriter/ort_fusions/gqa_packed_qkv_extended_test.py Fixed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 65.19231% with 181 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.48%. Comparing base (1911741) to head (fe3e63b).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...nxscript/rewriter/ort_fusions/gqa_extended_test.py 55.12% 34 Missing and 1 partial ⚠️
...script/rewriter/rules/fusion/_gqa_extended_test.py 50.70% 33 Missing and 2 partials ⚠️
...ewriter/ort_fusions/cos_sin_cache_extended_test.py 50.72% 33 Missing and 1 partial ⚠️
...er/rules/common/_fuse_conv_affine_extended_test.py 66.29% 29 Missing and 1 partial ⚠️
...script/rewriter/models/_rotary_embedding_models.py 14.81% 23 Missing ⚠️
...ules/common/_redundant_scatter_nd_extended_test.py 85.24% 8 Missing and 1 partial ⚠️
...writer/ort_fusions/gqa_packed_qkv_extended_test.py 77.41% 6 Missing and 1 partial ⚠️
...er/rules/fusion/_rotary_embedding_extended_test.py 89.83% 3 Missing and 3 partials ⚠️
...es/common/_cast_constant_of_shape_extended_test.py 94.28% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2899      +/-   ##
==========================================
- Coverage   72.51%   72.48%   -0.04%     
==========================================
  Files         250      258       +8     
  Lines       30955    31475     +520     
  Branches     2960     2973      +13     
==========================================
+ Hits        22448    22815     +367     
- Misses       7504     7650     +146     
- Partials     1003     1010       +7     

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

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 expands the ONNXScript rewriter “extended” test suite to cover additional high-priority fusion/rewrite gaps, and introduces a small model-generator helper to build cleaner negative rotary-embedding cases.

Changes:

  • Added new extended test modules for multiple rewriter rules (fusion, common, and ort_fusions).
  • Added negative/positive scenarios including boundary mismatches and prerequisite-missing cases.
  • Extended the rotary-embedding model helpers with a script generator for partial rotary patterns.

Reviewed changes

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

Show a summary per file
File Description
onnxscript/rewriter/rules/fusion/_rotary_embedding_extended_test.py Adds extended tests for PartialRotaryEmbedding23 (positive + negative cases).
onnxscript/rewriter/rules/fusion/_gqa_extended_test.py Adds extended tests for fusion GQA rule (negative wrong-group + a positive alt config).
onnxscript/rewriter/rules/common/_redundant_scatter_nd_extended_test.py Adds extended tests for redundant ScatterND elimination.
onnxscript/rewriter/rules/common/_fuse_conv_affine_extended_test.py Adds extended tests for Conv/Affine fusion rules (positive + multiple negatives).
onnxscript/rewriter/rules/common/_cast_constant_of_shape_extended_test.py Adds extended dtype-coverage tests for Cast+ConstantOfShape fusion.
onnxscript/rewriter/ort_fusions/gqa_packed_qkv_extended_test.py Adds extended negative test for packed-QKV GQA fusion.
onnxscript/rewriter/ort_fusions/gqa_extended_test.py Adds an extended negative test for ort_fusions GQA (no RotaryEmbedding prerequisite).
onnxscript/rewriter/ort_fusions/cos_sin_cache_extended_test.py Adds extended tests for cos/sin cache fusion (dynamic inv_freq negative + sanity positive).
onnxscript/rewriter/models/_rotary_embedding_models.py Adds _make_partial_rotary_script(mismatched=...) generator to support negative test construction.

Comment thread onnxscript/rewriter/rules/common/_redundant_scatter_nd_extended_test.py Outdated
Comment thread onnxscript/rewriter/rules/common/_redundant_scatter_nd_extended_test.py Outdated
Comment thread onnxscript/rewriter/ort_fusions/gqa_extended_test.py Outdated
- Fix mixed 'import onnxscript' + 'from onnxscript import ...' in 5 files
  by using only 'from onnxscript import ...' style
- Fix docstrings in gqa_extended_test.py and _redundant_scatter_nd_extended_test.py
  to match actual test coverage
- Use symbolic dim N in scatter_nd dynamic test to prevent constant folding
  from eliminating the pattern nodes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gramalingam gramalingam merged commit 30d3860 into main Apr 23, 2026
30 of 33 checks passed
@gramalingam gramalingam deleted the rama/tests2 branch April 23, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants