Skip to content

[PT FE] Improve torch.export tests#33980

Open
mvafin wants to merge 1 commit intoopenvinotoolkit:masterfrom
mvafin:mvafin/pt_fe/tests_export
Open

[PT FE] Improve torch.export tests#33980
mvafin wants to merge 1 commit intoopenvinotoolkit:masterfrom
mvafin:mvafin/pt_fe/tests_export

Conversation

@mvafin
Copy link
Contributor

@mvafin mvafin commented Feb 5, 2026

Details:

  • Validate fx operation kind to confirm test reproduces the operation

Tickets:

@mvafin mvafin requested a review from Copilot February 5, 2026 11:23
@mvafin mvafin requested a review from a team as a code owner February 5, 2026 11:23
@github-actions github-actions bot added the category: PyTorch FE OpenVINO PyTorch Frontend label Feb 5, 2026
Copy link
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 enhances torch.export tests by adding validation of FX graph operations. The changes ensure that tests properly verify the presence of expected operations in the FX graph representation, improving test accuracy and catching potential regressions.

Changes:

  • Added fx_kind parameter validation to verify expected FX operations exist in exported models
  • Implemented helper methods to check FX operation existence and auto-derive FX operation names from TorchScript kinds
  • Updated test methods across multiple files to specify expected FX operations

Reviewed changes

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

Show a summary per file
File Description
tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py Core infrastructure: added FX operation validation methods and assertion logic
tests/layer_tests/pytorch_tests/test_unary_ops.py Added fx_kind parameter for abs operation validation
tests/layer_tests/pytorch_tests/test_split.py Added fx_kind parameters for split operations and modernized super() calls
tests/layer_tests/pytorch_tests/test_slice.py Added fx_kind for unsqueeze validation and cleaned up model
tests/layer_tests/pytorch_tests/test_shift_operations.py Added fx_kind for shift operations
tests/layer_tests/pytorch_tests/test_scatter.py Added fx_kind for scatter_add validation
tests/layer_tests/pytorch_tests/test_resolve_conj_neg.py Added fx_kind for resolve operations
tests/layer_tests/pytorch_tests/test_repeat.py Added fx_kind and removed precommit_torch_export marker
tests/layer_tests/pytorch_tests/test_permute.py Added fx_kind for permute validation
tests/layer_tests/pytorch_tests/test_neg.py Added fx_kind for built-in neg function
tests/layer_tests/pytorch_tests/test_min_max.py Added fx_kind for min/max operations
tests/layer_tests/pytorch_tests/test_matmul.py Formatting cleanup (trailing comma)
tests/layer_tests/pytorch_tests/test_masked_fill.py Used skip_if_export for inplace parameter
tests/layer_tests/pytorch_tests/test_loop.py Added fx_kind for while_loop validation
tests/layer_tests/pytorch_tests/test_logsumexp.py Added fx_kind for logsumexp validation
tests/layer_tests/pytorch_tests/test_lerp.py Added fx_kind with conditional logic for inplace variant
tests/layer_tests/pytorch_tests/test_index_copy_.py Used skip_if_export for inplace parameter
tests/layer_tests/pytorch_tests/test_fake_quantize.py Added fx_kind for fake quantization operations
tests/layer_tests/pytorch_tests/test_eye.py Added fx_kind for eye operations
tests/layer_tests/pytorch_tests/test_expand.py Added fx_kind for expand/broadcast validation
tests/layer_tests/pytorch_tests/test_device.py Removed precommit_torch_export markers
tests/layer_tests/pytorch_tests/test_convolution.py Added fx_kind for convolution operations
tests/layer_tests/pytorch_tests/test_cond.py Added fx_kind for conditional operations
tests/layer_tests/pytorch_tests/test_clamp.py Added fx_kind for clamp operations
tests/layer_tests/pytorch_tests/test_broadcast_tensors.py Added fx_kind and refactored parametrization to reduce test combinations
tests/layer_tests/pytorch_tests/test_bitwise_ops.py Added fx_kind for bitwise operations
tests/layer_tests/pytorch_tests/test_atan2.py Added fx_kind for atan2 validation
tests/layer_tests/pytorch_tests/test_as_strided.py Added fx_kind for as_strided validation
tests/layer_tests/pytorch_tests/test_aliases.py Added fx_kind for alias operations
tests/layer_tests/pytorch_tests/test_add.py Added fx_kind for add and removed precommit_torch_export marker
tests/layer_tests/pytorch_tests/test_strided_const.py Modernized super() call and updated return statement

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

if fx_kind is None:
fx_kind = self._derive_fx_kind_from_kind(kind)

assert fx_kind is not None, f"fx_kind must be provided explicitly or derivable from kind. Graph:\n{em.graph}"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The error message could be more helpful by specifying what 'kind' value was provided. Consider: f\"fx_kind must be provided explicitly or derivable from kind='{kind}'. Graph:\\n{em.graph}\"

Suggested change
assert fx_kind is not None, f"fx_kind must be provided explicitly or derivable from kind. Graph:\n{em.graph}"
assert fx_kind is not None, f"fx_kind must be provided explicitly or derivable from kind='{kind}'. Graph:\n{em.graph}"

Copilot uses AI. Check for mistakes.
if not isinstance(fx_kind, (tuple, list)):
fx_kind = [fx_kind]
for op in fx_kind:
assert self._check_fx_op_exist(em, op), f"Operation {op} doesn't exist in FX graph. Graph:\n{em.graph}"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The error message uses the contraction "doesn't" which should be spelled out as "does not" for consistency with professional error messages.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: PyTorch FE OpenVINO PyTorch Frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant