-
Bug
-
Resolution: Done
-
Undefined
-
None
-
None
-
2
-
False
-
-
False
-
-
-
2
-
PyTorch Sprint 23, PyTorch Sprint 24, PyTorch Sprint 25, PyTorch Sprint 26
-
-
- 🐛 Describe the bug
-
Description:
When using `torch.compile` with `fullgraph=True` on models that call `torch.sparse_csr_tensor()`, compilation fails with an `Unsupported` error. The error message explicitly states that Dynamo cannot trace this builtin function and suggests filing an issue.
code:
```
import torch
import torch.nn as nn
import torch.nn.functional as F
class TestModel(nn.Module):
def _init_(self):
super()._init_()
self.crow_indices = torch.tensor([0, 2, 5, 7], dtype=torch.int64)
self.col_indices = torch.tensor([1, 3, 0, 2, 4], dtype=torch.int64)
self.sparse_tensor = torch.sparse_csr_tensor(self.crow_indices, self.col_indices, torch.tensor([1.0, 2.0, 3.0, 4.0]), (5, 5))
def forward(self, x):
local_crow = torch.tensor([0, 1, 3, 4], dtype=torch.int64)
local_col = torch.tensor([2, 1, 10, 1], dtype=torch.int64)
local_sparse = torch.sparse_csr_tensor(local_crow, local_col, torch.tensor([1.0, 2.0, 3.0, 4.0]), (5, 5))
return F.relu(local_sparse)
def get_default_model():
return TestModel()
def get_sample_inputs():
return (torch.randn(1, 10),)
def main():
model = get_default_model()
model.eval()
inputs = get_sample_inputs()
with torch.no_grad():
output = model(*inputs)
print('Model executed successfully!')
print(f'Input shape:
')
print(f'Output shape:
')
print(f'Model parameters:
')
compiled_model = torch.compile(model,fullgraph=True)
with torch.no_grad():
output_compile = compiled_model(*inputs)
print(f'Compile shape:
')
if _name_ == '_main_':
main()
```
output:
```
Model executed successfully!
Input shape: torch.Size([1, 10])
Output shape: torch.Size([5, 5])
Model parameters: 0
/home/zuri/project/issuestest/coverage_fuzzing/pytorch/crashes/crash_mutated_CSR_format_index_tensors_tensor_value_mutation_testcase_nested_tensor_dimensions_tensor_dimension_mutation_20260107_173223.py:11: UserWarning: Sparse CSR tensor support is in beta state. If you miss a functionality in the sparse tensor support, please submit a feature request to https://github.com/pytorch/pytorch/issues. (Triggered internally at /pytorch/aten/src/ATen/SparseCsrTensorImpl.cpp:53.)
self.sparse_tensor = torch.sparse_csr_tensor(self.crow_indices, self.col_indices, torch.tensor([1.0, 2.0, 3.0, 4.0]), (5, 5))
/home/zuri/project/issuestest/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/functions.py:1939: UserWarning: Dynamo does not know how to trace the builtin `torch._VariableFunctionsClass.sparse_csr_tensor.` This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind).
If it is a Python builtin, please file an issue on GitHub so the PyTorch team can add support for it and see the next case for a workaround.
If it is a third-party C/C++ Python extension, please either wrap it into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html for more details) or, if it is traceable, use `torch.compiler.allow_in_graph`.
torch._dynamo.utils.warn_once(explanation + "\n" + "\n".join(hints))
Traceback (most recent call last):
...torch._dynamo.exc.Unsupported: Attempted to call function marked as skipped
Explanation: Dynamo does not know how to trace the builtin `torch._VariableFunctionsClass.sparse_csr_tensor.` This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind).
Hint: If it is a Python builtin, please file an issue on GitHub so the PyTorch team can add support for it and see the next case for a workaround.
Hint: If it is a third-party C/C++ Python extension, please either wrap it into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html for more details) or, if it is traceable, use `torch.compiler.allow_in_graph`.
Developer debug context: module: torch, qualname: _VariableFunctionsClass.sparse_csr_tensor, skip reason: <missing reason>
For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0007.html
from user code:
line 16, in forward
local_sparse = torch.sparse_csr_tensor(local_crow, local_col, torch.tensor([1.0, 2.0, 3.0, 4.0]), (5, 5))
Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
```
-
-
- Versions
-
Environment Information
PyTorch Build Details:
PyTorch version: 2.10.0.dev20251124+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A
OS and Compilers:
OS: Ubuntu 24.04.1 LTS (x86_64)
GCC version: (Ubuntu 10.5.0-4ubuntu2) 10.5.0
Clang version: 18.1.3 (1)
CMake version: version 3.28.3
Libc version: glibc-2.39
Python Environment:
Python version: 3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.14.0-36-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU Information:
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4060 Laptop GPU
Nvidia driver version: 580.95.05
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A
CPU Information:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i9-14900HX
CPU family: 6
Model: 183
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 1
Stepping: 1
CPU(s) scaling MHz: 33%
CPU max MHz: 5800.0000
CPU min MHz: 800.0000
BogoMIPS: 4838.40
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 896 KiB (24 instances)
L1i cache: 1.3 MiB (24 instances)
L2 cache: 32 MiB (12 instances)
L3 cache: 36 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-31
Vulnerability Gather data sampling: Not affected
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Mitigation; Clear Register File
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Mitigation; IBPB before exit to userspace
Versions of Relevant Libraries:
[pip3] numpy==2.3.3
[pip3] nvidia-cublas-cu12==12.1.3.1
[pip3] nvidia-cuda-cupti-cu12==12.1.105
[pip3] nvidia-cuda-nvrtc-cu12==12.1.105
[pip3] nvidia-cuda-runtime-cu12==12.1.105
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.0.2.54
[pip3] nvidia-curand-cu12==10.3.2.106
[pip3] nvidia-cusolver-cu12==11.4.5.107
[pip3] nvidia-cusparse-cu12==12.1.0.106
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.9.86
[pip3] nvidia-nvtx-cu12==12.1.105
[pip3] optree==0.18.0
[pip3] pytorch-triton-rocm==3.5.0
[pip3] torch==2.10.0.dev20251124+cpu
[pip3] torchao==0.15.0.dev20251124+cpu
[pip3] torchdata==0.12.0.dev20250909+cpu
[pip3] torchtext==0.17.0.dev20240912+cpu
[pip3] triton==3.1.0
[conda] Could not collect
cc @nikitaved @pearu @cpuhrsch @amjames @bhosmer @jcaip @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @Lucaskabela @jataylo
- clones
-
AIPCC-8537 Inductor fails to compile models using `torch.cat` with `axis` keyword argument
-
- Closed
-
- is cloned by
-
AIPCC-8540 TypeError in torch.compile due to incorrect F.sigmoid parameter passing
-
- Closed
-