Skip to content

torch.compile does not work since 2.2.1 on MacOS for some models #124497

@maxbartel

Description

@maxbartel

🐛 Describe the bug

The execution hangs when first calling the model to warm-up. After will never be printed. This is on an Apple M3 Max. Smaller models work sometimes.

import torch
from transformers import AutoModelForImageClassification


neural_network = AutoModelForImageClassification.from_pretrained("microsoft/resnet-50")
input_data = torch.randn(1, 3, 228, 228)
print(neural_network(input_data))
neural_network_c = torch.compile(neural_network, backend="inductor")
print("Before")
neural_network_c(input_data)
print("After")

The last version that worked was torch 2.2.0.

Versions

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

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

Python version: 3.11.8 (main, Feb  6 2024, 21:21:21) [Clang 15.0.0 (clang-1500.1.0.2.5)] (64-bit runtime)
Python platform: macOS-14.4.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M3 Max

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] onnx==1.16.0
[pip3] torch==2.2.1
[conda] Could not collect

Thanks for your help!

cc @ezyang @gchanan @zou3519 @kadeng @malfet @albanD @msaroufim @bdhirsh @anijain2305 @chauhang

Metadata

Metadata

Assignees

Labels

has workaroundhigh prioritymodule: macosMac OS related issuesmodule: regressionIt used to work, and now it doesn'toncall: cpu inductorCPU Inductor issues for Intel team to triageoncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions