[Vulkan] Add the off-graph flat KV cache and update_and_attend op - #22036
[Vulkan] Add the off-graph flat KV cache and update_and_attend op#22036kiymetakdemir wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22036
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 6 Unrelated FailuresAs of commit 275e70d with merge base 2c88f57 ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Adds the off-graph KV cache to the Vulkan backend, behind the neutral
kvcache::update_and_attendop. The cache is runtime state the host installs before the graph is built; it owns one buffer pool per layer for K and one for V, and the op function wraps them using the external-storage path. Pools are buffers.Added the missing shader variants — [texture3d, buffer] for the SDPA shaders and [buffer, texture3d] for the cache update so a buffer pool works inside the default texture-storage graph.
sdpa_implassertedscalewas None and then hardcoded1/sqrt(head_dim). The op contract makesscalea required float, so it now uses the supplied value when there is one.Files
backends/vulkan/runtime/graph/VulkanCache.h— graph-facing interface: pool shape, dtype, layer count, pool buffers.backends/vulkan/runtime/graph/VulkanSequenceCache.h— the byte layer; allocates pools at construction from the global context. Flat layers only.backends/vulkan/runtime/graph/ComputeGraph.h— the installed cache, set before the graph is built.backends/vulkan/runtime/graph/ops/impl/SDPA.cpp—update_and_attend_impl, andscaleinsdpa_impl.backends/vulkan/runtime/graph/ops/glsl/sdpa_*.{glsl,yaml}— the missing storage-type variants.backends/vulkan/test/op_tests/sdpa_test.cpp—OFFGRAPHmode.Testing
vulkan_sdpa_test—OFFGRAPHruns through the existing driver, so it covers all four configurations and both storage types: prefill, single-token decode, mid-sequence chunks, four GQA ratios and four head dims, each step compared against the ATen reference.cc @SS-JIA @manuelcandales @digantdesai @cbilgin