Our ExecuTorch fork (software-mansion-labs/executorch) carries Gemma 4 Vulkan
support that upstream does not have. It should go upstream so we stop carrying
it, but it is a re-port rather than a patch, so it needs planning.
Context
Commit 24f0f69 "Add Gemma4 Vulkan support (Android GPU)" is 45 files,
+4247/-1188. It was already a port ("Ports Mateusz Kopciński's Gemma4 Vulkan
work onto 1.3"), and the upstream files it rewrites have moved again since
1.3.1. Upstream now has its own RMSNorm.cpp and IndexSelect.cpp, and its
SDPA.cpp has evolved independently, so our version collides rather than
applies.
Everything else SWM carries has now been checked against upstream and is either
already there or has been sent:
So Gemma 4 Vulkan is the only substantial piece left on the fork.
Suggested split
Four independent pieces, easiest first:
- Shader precision/perf helpers —
linear_q4gsw / linear_dq8ca_q4gsw
changes plus sdpa_fp32_acc.glslh and linear_fp32_scale_dq_acc.glslh.
Additive, likely stand alone.
- The
aten.rms_norm lowering (replacing the legacy et_vk.rms_norm).
Upstream already has an RMSNorm.cpp; this needs a diff against theirs first
to establish whether ours is an improvement, a duplicate, or a regression.
GemmaSDPA.cpp + the gemma SDPA shaders — the actual feature, ~738 lines
plus ~10 shader files. New files, so it can land as an addition, but it
depends on the reworked SDPA tile-load helpers, which is exactly where it
collides with upstream's evolved SDPA.cpp. This is the bulk of the work.
- Do not upstream — the
gen_vulkan_spv.py backward-compat shim (lets
ported shaders call define_required_extensions with one arg; a porting
artifact) and the DispatchNode.cpp tracer, see below.
Separate cleanup, worth doing regardless
The same commit added an env-gated dispatch tracer to
backends/vulkan/runtime/graph/ops/DispatchNode.cpp — ETVK_DISPATCH_TRACE,
with <cstdio>/fopen/setvbuf, commented "Iter 21 instrumentation". It is
still in the fork HEAD, so it ships in every runtime we build, including the one
RNE distributes. Inert unless the env var is set, but it is leftover debugging
in a shipped runtime and should probably come out of the fork.
Our ExecuTorch fork (software-mansion-labs/executorch) carries Gemma 4 Vulkan
support that upstream does not have. It should go upstream so we stop carrying
it, but it is a re-port rather than a patch, so it needs planning.
Context
Commit
24f0f69"Add Gemma4 Vulkan support (Android GPU)" is 45 files,+4247/-1188. It was already a port ("Ports Mateusz Kopciński's Gemma4 Vulkan
work onto 1.3"), and the upstream files it rewrites have moved again since
1.3.1. Upstream now has its own
RMSNorm.cppandIndexSelect.cpp, and itsSDPA.cpphas evolved independently, so our version collides rather thanapplies.
Everything else SWM carries has now been checked against upstream and is either
already there or has been sent:
1f9e5a4) — already upstream, verbatim.d454314) — upstream built its own (iOS 17.0+,ios.toolchain.cmake, metallib viaMLX_METAL_JIT). Superseded.IntEValue — extracted from the Gemma 4 commit andsent as Vulkan: accept a SymInt delegate arg as a plain Int EValue pytorch/executorch#21848.
index.Tensorsupport check + delegate arg-count guard —Vulkan: stop delegating nodes past their own support check pytorch/executorch#21847 (found while enabling LFM2.5-VL, see LFM2.5-VL-1.6B: Vulkan export for Android GPU? #1360).
So Gemma 4 Vulkan is the only substantial piece left on the fork.
Suggested split
Four independent pieces, easiest first:
linear_q4gsw/linear_dq8ca_q4gswchanges plus
sdpa_fp32_acc.glslhandlinear_fp32_scale_dq_acc.glslh.Additive, likely stand alone.
aten.rms_normlowering (replacing the legacyet_vk.rms_norm).Upstream already has an
RMSNorm.cpp; this needs a diff against theirs firstto establish whether ours is an improvement, a duplicate, or a regression.
GemmaSDPA.cpp+ the gemma SDPA shaders — the actual feature, ~738 linesplus ~10 shader files. New files, so it can land as an addition, but it
depends on the reworked SDPA tile-load helpers, which is exactly where it
collides with upstream's evolved
SDPA.cpp. This is the bulk of the work.gen_vulkan_spv.pybackward-compat shim (letsported shaders call
define_required_extensionswith one arg; a portingartifact) and the
DispatchNode.cpptracer, see below.Separate cleanup, worth doing regardless
The same commit added an env-gated dispatch tracer to
backends/vulkan/runtime/graph/ops/DispatchNode.cpp—ETVK_DISPATCH_TRACE,with
<cstdio>/fopen/setvbuf, commented "Iter 21 instrumentation". It isstill in the fork HEAD, so it ships in every runtime we build, including the one
RNE distributes. Inert unless the env var is set, but it is leftover debugging
in a shipped runtime and should probably come out of the fork.