Skip to content

Arm backend: Phase 3 - Vulkan backend uses shared vulkan context. - #23151

Merged
SS-JIA merged 15 commits into
pytorch:mainfrom
wwwind:phase3_vulkan
Nov 6, 2026
Merged

SS-JIA merged 15 commits into
pytorch:mainfrom
wwwind:phase3_vulkan

Conversation

@wwwind

@wwwind wwwind commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Implement Phase 3 of the shared Vulkan runtime RFC by integrating SharedVulkanContext into the ExecuTorch Vulkan backend.
RFC: #19298

The Vulkan delegate can now resolve, create, or reuse a shared Vulkan context during initialization and construct an Adapter around the shared VkInstance, VkDevice, and queue.

Key changes:

  • Add shared-context resolution to Vulkan backend initialization.
  • Extend Adapter to support borrowed shared devices and queues.
  • Route shared queue submit/wait operations through with_locked_queue() for cross-delegate synchronization.
  • Preserve correct shared-device lifetime and ownership semantics.
  • Keep the legacy Vulkan path unchanged when shared-context options are not provided.
  • Reuse the existing Vulkan VkInstance and avoid device-level volkLoadDevice() dispatch so multiple shared VkDevices can coexist safely.
  • Add validation and tests for shared-context creation, reuse, compatibility, lifetime, and queue handling.

This implements the Vulkan-side work described in the RFC and prepares the shared runtime for Phase 4 VGF integration.

Implementation has been assisted with Codex.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

Signed-off-by: Elena Zhelezina <[email protected]>
Change-Id: I6bf8e362c4a19c46e4cf2e01335d118d54b85635
@wwwind wwwind added module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: arm Changes to the ARM backend delegate module: arm Issues related to arm backend labels Sep 25, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23151

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (2 Unrelated Failures)

As of commit 9983026 with merge base ad3b6d2 (image):

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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 25, 2026
@zingo

zingo commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Hi @SS-JIA and @digantdesai is it you or someone else who what to know about this?

@wwwind wwwind added the help wanted Extra attention is needed label Oct 5, 2026

@SS-JIA SS-JIA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review (Codex), static analysis. Findings rechecked against the current PR head.

Comment thread backends/vulkan/CMakeLists.txt Resolved
@wwwind
wwwind requested a review from mergennachin as a code owner October 27, 2026 04:57
Change-Id: Ie723be86551ad70d36c0cd8b436ab593f61f966e
@wwwind

wwwind commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@SS-JIA Could you please take a look ? I addressed the comments

Comment thread backends/vulkan/CMakeLists.txt Resolved
Change-Id: Ibb53efbe3da9849ad58c77f8342cb7ffd7148bf9
Change-Id: I546b2199f8b64b70f84463e133984623c78e35c2
@wwwind

wwwind commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@SS-JIA Thank you for the review. Comments are addressed.
Could you please re-review again ? Thanks

@SS-JIA SS-JIA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but there are a couple of build failures. Once those are resolved, it should be good to merge. Stamping for now to indicate that changes LGTM.

Comment thread backends/vulkan/CMakeLists.txt Resolved
Change-Id: I6b219abb4abe86189397ab4b77e58d6181061534
@wwwind

wwwind commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

@SS-JIA Please take a look again. I resolve an issue with this file.

@meta-codesync

meta-codesync Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@SS-JIA has imported this pull request. If you are a Meta employee, you can view this in D129152314.

@SS-JIA

SS-JIA commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Hi @wwwind — the internal import of this PR (D129152314) fails to build. All 8 failing signals trace to one stale path; no test code ran, so other compile errors may still surface after this fix.

Fix: in backends/vulkan/targets.bzl, the new vulkan_shared_device_test target lists a header that does not exist:

headers = ["runtime/SharedDevice.h"],

There is no runtime/SharedDevice.h in this PR. The header that was added is runtime/ResolveSharedDevice.h (included by ResolveSharedDevice.cpp and both new tests). Change the line to:

headers = ["runtime/ResolveSharedDevice.h"],

Evidence from D129152314:

File not found: `fbsource//xplat/executorch/backends/vulkan/runtime/SharedDevice.h`.
     Included in `xplat/executorch/backends/vulkan/BUCK` but does not exist
