Skip to content

Conversation

@ethanwee1
Copy link

@ethanwee1 ethanwee1 commented Jun 19, 2025

Fixes https://ontrack-internal.amd.com/browse/SWDEV-538110
Related to f309230
Not a Navi specific failure:

  File "/opt/conda/envs/py_3.12/lib/python3.12/site-packages/torch/testing/_internal/common_device_type.py", line 1412, in only_fn
    return fn(slf, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/jenkins/pytorch/test/test_binary_ufuncs.py", line 1671, in test_cuda_tensor_pow_scalar_tensor
    self._test_pow(base, exp)
  File "/var/lib/jenkins/pytorch/test/test_binary_ufuncs.py", line 1482, in _test_pow
    self.assertEqual(actual, expected)
  File "/opt/conda/envs/py_3.12/lib/python3.12/site-packages/torch/testing/_internal/common_utils.py", line 4052, in assertEqual
    raise error_metas.pop()[0].to_error(
AssertionError: The values for attribute 'dtype' do not match: torch.float32 != torch.float64.

Using .to(actual) without specifying dtype/device assumes actual is a tensor or tensor-like, which may fail silently or promote. Fixed by explicitly matching dtype and device
Going from pytorch#107302
Fix:

root@ubb4-rack-22:/var/lib/jenkins/pytorch# TEST_CONFIG=default HIP_VISIBLE_DEVICES=0 PYTORCH_TEST_WITH_ROCM=1 python test/test_binary_ufuncs.py TestBinaryUfuncsCUDA.test_cuda_tensor_pow_scalar_tensor_cuda
/opt/conda/envs/py_3.12/lib/python3.12/site-packages/hypothesis/entry_points.py:23: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources

Running tests...
----------------------------------------------------------------------
.
----------------------------------------------------------------------
Ran 1 test in 0.141s

OK

Generating XML reports...
root@ubb4-rack-22:/var/lib/jenkins/pytorch# pip list | grep numpy
numpy                   2.1.2

@ethanwee1 ethanwee1 marked this pull request as ready for review June 19, 2025 21:02
@rocm-repo-management-api
Copy link

rocm-repo-management-api bot commented Jun 19, 2025

Jenkins build for 53e606cb22787b76a4c639ce0d28bfdedf2dc14d commit finished as FAILURE
Links: Blue Ocean view / Build artifacts

@rocm-repo-management-api
Copy link

rocm-repo-management-api bot commented Jul 1, 2025

Jenkins build for c5b3bdb47ebe821b434e1fe5b48ab39e60623584 commit finished as FAILURE
Links: Blue Ocean view / Build artifacts

@jithunnair-amd jithunnair-amd merged this pull request into release/2.6 Jul 7, 2025
2 of 6 checks passed
@jithunnair-amd jithunnair-amd deleted the release2.6_numpy_dtype branch July 7, 2025 16:03
@jithunnair-amd jithunnair-amd changed the title [release/2.6] Numpy dtype change [release/2.6] Update test_binary_ufuncs.py after numpy upgrade Jul 7, 2025
@jithunnair-amd
Copy link
Collaborator

jithunnair-amd commented Jul 7, 2025

Unintentionally did "Rebase and Merge", so squashed commits into ea75c6e and force pushed.

pruthvistony pushed a commit that referenced this pull request Jul 14, 2025
Cast numpy dtype result to torch dtype result before compare

Numpy returns `np.power(float32, int64) => float64` [Promotion rules for
Python scalars](https://numpy.org/neps/nep-0050-scalar-promotion.html)
Pytorch returns `torch.pow(float32, int64) => float32`

Reverts #2287 and fixes tests in a
different way

Fixes:
- SWDEV-538110 - `'dtype' do not match: torch.float32 != torch.float64`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_cuda_tensor_pow_scalar_tensor_cuda
- SWDEV-539171 - `AttributeError: 'float' object has no attribute
'dtype`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_long_tensor_pow_floats_cuda
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_complex_scalar_pow_tensor_cuda_*
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_float_scalar_pow_float_tensor_cuda_*
okakarpa pushed a commit that referenced this pull request Jul 14, 2025
Cast numpy dtype result to torch dtype result before compare

Numpy returns `np.power(float32, int64) => float64` [Promotion rules for
Python scalars](https://numpy.org/neps/nep-0050-scalar-promotion.html)
Pytorch returns `torch.pow(float32, int64) => float32`

Reverts #2287 and fixes tests in a
different way

Fixes:
- SWDEV-538110 - `'dtype' do not match: torch.float32 != torch.float64`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_cuda_tensor_pow_scalar_tensor_cuda
- SWDEV-539171 - `AttributeError: 'float' object has no attribute
'dtype`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_long_tensor_pow_floats_cuda
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_complex_scalar_pow_tensor_cuda_*
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_float_scalar_pow_float_tensor_cuda_*
okakarpa pushed a commit that referenced this pull request Jul 14, 2025
Cast numpy dtype result to torch dtype result before compare

Numpy returns `np.power(float32, int64) => float64` [Promotion rules for
Python scalars](https://numpy.org/neps/nep-0050-scalar-promotion.html)
Pytorch returns `torch.pow(float32, int64) => float32`

Reverts #2287 and fixes tests in a
different way

Fixes:
- SWDEV-538110 - `'dtype' do not match: torch.float32 != torch.float64`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_cuda_tensor_pow_scalar_tensor_cuda
- SWDEV-539171 - `AttributeError: 'float' object has no attribute
'dtype`
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_long_tensor_pow_floats_cuda
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_complex_scalar_pow_tensor_cuda_*
> -
test_binary_ufuncs.py::TestBinaryUfuncsCUDA::test_float_scalar_pow_float_tensor_cuda_*
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