Whisper Runtime Failure
@SS-JIA is already working on this.
Since Aug 19, 2025.
- Dominant language
- Python
- Stars
- 5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 581
Description
🐛 Describe the bug
Error:
E 00:08:13.282337 executorch:advanced_index_util.cpp:463] Check failed (index_val >= 0 && index_val < in.size(i)): Index 4294967296 is out of bounds for input dimension 0 with size 448.
E 00:08:13.282779 executorch:op_index.cpp:104] Check failed (success):
E 00:08:13.282836 executorch:method.cpp:1338] KernelCall failed at instruction 0:60 in operator aten::index.Tensor_out: 0x12
E 00:08:13.282841 executorch:method.cpp:1344] arg 0 with type id 1
E 00:08:13.282843 executorch:method.cpp:1344] arg 1 with type id 11
E 00:08:13.282845 executorch:method.cpp:1344] arg 2 with type id 1
E 00:08:13.282847 executorch:method.cpp:1344] arg 3 with type id 1
F 00:08:13.282882 executorch:executor_runner.cpp:282] In function main(), assert failed (status == Error::Ok): Execution of method forward failed with status 0x12
Aborted
Although I built this using the Vulkan delegate, this error is coming from an operation that is not being delegated.
How I created the Whisper .pte:
- Note : This requires transformers v4.47.1. https://github.com/pytorch/executorch/issues/13195
class WhisperWrapper(nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, input_features, decoder_input_ids):
return self.model(input_features=input_features, decoder_input_ids=decoder_input_ids)
@staticmethod
def get_dummy_inputs():
return (
torch.randn(1, 80, 3000),
torch.randint(0, 51864, (1, 4))
)
def getPTE():
model = WhisperModel.from_pretrained("openai/whisper-base")
model.config.use_cache = False
wrapped = WhisperWrapper(model).eval()
inputs = wrapped.get_dummy_inputs()
exported_program = torch.export.export(wrapped, inputs)
edge = to_edge(exported_program)
# Lower the model to Vulkan backend
compile_options = {"enable_dynamic_shape": True}
edge = edge.to_backend(VulkanPartitioner(compile_options))
# Makes the binary .pte ExecuTorch program file
exec_prog = edge.to_executorch()
with open("Whisper.pte", "wb") as file:
exec_prog.write_to_file(file)
Here is some of my debug effort:
-
The Whisper model uses the operator aten::index.Tensor.out. This operator lets you index into a tensor using other tensors as indices. It is NOT being delegated to the vulkan backend. So this is all CPU stuff happening below.
-
When the model gets compiled to a .pte, this operator's index tensors are seen as dynamic (not constant), meaning they will be set at runtime
-
At runtime this memory is getting allocated to store the indices in getMemPlannedPtr, called here: https://github.com/pytorch/executorch/blob/50ffe4466b1fb6d737c7f1359c4db08c4f734ad3/runtime/executor/tensor_parser_exec_aten.cpp#L254
-
At some point during the run, this piece of memory is being set
-
When the operator runs, we get the index value for whichever tensor we want, by calling query_integral_index here: https://github.com/pytorch/executorch/blob/bb66af0bf65a2c0ce8ec5e38b22b8f96141b52b1/kernels/portable/cpu/util/advanced_index_util.cpp#L453
-
Getting the index_val, we hit the assert because index_val == 2^32 (0b100000000000000000000000000000000)
-
I haven't been able to figure out exactly what's wrong, because I can't figure out what it should be. Obviously it shouldn't be 2^32. But I've been looking at query_integral_index: https://github.com/pytorch/executorch/blob/bf2f52b4b7b7e7bed0b174a44b34784f6a14c65b/kernels/portable/cpu/util/advanced_index_util.cpp#L135-L153
-
It gets called many times, but flat_ix is always one of 0, 1, 2, or 3.
index_ptr is being viewed as an int64_t *. -
Looking at the values in index_ptr: [0]=4294967296(0x100000000) [1]=12884901890(0x300000002) [2]=0(0x0) [3]=0(0x0), ...
-
As you can see, it looks like the values in index_ptr aren't being set correctly. It looks like they are being set as int32.
-
So, I modified the code to the following to essentially "index" into the int64 array as if it's 32 bit:
index_val = (index_ptr[(flat_ix/2)] >> (32 * ((flat_ix+1)%2))) & 0xFFFFFFFF;
- This made the assert not throw an error, but the output is entirely "nan":
I 00:02:39.275967 executorch:executor_runner.cpp:291] Model executed successfully 1 time(s) in 158037.352617 ms.
I 00:02:39.275991 executorch:executor_runner.cpp:295] 2 outputs:
Output 0: tensor(sizes=[1, 4, 512], [
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
...,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
])
Output 1: tensor(sizes=[1, 1500, 512], [
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
...,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
-nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan, -nan,
])
- So, this either isn't the issue or there is something else that's also wrong.
Other thoughts:
Should the tensor have constant index values upon .pte generation?
- Hunch is no. Because it is pretty explicit and takes 2 different routes. The op simply doesn't have the values to store.
Is not enough memory being set upon the call to getMemPlannedPtr?
-
I think this may be a possibility. When debugging, I saw that getMemPlannedPtr created 16 bytes of data for this. The shape is 4x1, and they should be int64, so it should actually create 32 bytes of data (8 bytes per int64).
-
However, this doesn't make up for the data being stored into that array incorrectly... but maybe it's all grouped together? Somehow more internally the array is being treated as int32 instead of int64?
Should it actually be int32 instead of int64?
- No. Was debugging and looking at the aten ops during compilation. It should be int64.
Versions
PyTorch version: 2.9.0.dev20250725+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.30.4
Libc version: glibc-2.31
Python version: 3.10.17 | packaged by conda-forge | (main, Apr 10 2025, 22:19:12) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-139-generic-x86_64-with-glibc2.31
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
Is XPU available: False
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
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 48
On-line CPU(s) list: 0-47
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz
Stepping: 7
CPU MHz: 2200.000
CPU max MHz: 4000.0000
CPU min MHz: 1000.0000
BogoMIPS: 4400.00
Virtualization: VT-x
L1d cache: 768 KiB
L1i cache: 768 KiB
L2 cache: 24 MiB
L3 cache: 35.8 MiB
NUMA node0 CPU(s): 0-47
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; TSX disabled
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 smx 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 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid 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 pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Versions of relevant libraries:
[pip3] executorch==0.8.0a0+fe84495
[pip3] flake8==6.1.0
[pip3] flake8-breakpoint==1.1.0
[pip3] flake8-bugbear==24.4.26
[pip3] flake8-comprehensions==3.14.0
[pip3] flake8-plugin-utils==1.3.3
[pip3] flake8-pyi==23.5.0
[pip3] mypy==1.14.1
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.1.1
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-nccl-cu12==2.27.3
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] onnx==1.18.0
[pip3] pytorch_tokenizers==0.1.0
[pip3] torch==2.9.0.dev20250725+cpu
[pip3] torchao==0.13.0+git1526dfe50
[pip3] torchaudio==2.8.0.dev20250725+cpu
[pip3] torchdata==0.11.0
[pip3] torchexplorer==1.1.2
[pip3] torchsr==1.0.4
[pip3] torchtune==0.6.1
[pip3] torchview==0.2.7
[pip3] torchvision==0.24.0.dev20250725+cpu
[pip3] torchviz==0.0.3
[pip3] triton==3.4.0
[conda] executorch 0.8.0a0+fe84495 pypi_0 pypi
[conda] numpy 2.1.1 pypi_0 pypi
[conda] nvidia-cublas-cu12 12.8.4.1 pypi_0 pypi
[conda] nvidia-cuda-cupti-cu12 12.8.90 pypi_0 pypi
[conda] nvidia-cuda-nvrtc-cu12 12.8.93 pypi_0 pypi
[conda] nvidia-cuda-runtime-cu12 12.8.90 pypi_0 pypi
[conda] nvidia-cudnn-cu12 9.10.2.21 pypi_0 pypi
[conda] nvidia-cufft-cu12 11.3.3.83 pypi_0 pypi
[conda] nvidia-curand-cu12 10.3.9.90 pypi_0 pypi
[conda] nvidia-cusolver-cu12 11.7.3.90 pypi_0 pypi
[conda] nvidia-cusparse-cu12 12.5.8.93 pypi_0 pypi
[conda] nvidia-cusparselt-cu12 0.7.1 pypi_0 pypi
[conda] nvidia-nccl-cu12 2.27.3 pypi_0 pypi
[conda] nvidia-nvjitlink-cu12 12.8.93 pypi_0 pypi
[conda] nvidia-nvtx-cu12 12.8.90 pypi_0 pypi
[conda] pytorch-tokenizers 0.1.0 pypi_0 pypi
[conda] torch 2.9.0.dev20250725+cpu pypi_0 pypi
[conda] torchao 0.13.0+git1526dfe50 pypi_0 pypi
[conda] torchaudio 2.8.0.dev20250725+cpu pypi_0 pypi
[conda] torchdata 0.11.0 pypi_0 pypi
[conda] torchexplorer 1.1.2 pypi_0 pypi
[conda] torchfix 0.6.0 pypi_0 pypi
[conda] torchsr 1.0.4 pypi_0 pypi
[conda] torchtune 0.6.1 pypi_0 pypi
[conda] torchview 0.2.7 pypi_0 pypi
[conda] torchvision 0.24.0.dev20250725+cpu pypi_0 pypi
[conda] torchviz 0.0.3 pypi_0 pypi
[conda] triton 3.4.0 pypi_0 pypi
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.