Repository: pytorch
Issue: AttributeError: '_OpNamespace' 'aten' object has no attribute 'momentum'
Labels: needs reproduction,triaged,module: custom-operators,module: library,oncall: pt2,module: pt2-dispatcher,module: core aten

### 🐛 Describe the bug

I have a problem with the following piece of code

```python
import torch
from torch import nn


class GatedLinearUnit(nn.Module):
    def __init__(self, in_features: int) -> None:
        super().__init__()
        self.linear_1 = nn.Linear(in_features=in_features, out_features=in_features)
        self.linear_2 = nn.Linear(in_features=in_features, out_features=in_features)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return self.linear_1(x) * self.linear_2(x).sigmoid()


def test_gated_linear_unit_shape(in_features):
    """Tests if the output shape of the GatedLinearUnit is correct."""
    gated_linear_unit = GatedLinearUnit(in_features=in_features)

    input_tensor = torch.randn(8, 16)
    output_tensor = gated_linear_unit(input_tensor)

    assert output_tensor.shape == (8, 16)


if __name__ == "__main__":
    test_gated_linear_unit_shape()
```

if you run it with pytest or python the output is the same, i.e.,

```text
uv run python tests/test_gated_linear_unit.py
Traceback (most recent call last):
  File "/Users/argo/git/models/tests/test_gated_linear_unit.py", line 1, in <module>
    import torch
  File "/Users/argo/git/models/.venv/lib/python3.12/site-packages/torch/__init__.py", line 2486, in <module>
    from torch import _meta_registrations
  File "/Users/argo/git/models/.venv/lib/python3.12/site-packages/torch/_meta_registrations.py", line 10, in <module>
    from torch._decomp import (
  File "/Users/argo/git/models/.venv/lib/python3.12/site-packages/torch/_decomp/__init__.py", line 249, in <module>
    import torch._decomp.decompositions
  File "/Users/argo/git/models/.venv/lib/python3.12/site-packages/torch/_decomp/decompositions.py", line 20, in <module>
    from torch._higher_order_ops.out_dtype import out_dtype
  File "/Users/argo/git/models/.venv/lib/python3.12/site-packages/torch/_higher_order_ops/out_dtype.py", line 22, in <module>
    torch.ops.aten.momentum.default,
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/argo/git/models/.venv/lib/python3.12/site-packages/torch/_ops.py", line 1225, in __getattr__
    raise AttributeError(
AttributeError: '_OpNamespace' 'aten' object has no attribute 'momentum'
```

The environment I'm using is:

```text
uv pip list
Package           Version
----------------- ---------
filelock          3.16.1
fsspec            2024.12.0
iniconfig         2.0.0
jinja2            3.1.5
markupsafe        3.0.2
mpmath            1.3.0
mypy              1.14.1
mypy-extensions   1.0.0
networkx          3.4.2
numpy             2.2.2
packaging         24.2
pluggy            1.5.0
pytest            8.3.4
ruff              0.9.2
setuptools        75.8.0
sympy             1.13.1
torch             2.5.1
typing-extensions 4.12.2
```

Does anyone have an idea of what might be happening? I searched and found similar problems, but no definitive answers.

I’m running on a MacBook Pro M2, with the Apple M2 chip, and macOS Sonoma version 14.6.1.

Thanks for your help!

### Versions

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: macOS 14.6.1 (x86_64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.3.9.4)
CMake version: Could not collect
Libc version: N/A

Python version: 3.9.13 (main, Aug 25 2022, 18:29:29)  [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-10.16-x86_64-i386-64bit
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Apple M2

Versions of relevant libraries:
[pip3] flake8==4.0.1
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.5
[pip3] numpydoc==1.4.0
[pip3] pytorch-lightning==1.7.7
[pip3] torch==1.10.2
[pip3] torchmetrics==0.10.0
[conda] blas                      1.0                         mkl  
[conda] mkl                       2021.4.0           hecd8cb5_637  
[conda] mkl-service               2.4.0            py39h9ed2024_0  
[conda] mkl_fft                   1.3.1            py39h4ab4a9b_0  
[conda] mkl_random                1.2.2            py39hb2f4e1b_0  
[conda] numpy                     1.23.5                   pypi_0    pypi
[conda] numpydoc                  1.4.0            py39hecd8cb5_0  
[conda] pytorch                   1.10.2          cpu_py39h903acac_0  
[conda] pytorch-lightning         1.7.7              pyhd8ed1ab_0    conda-forge
[conda] torchmetrics              0.10.0             pyhd8ed1ab_0    conda-forge


cc @anjali411 @chauhang @penguinwu @zou3519 @bdhirsh @yf225 @manuelcandales @SherlockNoMad @angelayi