Repository: pytorch/benchmark
Issue: benchmark install failed due to mpmath upgrade to 1.4.0.a0 pre-release
Root cause: External Dependency Breakage

The latest benchmark install.py reported an error which releted to Sympy and mpmath
Related issue: https://github.com/sympy/sympy/issues/26273 

**Error info**:
```
#15 23.49   File "install.py", line 36, in <module>
#15 23.49     versions = get_pkg_versions(TORCH_DEPS)
#15 23.49   File "/workspace/benchmark/utils/__init__.py", line 24, in get_pkg_versions
#15 23.49     module = importlib.import_module(module)
#15 23.49   File "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module
#15 23.49     return _bootstrap._gcd_import(name[level:], package, level)
#15 23.49   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
#15 23.49   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
#15 23.49   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
#15 23.49   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
#15 23.49   File "<frozen importlib._bootstrap_external>", line 843, in exec_module
#15 23.49   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/torchvision/__init__.py", line 6, in <module>
#15 23.49     from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/torchvision/models/__init__.py", line 2, in <module>
#15 23.49     from .convnext import *
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/torchvision/models/convnext.py", line 8, in <module>
#15 23.49     from ..ops.misc import Conv2dNormActivation, Permute
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/torchvision/ops/__init__.py", line 23, in <module>
#15 23.49     from .poolers import MultiScaleRoIAlign
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/torchvision/ops/poolers.py", line 10, in <module>
#15 23.49     from .roi_align import roi_align
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/torchvision/ops/roi_align.py", line 4, in <module>
#15 23.49     import torch._dynamo
#15 23.49   File "/workspace/pytorch/torch/_dynamo/__init__.py", line 2, in <module>
#15 23.49     from . import convert_frame, eval_frame, resume_execution
#15 23.49   File "/workspace/pytorch/torch/_dynamo/convert_frame.py", line 30, in <module>
#15 23.49     from torch.fx.experimental.symbolic_shapes import (
#15 23.49   File "/workspace/pytorch/torch/fx/experimental/symbolic_shapes.py", line 63, in <module>
#15 23.49     from torch.utils._sympy.functions import FloorDiv, Mod, IsNonOverlappingAndDenseIndicator
#15 23.49   File "/workspace/pytorch/torch/utils/_sympy/functions.py", line 1, in <module>
#15 23.49     import sympy
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/sympy-1.12-py3.8.egg/sympy/__init__.py", line 30, in <module>
#15 23.49     from sympy.core.cache import lazy_function
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/sympy-1.12-py3.8.egg/sympy/core/__init__.py", line 9, in <module>
#15 23.49     from .expr import Expr, AtomicExpr, UnevaluatedExpr
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/sympy-1.12-py3.8.egg/sympy/core/expr.py", line 4159, in <module>
#15 23.49     from .mul import Mul
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/sympy-1.12-py3.8.egg/sympy/core/mul.py", line 2193, in <module>
#15 23.49     from .numbers import Rational
#15 23.49   File "/opt/conda/lib/python3.8/site-packages/sympy-1.12-py3.8.egg/sympy/core/numbers.py", line 4567, in <module>
#15 23.49     _sympy_converter[type(mpmath.rational.mpq(1, 2))] = sympify_mpmath_mpq
#15 23.49 AttributeError: module 'mpmath' has no attribute 'rational'
#15 ERROR: process "/bin/sh -c git clone -b ${TORCH_BENCH_BRANCH} https://github.com/pytorch/benchmark.git &&     cd benchmark && if [ \"${TORCH_BENCH_COMMIT}\" = \"default\" ]; then git checkout `cat /workspace/pytorch/.github/ci_commit_pins/torchbench.txt`; else git checkout ${TORCH_BENCH_COMMIT}; fi && pip install --no-deps -r requirements.txt &&     pip install --no-cache Jinja2==3.1.2 markupsafe==2.0.1 beartype==0.15.0 &&     python install.py --continue_on_fail &&     pip install --upgrade numpy" did not complete successfully: exit code: 1
------
```

**Root cause**

- `mpmath` 1.4.0.a0 was installed when pytorch whl installed. And `Sympy` hasn't got chance to integrate the new feature of `mpmath`
```
#13 666.7 Searching for mpmath>=0.19
#13 666.7 Reading https://pypi.org/simple/mpmath/
#13 666.7 Downloading https://files.pythonhosted.org/packages/bf/43/28116b6ad78fcf009071a12f702aeae6c9fbc2cfd814c5eefaacda1a52aa/mpmath-1.4.0a0-py3-none-any.whl#sha256=1b60ef0e9ea0e13e11580e31dc0c47284b9a26b1384bcef577ddda5e29b2836b
#13 666.8 Best match: mpmath 1.4.0a0
#13 666.8 Processing mpmath-1.4.0a0-py3-none-any.whl
#13 666.8 Installing mpmath-1.4.0a0-py3-none-any.whl to /opt/conda/lib/python3.8/site-packages
#13 666.8 Adding mpmath 1.4.0a0 to easy-install.pth file
#13 666.8 detected new path './MarkupSafe-2.1.5-py3.8-linux-x86_64.egg'
#13 666.8 
#13 666.8 Installed /opt/conda/lib/python3.8/site-packages/mpmath-1.4.0a0-py3.8.egg
#13 666.8 Searching for typing-extensions==4.9.0
#13 666.8 Best match: typing-extensions 4.9.0
#13 666.8 Adding typing-extensions 4.9.0 to easy-install.pth file
#13 666.8 detected new path './mpmath-1.4.0a0-py3.8.egg'
#13 666.8 
#13 666.8 Using /opt/conda/lib/python3.8/site-packages
#13 666.8 Finished processing dependencies for torch==2.3.0a0+git53f5035
#13 DONE 669.5s
```



How do you install the pytorch version? Did you install it from nightly release channel, or did you build it from the source?
If you are building it from source code, can you please retry it from a clean environment?

This might also be a pytorch installation issue, cc @malfet @atalman 

This seems to be related to https://github.com/pytorch/test-infra/pull/4948/files

The problem has been fixed by upstream.