openvino
openvino copied to clipboard
[Bug]: [PyTorch Frontend] No translation for the scan higher-order op
OpenVINO Version
2026.4.1, master
Operating System
Other (Linux, Python 3.11, torch 2.15.0)
Device used for inference
CPU
Framework
PyTorch
Model used
Qwen3.5, Qwen3-Next, Olmo-Hybrid, Mamba, Falcon-Mamba, Jamba (through transformers.exporters)
Issue description
The PyTorch frontend has no conversion rule for the scan higher-order op (torch._higher_order_ops.scan) from torch.export, so converting any exported program that contains it fails. The getitem error below is a consequence: the unconverted scan leaves a single output.
Tracked in huggingface/transformers#51306 (item 24). Fix: #40426.
Step-by-step reproduction
import numpy as np
import openvino as ov
import torch
from torch._higher_order_ops.scan import scan
class M(torch.nn.Module):
def forward(self, xs):
def step(carry, x):
carry = carry * 0.5 + x
return carry, carry.clone()
return scan(step, torch.zeros_like(xs[0]), xs)
xs = torch.randn(5, 2, 4)
program = torch.export.export(M(), (xs,))
compiled = ov.Core().compile_model(ov.convert_model(program), "CPU", {"INFERENCE_PRECISION_HINT": "f32"})
results = compiled([xs.numpy()])
for output, expected in zip(compiled.outputs, M()(xs)):
np.testing.assert_allclose(results[output], expected.numpy(), atol=1e-5, rtol=1e-5)
Relevant log output
FrontEnd API failed with OpConversionFailure:
Model wasn't fully converted. Failed operations detailed log:
-- <built-in function getitem> with a message:
Exception happened during conversion of operation getitem_1/<built-in function getitem> with schema NONE
Check '(getitem_idx < static_cast<int64_t>(list_elems.size()))' failed at src/frontends/pytorch/src/op/getitem.cpp:34:
FrontEnd API failed with OpConversionFailure:
[PyTorch Frontend] Index: 1 is out of bounds of input list of len: 1
Summary:
-- No conversion rule found for operations: UNKNOWN_TYPE_call_module, scan
-- Conversion is failed for: <built-in function getitem>
Issue submission checklist
- [x] I'm reporting an issue. It's not a question.
- [x] I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
- [x] There is reproducer code and related data files such as images, videos, models, etc.