Unknown target `vulkan_shared_device_test_no_volk` ...

This blocks vulkan_shared_device_test and vulkan_shared_device_test_no_volk (xplat and fbcode), and the citadel-*-for-executorch-linux-sanity-check jobs that build them. The github-export-checks failure is consequential — it was cancelled because its dependency failed — and should clear once the build passes.

Please update that one line and re-run CI. Happy to re-check the import once updated.

Change-Id: Ie1822d9558b1cbe77f30f7b351fc331567140b24
@SS-JIA
SS-JIA merged commit 2e15ded into pytorch:main Nov 6, 2026
SS-JIA pushed a commit that referenced this pull request Nov 10, 2026
Summary:
#23151 broke several Buck builds:

`vulkan_shared_device_test` compares Vulkan queue handles with `VK_NULL_HANDLE`, which some Vulkan headers define as `0`, so gtest compares a pointer with an int and the test does not compile. Compare with `nullptr`.

The `_no_volk` variants of that test link `libvulkan`, which the Linux, Android and Apple test hosts do not have. Keep only the volk variant.

`vulkan_compute_api` exported `vulkan_shared:runtime`, which pulls in the ExecuTorch runtime. A Windows binary that links the compute API with `link_style = "shared"` then builds `portable_type` as a DLL, which fails to link. The compute API only needs `SharedVulkanDevice`, so move it into its own `vulkan_shared:device` target with no runtime deps and export that instead.

On Windows, callers declared the shared API `dllimport`, so a binary that links the static build of the library cannot resolve it. Drop `dllimport` for callers; a plain declaration links against both the import library and the static library.

Authored with Metamate (agentcloud).

Reviewed By: shoumikhin

