pytorch / pytorch/tutorials

[BUG] unable to compile f3 in torch.compile tutorial

Open
#3,551 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug torch.compile
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Add Link

https://docs.pytorch.org/tutorials/intermediate/torch_compile_tutorial.html

Describe the bug

When I run the cell

compile_f3 = torch.compile(f3)
print("compile 3:", test_fns(f3, compile_f3, (inp2,)))

in the tutorial, I get the warnings show in the tutorial, but also an error

InternalTorchDynamoError: AttributeError: 'str' object has no attribute 'IF_NEEDED'

from user code:
   File "/home/tiago/miniforge3/envs/pytorch/lib/python3.12/site-packages/scipy/fft/_realtransforms_backend.py", line 15, in torch_dynamo_resume_in__execute_at_12
    return xp.asarray(y)
  File "/home/tiago/miniforge3/envs/pytorch/lib/python3.12/site-packages/scipy/_lib/array_api_compat/numpy/_aliases.py", line 113, in asarray
    return np.array(obj, copy=copy, dtype=dtype, **kwargs)  # pyright: ignore

This also happened when I ran the tutorial in Google Colab.

Describe your environment
  • Plataform: Ubuntu 24.04.3
  • CUDA 12.9
  • pytorch 2.7.1

cc @williamwen42 @msaroufim @anijain2305

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the torch_compile_tutorial.html example and run the cell containing compile_f3 = torch.compile(f3), reproducing the InternalTorchDynamoError in the reported Ubuntu or Colab environment. Trace the failure through the scipy fft and array_api_compat locations shown in the traceback; done means the tutorial cell runs without this error and its expected output is documented or restored.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.