Repository navigation
Commit 02b38d6
authored
Vulkan: accept a SymInt delegate arg as a plain Int EValue (pytorch#21848)
### Summary
`VulkanBackend::execute` required every SymInt input to arrive as a
scalar
tensor:
```cpp
VK_CHECK_COND(
args[i]->isTensor(),
"Cannot handle symint arg to graph that is not derived from a "
"scalar tensor at the moment.");
```
That holds when the value was lifted from a scalar tensor, but not when
the
Method's schema declares the argument as `SymInt` — the emitter then
passes a
plain `Int` EValue and the delegate rejects it. A dynamic-shape export
whose
sequence length crosses the delegate boundary as a SymInt hits this.
This PR accepts both forms on the way in, and adds the mirrored handling
on the
way out, which was missing entirely: the output loop knew about tensors
and
TensorRefs but not SymInts, so a graph returning one fell through to
`"Could not handle output with type"`. An output SymInt is now written
into the
caller's slot whether that slot is a scalar tensor (`Int` or `Long`) or
an `Int`
EValue.
Behaviour for the existing scalar-tensor path is unchanged.
### Test plan
- Existing `backends/vulkan/test/test_vulkan_delegate.py` suite.
- On device (Galaxy S26 Ultra, Adreno): Gemma 4 and LFM2.5-VL exports
whose
decoder takes a dynamic sequence length pass the SymInt across the
delegate
boundary as a plain `Int` and generate correctly. Without this change
the
delegate aborts at the `VK_CHECK_COND` above during the first
`execute()`.
Originally written by @Nklockiewicz and Mateusz Kopciński as part of
Gemma 4
Vulkan enablement; extracted here as a standalone change.
cc @SS-JIA @manuelcandales @digantdesai @cbilgin
Fixes pytorch#218771 parent d62d70f commit 02b38d6
1 file changed
Lines changed: 46 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
773 | 787 | | |
774 | 788 | | |
775 | 789 | | |
| |||
846 | 860 | | |
847 | 861 | | |
848 | 862 | | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
849 | 889 | | |
850 | 890 | | |
851 | 891 | | |
| |||
0 commit comments