Differential Revision: D130716215
xuyanwen2012 added a commit to sarc-acl/executorch that referenced this pull request Nov 13, 2026
An Adapter that borrows a shared device (pytorch#23151) built its pipeline
cache without full subgroups and reported the Vulkan memory model as
off, so coopmat_family() was none there and shared-device users got
main's kernels. Both facts are known: the SharedVulkanDevice carries the
extensions and features the VkDevice was created with, and a device the
backend creates through create_vulkan_shared_device() is created by an
owning Adapter.

SharedVulkanDeviceFeatures now also records vulkanMemoryModel and
vulkanMemoryModelDeviceScope, filled by create_logical_device. The
owning and the shared-device constructors derive full subgroups (subgroup
size control and computeFullSubgroups) and the memory model (the
extension and its feature) from the enabled extensions and features
through vk_api/EnabledDeviceState.h; shared_physical_device() masks the
memory-model features like the others. An Adapter on an external
VkDevice stays conservative: no full subgroups, no memory model.

Tests: host gtest EnabledDeviceState (the key from a created device's
state matches xe2 / nvidia; no declared features, no full subgroups, or
the memory-model extension without its feature, or the reverse, match
none). vulkan_shared_device_test gains CreatedDeviceKeepsCoopmatFamily
(a borrowing Adapter has the owner's full subgroups, memory model and
family) and ImportedDeviceHasNoCoopmatFamily. On an Arc B580 (Mesa
26.2.6) the borrowing Adapter reports xe2; with the previous constructor
the first test fails (none). The suite passes on the B580, a RADV iGPU
and llvmpipe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
xuyanwen2012 added a commit to sarc-acl/executorch that referenced this pull request Nov 13, 2026
An Adapter that borrows a shared device (pytorch#23151) built its pipeline
cache without full subgroups and reported the Vulkan memory model as
off, so coopmat_family() was none there and shared-device users got
main's kernels. Both facts are known: the SharedVulkanDevice carries the
extensions and features the VkDevice was created with, and a device the
backend creates through create_vulkan_shared_device() is created by an
owning Adapter.

SharedVulkanDeviceFeatures now also records vulkanMemoryModel and
vulkanMemoryModelDeviceScope, filled by create_logical_device. The
owning and the shared-device constructors derive full subgroups (subgroup
size control and computeFullSubgroups) and the memory model (the
extension and its feature) from the enabled extensions and features
through vk_api/EnabledDeviceState.h; shared_physical_device() masks the
memory-model features like the others. An Adapter on an external
VkDevice stays conservative: no full subgroups, no memory model.

Tests: host gtest EnabledDeviceState (the key from a created device's
state matches xe2 / nvidia; no declared features, no full subgroups, or
the memory-model extension without its feature, or the reverse, match
none). vulkan_shared_device_test gains CreatedDeviceKeepsCoopmatFamily
(a borrowing Adapter has the owner's full subgroups, memory model and
family) and ImportedDeviceHasNoCoopmatFamily. On an Arc B580 (Mesa
26.2.6) the borrowing Adapter reports xe2; with the previous constructor
the first test fails (none). The suite passes on the B580, a RADV iGPU
and llvmpipe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SS-JIA pushed a commit to sarc-acl/executorch that referenced this pull request Nov 17, 2026
An Adapter that borrows a shared device (pytorch#23151) built its pipeline
cache without full subgroups and reported the Vulkan memory model as
off, so coopmat_family() was none there and shared-device users got
main's kernels. Both facts are known: the SharedVulkanDevice carries the
extensions and features the VkDevice was created with, and a device the
backend creates through create_vulkan_shared_device() is created by an
owning Adapter.

SharedVulkanDeviceFeatures now also records vulkanMemoryModel and
vulkanMemoryModelDeviceScope, filled by create_logical_device. The
owning and the shared-device constructors derive full subgroups (subgroup
size control and computeFullSubgroups) and the memory model (the
extension and its feature) from the enabled extensions and features
through vk_api/EnabledDeviceState.h; shared_physical_device() masks the
memory-model features like the others. An Adapter on an external
VkDevice stays conservative: no full subgroups, no memory model.

Tests: host gtest EnabledDeviceState (the key from a created device's
state matches xe2 / nvidia; no declared features, no full subgroups, or
the memory-model extension without its feature, or the reverse, match
none). vulkan_shared_device_test gains CreatedDeviceKeepsCoopmatFamily
(a borrowing Adapter has the owner's full subgroups, memory model and
family) and ImportedDeviceHasNoCoopmatFamily. On an Arc B580 (Mesa
26.2.6) the borrowing Adapter reports xe2; with the previous constructor
the first test fails (none). The suite passes on the B580, a RADV iGPU
and llvmpipe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SS-JIA pushed a commit to sarc-acl/executorch that referenced this pull request Nov 18, 2026
An Adapter that borrows a shared device (pytorch#23151) built its pipeline
cache without full subgroups and reported the Vulkan memory model as
off, so coopmat_family() was none there and shared-device users got
main's kernels. Both facts are known: the SharedVulkanDevice carries the
extensions and features the VkDevice was created with, and a device the
backend creates through create_vulkan_shared_device() is created by an
owning Adapter.

SharedVulkanDeviceFeatures now also records vulkanMemoryModel and
vulkanMemoryModelDeviceScope, filled by create_logical_device. The
owning and the shared-device constructors derive full subgroups (subgroup
size control and computeFullSubgroups) and the memory model (the
extension and its feature) from the enabled extensions and features
through vk_api/EnabledDeviceState.h; shared_physical_device() masks the
memory-model features like the others. An Adapter on an external
VkDevice stays conservative: no full subgroups, no memory model.

Tests: host gtest EnabledDeviceState (the key from a created device's
state matches xe2 / nvidia; no declared features, no full subgroups, or
the memory-model extension without its feature, or the reverse, match
none). vulkan_shared_device_test gains CreatedDeviceKeepsCoopmatFamily
(a borrowing Adapter has the owner's full subgroups, memory model and
family) and ImportedDeviceHasNoCoopmatFamily. On an Arc B580 (Mesa
26.2.6) the borrowing Adapter reports xe2; with the previous constructor
the first test fails (none). The suite passes on the B580, a RADV iGPU
and llvmpipe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SS-JIA pushed a commit to sarc-acl/executorch that referenced this pull request Nov 19, 2026
An Adapter that borrows a shared device (pytorch#23151) built its pipeline
cache without full subgroups and reported the Vulkan memory model as
off, so coopmat_family() was none there and shared-device users got
main's kernels. Both facts are known: the SharedVulkanDevice carries the
extensions and features the VkDevice was created with, and a device the
backend creates through create_vulkan_shared_device() is created by an
owning Adapter.

SharedVulkanDeviceFeatures now also records vulkanMemoryModel and
vulkanMemoryModelDeviceScope, filled by create_logical_device. The
owning and the shared-device constructors derive full subgroups (subgroup
size control and computeFullSubgroups) and the memory model (the
extension and its feature) from the enabled extensions and features
through vk_api/EnabledDeviceState.h; shared_physical_device() masks the
memory-model features like the others. An Adapter on an external
VkDevice stays conservative: no full subgroups, no memory model.

Tests: host gtest EnabledDeviceState (the key from a created device's
state matches xe2 / nvidia; no declared features, no full subgroups, or
the memory-model extension without its feature, or the reverse, match
none). vulkan_shared_device_test gains CreatedDeviceKeepsCoopmatFamily
(a borrowing Adapter has the owner's full subgroups, memory model and
family) and ImportedDeviceHasNoCoopmatFamily. On an Arc B580 (Mesa
26.2.6) the borrowing Adapter reports xe2; with the previous constructor
the first test fails (none). The suite passes on the B580, a RADV iGPU
and llvmpipe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SS-JIA pushed a commit that referenced this pull request Nov 19, 2026
…NVIDIA (#24000)

## Summary

Today the cooperative-matrix path of `q4gsw` and `dq8ca_q4gsw` linear
only runs on devices with subgroup size 64
whose name contains "Radeon" or "Xclipse". On Intel Xe2 (subgroup 16)
and NVIDIA (subgroup 32) no
cooperative-matrix linear kernel runs, and prefill uses the tiled
kernels.

This PR adds a cooperative-matrix path for 4-bit weight linear (`q4gsw`,
4w) and 8-bit-activation 4-bit-weight
linear (`dq8ca_q4gsw`, 8da4w) on two architecture families:

- **Intel Xe2** (Arc B580, Arc Pro B70) on Mesa ANV
- **NVIDIA** (RTX 4070 Ti SUPER, Jetson Orin) on the proprietary driver

A device matches a family by four things, never by device name: vendor
ID, driver ID, the cooperative-matrix
shapes it reports and the subgroup sizes it supports. Its logical device
must also have what the kernels need
enabled: subgroup size control for compute, full subgroups and the
Vulkan memory model. This holds for an
Adapter that creates its device and for one that borrows a shared device
(#23151). **A device that matches no
family keeps the kernels it runs today.**

## What changes

1. `vk_api`:
- Set `REQUIRE_FULL_SUBGROUPS` on pipelines with a required subgroup
size when the device enabled
`computeFullSubgroups` and the local size in X is a multiple of it
(VUID-RuntimeSpirv-OpTypeCooperativeMatrixKHR-10770,
     VUID 02757).
- Enable `VK_KHR_vulkan_memory_model` (and its device scope) whenever
the device supports it, and map the
`VulkanMemoryModel` / `VulkanMemoryModelDeviceScope` SPIR-V capabilities
to it.
- Record the memory-model features in `SharedVulkanDeviceFeatures`.
Shared-device Adapters derive full
subgroups and the memory model from the device's enabled extensions and
features, as the owning Adapter
does (`vk_api/EnabledDeviceState.h`). Adapters on an external `VkDevice`
stay conservative.
- Expose the driver ID (`VkPhysicalDeviceDriverProperties`, only with
`VK_KHR_driver_properties`), the
cooperative-matrix property list and the maximum compute shared memory.
- Add `kReadStorageImage`, a read access that selects
`VK_IMAGE_LAYOUT_GENERAL`. The graph dump lists it as
     a read.
2. `impl/gemm/linear/qw/wmma/CoopmatFamily.{h,cpp}`: the family key and
one table of kernel rows per family.
- Each row names a shader variant, its tile geometry, the shared memory
it declares per IO storage and an
     optional shape rule.
- Selection checks op, layout, subgroup size, shared-memory limit and
tile alignment. A shape that no row
     fits falls back to the existing kernel.
- `WmmaLinear.*` builds the key (from an Adapter or a graph) and the
shape.
3. `impl/gemm/linear/qw/q4gsw/wmma/Q4gswLinearWmma.*`,
`impl/gemm/linear/qw/dq8ca_q4gsw/wmma/Dq8caQ4gswLinearWmma.*`:
dispatch, hooked into `Q4gswLinear.cpp` and `Dq8caQ4gswLinear.cpp` (7
lines each). Weight scales are
converted to the output dtype, so fp32-scale and floating-zero-point
models take the family kernels too.
4. Shaders under `glsl/gemm/linear/qw/{q4gsw,dq8ca_q4gsw}/wmma/`:
- Two cooperative-matrix linear templates, `linear_q4gsw_wmma` and
`linear_dq8ca_q4gsw_wmma`, each with one
     `*_body.glslh`.
- q4gsw flags: `B_TEXEL`, `ACC_FP32`, `CSH_IN_ASH`, `FRAG_LAYOUT`,
`IMG_A`, `CSH_BAND`, `B_COLMAJOR`.
     - dq8ca flags: `ROWMAJOR_A`, `ORDER_NB_MAX`, `A_MULTI_BLOCK`.
- 15 variants. The storage, dtype and zero-point suffixes come from
`generate_variant_forall`. The
templates define `PRECISION highp` themselves, so `--auto-use-mediump`
does not change them.
- The existing with-group-sums activation packer, now
`quantize_and_pack_with_group_sums.{glsl,yaml}`, gains
an `OUTPUT_LAYOUT` axis with two row-major variant names
(`quantize_and_pack_4w_with_group_sums_*`). Its 16
     existing variants compile to the same SPIR-V as before.
5. Tests:
- `test/custom_ops/coopmat_family_test.cpp`: host-only gtest of the key
and the selection (14 tests). It
     covers:
     - unmatched keys (e.g. llvmpipe);
- logical-device prerequisites, and the enabled state a created or
shared device yields;
     - the shared-memory limit of every row;
- every row's tile geometry (`WG_TILE_*`, `SG_GRID_*`, subgroup size,
`MMA_M`, IO storage, layout flags)
       against the yaml parameters of each variant it dispatches.

     It runs in `test-vulkan-operators-linux`.
- `vulkan_shared_device_test`: an Adapter that borrows a shared device
created by the backend has the
owner's pipeline flags, memory model and family. An imported device
without declared features has none.
- `benchmark_v2/operators/gemm/linear/qw/wmma/cases/correctness.json`
(88 cases). It runs on its own in
`test-vulkan-operators-linux` (SwiftShader) and `test-vulkan-nvidia`.
- Each case is a `wmma_family_route` check: `operator_dynamic_resize`
steps that also assert the kernel
each step dispatches for the device's family. The family is stated by
`ETVK_WMMA_EXPECTED_FAMILY`
(`nvidia` on the NVIDIA job, `software` on SwiftShader), not taken from
the selector. In strict mode a
       case that does not run fails.
- Coverage: every Xe2 and NVIDIA row, both IO storages, group sizes 32 /
64 / 128 / 256, `[1, M, K]`
inputs, `[2, M, K]` (no family kernel), unaligned M, runtime shrink/grow
down to decode and back,
       fp32 / bias graphs, fp32 scales and fp16 zero points.
- Long-K q4gsw steps that dispatch a family kernel are validated at that
family's measured bound (see
       Testing).
- `wmma_family_shared_memory` checks the row table against the SPIR-V.
`wmma_memory_model_gate` checks
       that family kernels pass the capability gate on family devices.
     - `performance.json` has the Llama 3.2 1B projections.
   - The Xe2 rows have no GitHub CI coverage (no runner has an Xe2 GPU).

| Family | 4w | 8da4w |
|---|---|---|
| Xe2 (MMA 8x16x16 fp16, 8x16x32 int8, subgroup 16) |
`t128x128k16g82s16m8flib` (texture3d), `t128x128k16g44s16m8fl` (buffer)
| `t128x128k64g84s16m8i`; blocked workgroup order `...n13` when K*N >=
20e6 |
| NVIDIA (MMA 16x16x16 fp16/fp32, 16x16x32 int8, subgroup 32) |
`t256x128k16g42s32bt` for K <= 8192; `t128x128k16g22s32` where the
256-row tile does not fit; `bx_t128x128k32g42s32f32c` (fp32
accumulation) for K > 8192 | `rowmajor_t128x128k64g24s32mk32` |

The kernel sets were chosen from per-device tuned kernels by measuring
each candidate on every member of its
family. The accepted set is within 3 % geomean of each member's own best
set, with no projection more than 8 %
worse. The K > 8192 fp32-accumulation rule on NVIDIA is a correctness
rule: the fp16-accumulate kernel exceeds
tolerance at K = 14336 (Llama 3.1 8B down projection).

Buffer tensors pad their packed dim to four (#24753). On the family
route that dim is always a multiple of the
tile, so the padding is empty there.

## Results

End-to-end prefill, Llama 3.2 1B, 512-token prompt, tokens/s (median of
3), this PR vs `main`. Measured
2026-10-19, before the rebases. Family kernel times were unchanged on
2026-11-10 (B580, 4070 Ti), and the
changes since then leave the family kernels' SPIR-V byte-identical:

| Device | 4w | 8da4w |
|---|---|---|
| Arc B580 | 10667 vs 3066 (3.5x) | 13474 vs 6737 (2.0x) |
| RTX 4070 Ti SUPER | 21333 vs 6649 (3.2x) | 32000 vs 7420 (4.3x) |

Unaligned prompts (e.g. 511, 300, 129 tokens) take the family kernels
through a partial last M tile. On the
4070 Ti, 1B 4w at 511 tokens goes from 6636 to 21292 tok/s.

Outside the Llama projections, I tested 30 projection shapes of Qwen2.5
0.5B / 1.5B, Gemma 2 2B, Qwen3 4B / 8B
and Phi-3 mini (M = 512 and 2048, group sizes 64, 128 and 256). They
pass against the CPU reference on the
4070 Ti and the Orin and run 2.2x to 13.5x faster than the current
kernels.

## Testing

On the current head (`221c089c33`, base `main` `311d96d60d`), 2026-11-13
(wmma set rerun 2026-11-16), `etvk_ops_bench --validation_only`:

| Device | `wmma/correctness` | `q4gsw/correctness` |
`coopmat_correctness` | `fpa_correctness` |
|---|---|---|---|---|
| Arc B580 (Mesa 26.2.6) | 88/88 (`xe2`) | 134/134 | 32/32 | 90/90 |
| Ryzen 9600X iGPU (RADV, Mesa 26.2.6, no family) | 88/88 (`none`) |
134/134 | not rerun | not rerun |
| llvmpipe (Mesa 26.2.6, no family) | 88/88 (`software`) | 134/134 | not
rerun | not rerun |

On the same commits before the last rebase (base `main` `4d292c9733`),
2026-11-13:

| Device | `wmma/correctness` | `q4gsw/correctness` |
`coopmat_correctness` | `fpa_correctness` |
|---|---|---|---|---|
| Arc Pro B70 (Mesa 26.2.6) | 88/88 (`xe2`) | 130/132 * | 32/32 | 90/90
|
| Jetson Orin Nano (595.78) | 88/88 (`nvidia`) | 132/132 | 32/32 | 90/90
|
| Ryzen 9600X iGPU (RADV) | 88/88 (`none`) | 132/132 | 32/32 | 90/90 |
| llvmpipe | 88/88 (`software` and `none`) | 132/132 | 32/32 | 90/90 |

\* Two `linear_dq8ca_q4gsw` buffer cases that no family row takes failed
on Intel on that base, as on `main` at
the time. They pass on the B580 on the current base.

The RTX 4070 Ti SUPER (615.71.09) passed an earlier head's 75 cases on
2026-11-10. It was not reachable for
this head. SwiftShader was last run on 2026-11-10 too (75/75, outside
GitHub).

- **wmma runs.** The wmma rows were run with `ETVK_WMMA_EXPECTED_FAMILY`
set to the device's family. Every
route case validates its outputs at every step, with one exception: the
`[2, M, K]` cases check routing only,
because the existing kernels compute only the first batch, on `main`
too.
- **Host tests.** `vulkan_coopmat_family_test` passes 14/14.
`vulkan_shared_device_test` passes 41/41 on the
  B580, B70 and RADV, and 40/40 with 1 skipped on llvmpipe.
- **Kernel lists.** Enabling the memory model wherever it is supported
did not change the dispatched kernel of
any case in the three q4gsw collections on the B580, RADV or llvmpipe.
None of upstream's `VulkanMemoryModel` coopmat shaders is selected on
these devices. They need
  a Radeon/Xclipse name or subgroup size 64.
- **Long K.** Max |error| against the CPU reference over 5 seeds (M =
256):

  | Kernel | K = 9216 | K = 14336 |
  |---|---|---|
  | Xe2 fp16 accumulation (B580) | 0.13 | 0.23 |
  | NVIDIA fp32 accumulation (Orin) | 0.008 | 0.008 |
  | `main`'s q4gsw GEMM (B580) | 0.51 | 0.77 |

The family steps are validated at atol 0.3 (Xe2) and 0.03 (NVIDIA), rtol
0. Other devices keep atol 1.0.

## Known limitations and open questions

- **Device reach.** The Xe2 key requires Mesa ANV (the Intel Windows
driver is not matched). The NVIDIA key
matches any NVIDIA GPU on the proprietary driver that reports these
shapes. It was measured on Ada and Ampere
only (Turing, Hopper and Blackwell would match unmeasured). Happy to
narrow it if you prefer.
- **External `VkDevice`.** An Adapter on an external `VkDevice` does not
know whether full subgroups and the
memory model are enabled, so it keeps the existing kernels. Shared
devices carry that state and match.
- **Memory model on other devices.** The memory model is enabled
wherever it is supported. Upstream's
`linear_coopmat*`, `matmul_coopmat*` and Radeon/Xclipse
`linear_{,dq8ca_}q4gsw_coopmat_*` shaders therefore
pass the capability gate on such devices, as with #22899. Their own
dispatch gates decide whether they run.
  RDNA3 / Xclipse were not run here.
- **Xe2 long K.** The Xe2 4w rows keep fp16 accumulation at K > 8192.
The error is measured above: within the
0.25 every K <= 8192 case allows, and below `main`'s kernel on the same
device.
- **Xe2 8da4w threshold.** The blocked order starts at K*N >= 20e6, the
midpoint between the largest shape where
it is slower (16.8e6) and the smallest where it is faster (21.2e6) on
both Xe2 cards.
- **Image extents on Intel.** Texture3d tensors at K = 14336 exceed
ANV's reported 2048 image extent. This is the
  case on `main` as well and is not changed here.
- **AMD.** RDNA3 under RADV (780M, RX 7600, RX 7900 XTX) and Xclipse are
not covered. Their selection is
unchanged. Folding the AMD coopmat route into the family table is a
possible follow-up.
- **Weight layout.** On a family device, decode and small-M prefill fall
back to `linear_q4gsw_{coop,tiled}`,
  which read the legacy layout the family kernels share.
- On an Arc B580 those are faster than `main`'s `w_4x8_nc` GEMV/GEMM for
most Llama 3.2 1B projections
(geomean 0.63–0.78 of `main`'s time on texture3d). They are slower for
k/v decode and for gate/up at
    M = 64 and 100.
- On a Jetson Orin, `main`'s kernels are faster from M = 64 on (fallback
1.19x / 1.36x at M = 64 / 100) and
    on par for decode.
  - Reading `w_4x8_nc` from the family kernels is a follow-up.
- **Upstream issue seen while testing (not changed here).** On `main`,
`linear_q4gsw` / `linear_dq8ca_q4gsw`
  with a `[2, M, K]` input compute only the first batch.
- **Teardown crash on NVIDIA x86 (pre-existing, not from this PR).**
With a cold driver shader cache,
`etvk_ops_bench` on the 4070 Ti (driver 615.71) occasionally aborts at
exit after all cases have passed
(`ComputePipelineCache::purge` in `~Adapter` racing the driver's
background compiler thread).

Not in this PR: fused attention, decode kernels, fp16 linear.

Authored with Claude Code (AI).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. help wanted Extra attention is needed module: arm Issues related to arm backend module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants