Skip to content

Add Neuron dtype metadata for unfold and AA upsample - #97

Open
aws-charansg wants to merge 1 commit into
mainfrom
charansg/neuron-opinfo-dtypes-pt212-v2
Open

Add Neuron dtype metadata for unfold and AA upsample#97
aws-charansg wants to merge 1 commit into
mainfrom
charansg/neuron-opinfo-dtypes-pt212-v2

Conversation

@aws-charansg

Copy link
Copy Markdown

TestCommon.test_dtypes treats successful dtypes absent from OpInfo as unsupported. Neuron's unfold lowering accepts integral dtypes, while its antialiased bilinear upsample lowering accepts float16 and bfloat16 in addition to the default CPU dtype set.

Declare the implemented Neuron forward dtype sets in native OpInfo metadata. This removes the need for a private test override and does not change runtime lowering or backward support.

Test Plan:

python3 -m py_compile torch/testing/_internal/common_methods_invocations.py
spin quicklint -- --take RUFF
spin quicklint -- --skip PYREFLY
uvx --python 3.10 lintrunner@0.12.7 -a --skip PYREFLY
/opt/torch-neuronx/.venv/bin/pytest -o addopts= -q -v --tb=short --timeout=800 tests/pytorch_tests_native/test/test_ops.py::TestCommonNEURON::test_dtypes__upsample_bilinear2d_aa_neuron tests/pytorch_tests_native/test/test_ops.py::TestCommonNEURON::test_dtypes_nn_functional_unfold_neuron
/opt/torch-neuronx/.venv/bin/pytest -o addopts= -q -v --tb=short --timeout=1200 tests/pytorch_tests_native/test/test_ops.py::TestCommonNEURON::test_dtypes_nn_functional_unfold_neuron

The upsample test passed in the combined run. Unfold exceeded the local 800 second timeout, then passed alone in 805.01 seconds with the 1200 second limit. Full spin quicklint and literal lintrunner -a were also run; both reached only a pre-existing Pyrefly error in unchanged binary_cmp.py.

AI-assisted: Prepared with Kiro; reviewed and approved by the author.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

TestCommon.test_dtypes treats successful dtypes absent from OpInfo as
unsupported. Neuron's unfold lowering accepts integral dtypes, while its
antialiased bilinear upsample lowering accepts float16 and bfloat16 in
addition to the default CPU dtype set.

Declare the implemented Neuron forward dtype sets in native OpInfo metadata.
This removes the need for a private test override and does not change runtime
lowering or backward support.

Test Plan:
```
python3 -m py_compile torch/testing/_internal/common_methods_invocations.py
spin quicklint -- --take RUFF
spin quicklint -- --skip PYREFLY
uvx --python 3.10 lintrunner@0.12.7 -a --skip PYREFLY
/opt/torch-neuronx/.venv/bin/pytest -o addopts= -q -v --tb=short --timeout=800 tests/pytorch_tests_native/test/test_ops.py::TestCommonNEURON::test_dtypes__upsample_bilinear2d_aa_neuron tests/pytorch_tests_native/test/test_ops.py::TestCommonNEURON::test_dtypes_nn_functional_unfold_neuron
/opt/torch-neuronx/.venv/bin/pytest -o addopts= -q -v --tb=short --timeout=1200 tests/pytorch_tests_native/test/test_ops.py::TestCommonNEURON::test_dtypes_nn_functional_unfold_neuron
```

The upsample test passed in the combined run. Unfold exceeded the local 800
second timeout, then passed alone in 805.01 seconds with the 1200 second limit.
Full spin quicklint and literal lintrunner -a were also run; both reached only
a pre-existing Pyrefly error in unchanged binary_cmp.py.

AI-assisted: Prepared with Kiro; reviewed and approved by the author.
@@ -16324,6 +16320,7 @@ def sample_inputs_abs(op_info, device, dtype, requires_grad, op_kwargs=None, **k
OpInfo('nn.functional.unfold',
aten_name='im2col',
dtypes=floating_and_complex_types_and(torch.half, torch.bfloat16, torch.bool),
dtypesIf={'neuron': all_types_and_complex_and(torch.bool, torch.half, torch.bfloat16)},

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.

You cannot add anything neuron specific here - all of this code needs to be upstreamed to PyTorch

@@ -16496,6 +16493,7 @@ def sample_inputs_abs(op_info, device, dtype, requires_grad, op_kwargs=None, **k
supports_forward_ad=True,
supports_fwgrad_bwgrad=True,
dtypes=floating_types_and(torch.uint8),
dtypesIf={'neuron': floating_types_and(torch.uint8, torch.half, torch.bfloat16)},

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.

Same as above

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.

Please write this in a way that can be upstreamed and also raise a corresponding PR to PyTorch

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.

2 participants