-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Description
🐛 Describe the bug
I used to be able to export llama2 model (as of last week) using the following script, but now using the latest 2.8.0 nightly build it runs into a fake tensor error. Not sure if it's a regression or an error on my part. I'd like to bring this up to the attention of the exporter team in light of the pending release.
from transformers import AutoTokenizer, AutoModelForCausalLM, DynamicCache
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-chat-hf", attn_implementation="sdpa")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat-hf")
inputs = tokenizer(text="My name is Llama", return_tensors="pt")
past_key_values = DynamicCache()
outputs = model(**inputs, past_key_values=past_key_values, use_cache=True)
import torch
ep = torch.export.export(model, (inputs['input_ids'],), {'past_key_values': past_key_values, 'use_cache': True})
Error:
Traceback (most recent call last):
File "/workspace/GenAI/llama2/dynamic_cache.py", line 11, in <module>
ep = torch.export.export(model, (inputs['input_ids'],), {'past_key_values': past_key_values, 'use_cache': True})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 1168, in wrapper
raise e
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 1134, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 2190, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 1168, in wrapper
raise e
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 1134, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 2051, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 1993, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 1816, in _export_to_aten_ir_make_fx
return _produce_aten_artifact(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 551, in _produce_aten_artifact
_replace_unbacked_bindings(gm)
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/export/_trace.py", line 507, in _replace_unbacked_bindings
unbacked_bindings := _free_unbacked_symbols_with_path(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/yuanyao/.local/lib/python3.12/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1152, in _free_unbacked_symbols_with_path
assert isinstance(a, FakeTensor)
^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Versions
Collecting environment information...
PyTorch version: 2.8.0.dev20250627+cu126
Is debug build: False
CUDA used to build PyTorch: 12.6
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.1 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: 18.1.3 (1ubuntu1)
CMake version: version 3.27.0
Libc version: glibc-2.39
Python version: 3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 12.8.93
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA RTX A5000
Nvidia driver version: 560.28.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 20
On-line CPU(s) list: 0-19
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i9-9820X CPU @ 3.30GHz
CPU family: 6
Model: 85
Thread(s) per core: 2
Core(s) per socket: 10
Socket(s): 1
Stepping: 4
CPU(s) scaling MHz: 31%
CPU max MHz: 4200.0000
CPU min MHz: 1200.0000
BogoMIPS: 6599.98
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 pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 pti ssbd mba ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req vnmi md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 320 KiB (10 instances)
L1i cache: 320 KiB (10 instances)
L2 cache: 10 MiB (10 instances)
L3 cache: 16.5 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-19
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Mitigation; IBRS
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; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable
Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.6.4.1
[pip3] nvidia-cuda-cupti-cu12==12.6.80
[pip3] nvidia-cuda-nvrtc-cu12==12.6.77
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cufft-cu12==11.3.0.4
[pip3] nvidia-curand-cu12==10.3.7.77
[pip3] nvidia-cusolver-cu12==11.7.1.2
[pip3] nvidia-cusparse-cu12==12.5.4.2
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-nccl-cu12==2.27.3
[pip3] nvidia-nvjitlink-cu12==12.6.85
[pip3] nvidia-nvtx-cu12==12.6.77
[pip3] onnx==1.18.0
[pip3] onnx_graphsurgeon==0.5.8
[pip3] onnx-ir==0.1.3
[pip3] onnxscript==0.3.2.dev20250627
[pip3] pytorch-triton==3.3.1+gitc8757738
[pip3] torch==2.8.0.dev20250627+cu126
[pip3] torchaudio==2.8.0.dev20250627+cu126
[pip3] torchvision==0.23.0.dev20250627+cu126
[pip3] triton==3.3.1
[conda] Could not collect
cc @chauhang @penguinwu @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4