Skip to main content

fuel_vulkan_dispatch/
link.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! The built-in Vulkan backend's FKC `link_registry` (kernel-seam-interop §3.5,
3//! §4.3; FKC §12.6). The GPU analogue of `fuel_dispatch::fkc::CpuLinkRegistry`: maps
4//! each Vulkan kernel contract's `entry_point` symbol to the production dispatch
5//! wrapper — the real, non-stub resolution the importer uses so an imported
6//! contract binds the **actual** kernel (no raw pointers in the serialized
7//! contract, FKC P9).
8//!
9//! For the built-in Vulkan backend the wrappers live in
10//! [`crate::vulkan_dispatch`] (the dispatch layer that adapts the Slang/SPIR-V
11//! byte-kernels to [`KernelRef`]) and this table co-locates with them in
12//! fuel-dispatch. An *external* provider instead exports its own link registry
13//! across the FFI; this is Fuel's internal Vulkan-provider analogue.
14//!
15//! Everything here is gated behind the `vulkan` cargo feature — the DEFAULT
16//! build never compiles this module.
17
18use fuel_dispatch::fkc::LinkRegistry;
19use fuel_dispatch::kernel::KernelRef;
20
21/// One `(contract entry_point symbol, production wrapper)` pair. The symbol
22/// matches the contract's `entry_point: "fuel_vulkan_backend::fkc::<name>"`.
23/// Unlike the CPU `ep!` macro (which builds `<op>_<dt>` from two literals),
24/// Vulkan cast sections name their symbol in full (`cast_<src>_to_<dst>`), so
25/// this macro takes the bare symbol name + the fully-qualified wrapper path.
26macro_rules! vk_ep {
27    ($sym:literal, $wrapper:path $(,)?) => {
28        (
29            concat!("fuel_vulkan_backend::fkc::", $sym),
30            $wrapper as KernelRef,
31        )
32    };
33}
34
35/// The Vulkan cast (dtype-conversion) family's `symbol → production wrapper`
36/// map — the FULL family: 12 (SRC, DST) pairs resolving to 3 production
37/// wrappers. Contract: `fuel-dispatch/kernel-contracts/vulkan/cast.fkc.md`. Each per-pair
38/// section (`## cast_f32_to_f16`, …) declares a SPECIFIC single-dtype `src`
39/// input + a `fixed(DST)` output, so none of them dtype-fan — the importer
40/// resolves that symbol AS-IS and keys `[SRC, DST]` (input dtype + the output's
41/// fixed dtype), byte-for-byte the deleted hand-written
42/// `table.register_with_precision(OpKind::Cast, &[src, dst], …)` regs. The
43/// `OpParams::Cast` variant is a unit marker (the target dtype rides on the
44/// output Storage), so it never enters the key.
45///
46/// Several sections share ONE wrapper (as the deleted hand-written regs did):
47/// - `cast::cast_f32_half` — the pair-packed half casts `f32↔f16` / `f32↔bf16`.
48/// - `cast::cast_f32_f64` — the one-per-element wide casts `f32↔f64`.
49/// - `cast_f8e4m3::cast_f8e4m3` — the six byte-packed `F8E4M3↔{f32,f16,bf16}`
50///   casts (all non-F8 sides routed via F32 internally).
51///
52/// This contract has NO `##` chassis umbrella section, so there is no
53/// `registrable: false` describe-only entry to omit.
54pub static VULKAN_CAST_ENTRY_POINTS: &[(&str, KernelRef)] = &[
55    // Pair-packed half casts (f32↔f16, f32↔bf16) → cast_f32_half.
56    vk_ep!(
57        "cast_f32_to_f16",
58        crate::vulkan_dispatch::cast::cast_f32_half
59    ),
60    vk_ep!(
61        "cast_f16_to_f32",
62        crate::vulkan_dispatch::cast::cast_f32_half
63    ),
64    vk_ep!(
65        "cast_f32_to_bf16",
66        crate::vulkan_dispatch::cast::cast_f32_half
67    ),
68    vk_ep!(
69        "cast_bf16_to_f32",
70        crate::vulkan_dispatch::cast::cast_f32_half
71    ),
72    // One-per-element wide casts (f32↔f64) → cast_f32_f64.
73    vk_ep!(
74        "cast_f32_to_f64",
75        crate::vulkan_dispatch::cast::cast_f32_f64
76    ),
77    vk_ep!(
78        "cast_f64_to_f32",
79        crate::vulkan_dispatch::cast::cast_f32_f64
80    ),
81    // Byte-packed F8E4M3 casts (F8E4M3 ↔ {f32, f16, bf16}) → cast_f8e4m3.
82    vk_ep!(
83        "cast_f32_to_f8e4m3",
84        crate::vulkan_dispatch::cast_f8e4m3::cast_f8e4m3
85    ),
86    vk_ep!(
87        "cast_f8e4m3_to_f32",
88        crate::vulkan_dispatch::cast_f8e4m3::cast_f8e4m3
89    ),
90    vk_ep!(
91        "cast_f16_to_f8e4m3",
92        crate::vulkan_dispatch::cast_f8e4m3::cast_f8e4m3
93    ),
94    vk_ep!(
95        "cast_f8e4m3_to_f16",
96        crate::vulkan_dispatch::cast_f8e4m3::cast_f8e4m3
97    ),
98    vk_ep!(
99        "cast_bf16_to_f8e4m3",
100        crate::vulkan_dispatch::cast_f8e4m3::cast_f8e4m3
101    ),
102    vk_ep!(
103        "cast_f8e4m3_to_bf16",
104        crate::vulkan_dispatch::cast_f8e4m3::cast_f8e4m3
105    ),
106];
107
108/// The Vulkan elementwise family's `symbol → production wrapper` map — the
109/// FULL family: 94 (op, dtype) keys resolving to the per-(op, dtype) wrappers in
110/// [`crate::vulkan_dispatch`]. Contract:
111/// `fuel-dispatch/kernel-contracts/vulkan/elementwise.fkc.md`, re-authored per-op (the
112/// CPU inplace precedent). The strided unary / affine sections declare a BASE
113/// `entry_point` (`…::<op>` / `…::affine`) + `dtypes: [F32, F16, F64]`, so the
114/// importer fans them into `<base>_{f32,f16,f64}` — the symbols below. The
115/// binary sections fan `[F32, F16, F64, BF16]` (all four strided, incl. the
116/// lane-masked `binary_bf16`). The bf16-unary / `affine_bf16` / `clamp` / `powi`
117/// sections are single-dtype (resolved AS-IS on their full `<op>_<dt>` symbol).
118///
119/// Caps ride through the import truthfully (§6): the strided sections' layout
120/// (`strided: accepted, broadcast_stride0: accepted`) projects
121/// `strided_input=true` (byte-for-byte the deleted
122/// `register_with_caps_and_precision(strided)` regs); the bf16-unary /
123/// `affine_bf16` sections' `contiguous: required` layout projects
124/// `strided_input=false` (the deleted plain `register_with_precision` regs).
125pub static VULKAN_ELEMENTWISE_ENTRY_POINTS: &[(&str, KernelRef)] = &[
126    // ----- Unary: 16 ops, strided f32/f16/f64 fan + contiguous bf16 (64 symbols). -----
127    vk_ep!("neg_f32", crate::vulkan_dispatch::unary::neg_f32),
128    vk_ep!("neg_f16", crate::vulkan_dispatch::unary_f16::neg_f16),
129    vk_ep!("neg_f64", crate::vulkan_dispatch::unary_f64::neg_f64),
130    vk_ep!("neg_bf16", crate::vulkan_dispatch::unary_bf16::neg_bf16),
131    vk_ep!("sqr_f32", crate::vulkan_dispatch::unary::sqr_f32),
132    vk_ep!("sqr_f16", crate::vulkan_dispatch::unary_f16::sqr_f16),
133    vk_ep!("sqr_f64", crate::vulkan_dispatch::unary_f64::sqr_f64),
134    vk_ep!("sqr_bf16", crate::vulkan_dispatch::unary_bf16::sqr_bf16),
135    vk_ep!("sqrt_f32", crate::vulkan_dispatch::unary::sqrt_f32),
136    vk_ep!("sqrt_f16", crate::vulkan_dispatch::unary_f16::sqrt_f16),
137    vk_ep!("sqrt_f64", crate::vulkan_dispatch::unary_f64::sqrt_f64),
138    vk_ep!("sqrt_bf16", crate::vulkan_dispatch::unary_bf16::sqrt_bf16),
139    vk_ep!("exp_f32", crate::vulkan_dispatch::unary::exp_f32),
140    vk_ep!("exp_f16", crate::vulkan_dispatch::unary_f16::exp_f16),
141    vk_ep!("exp_f64", crate::vulkan_dispatch::unary_f64::exp_f64),
142    vk_ep!("exp_bf16", crate::vulkan_dispatch::unary_bf16::exp_bf16),
143    vk_ep!("log_f32", crate::vulkan_dispatch::unary::log_f32),
144    vk_ep!("log_f16", crate::vulkan_dispatch::unary_f16::log_f16),
145    vk_ep!("log_f64", crate::vulkan_dispatch::unary_f64::log_f64),
146    vk_ep!("log_bf16", crate::vulkan_dispatch::unary_bf16::log_bf16),
147    vk_ep!("sin_f32", crate::vulkan_dispatch::unary::sin_f32),
148    vk_ep!("sin_f16", crate::vulkan_dispatch::unary_f16::sin_f16),
149    vk_ep!("sin_f64", crate::vulkan_dispatch::unary_f64::sin_f64),
150    vk_ep!("sin_bf16", crate::vulkan_dispatch::unary_bf16::sin_bf16),
151    vk_ep!("cos_f32", crate::vulkan_dispatch::unary::cos_f32),
152    vk_ep!("cos_f16", crate::vulkan_dispatch::unary_f16::cos_f16),
153    vk_ep!("cos_f64", crate::vulkan_dispatch::unary_f64::cos_f64),
154    vk_ep!("cos_bf16", crate::vulkan_dispatch::unary_bf16::cos_bf16),
155    vk_ep!("tanh_f32", crate::vulkan_dispatch::unary::tanh_f32),
156    vk_ep!("tanh_f16", crate::vulkan_dispatch::unary_f16::tanh_f16),
157    vk_ep!("tanh_f64", crate::vulkan_dispatch::unary_f64::tanh_f64),
158    vk_ep!("tanh_bf16", crate::vulkan_dispatch::unary_bf16::tanh_bf16),
159    vk_ep!("sigmoid_f32", crate::vulkan_dispatch::unary::sigmoid_f32),
160    vk_ep!(
161        "sigmoid_f16",
162        crate::vulkan_dispatch::unary_f16::sigmoid_f16
163    ),
164    vk_ep!(
165        "sigmoid_f64",
166        crate::vulkan_dispatch::unary_f64::sigmoid_f64
167    ),
168    vk_ep!(
169        "sigmoid_bf16",
170        crate::vulkan_dispatch::unary_bf16::sigmoid_bf16
171    ),
172    vk_ep!("silu_f32", crate::vulkan_dispatch::unary::silu_f32),
173    vk_ep!("silu_f16", crate::vulkan_dispatch::unary_f16::silu_f16),
174    vk_ep!("silu_f64", crate::vulkan_dispatch::unary_f64::silu_f64),
175    vk_ep!("silu_bf16", crate::vulkan_dispatch::unary_bf16::silu_bf16),
176    vk_ep!("gelu_f32", crate::vulkan_dispatch::unary::gelu_f32),
177    vk_ep!("gelu_f16", crate::vulkan_dispatch::unary_f16::gelu_f16),
178    vk_ep!("gelu_f64", crate::vulkan_dispatch::unary_f64::gelu_f64),
179    vk_ep!("gelu_bf16", crate::vulkan_dispatch::unary_bf16::gelu_bf16),
180    vk_ep!("relu_f32", crate::vulkan_dispatch::unary::relu_f32),
181    vk_ep!("relu_f16", crate::vulkan_dispatch::unary_f16::relu_f16),
182    vk_ep!("relu_f64", crate::vulkan_dispatch::unary_f64::relu_f64),
183    vk_ep!("relu_bf16", crate::vulkan_dispatch::unary_bf16::relu_bf16),
184    vk_ep!("step_f32", crate::vulkan_dispatch::unary::step_f32),
185    vk_ep!("step_f16", crate::vulkan_dispatch::unary_f16::step_f16),
186    vk_ep!("step_f64", crate::vulkan_dispatch::unary_f64::step_f64),
187    vk_ep!("step_bf16", crate::vulkan_dispatch::unary_bf16::step_bf16),
188    vk_ep!("abs_f32", crate::vulkan_dispatch::unary::abs_f32),
189    vk_ep!("abs_f16", crate::vulkan_dispatch::unary_f16::abs_f16),
190    vk_ep!("abs_f64", crate::vulkan_dispatch::unary_f64::abs_f64),
191    vk_ep!("abs_bf16", crate::vulkan_dispatch::unary_bf16::abs_bf16),
192    vk_ep!("sign_f32", crate::vulkan_dispatch::unary::sign_f32),
193    vk_ep!("sign_f16", crate::vulkan_dispatch::unary_f16::sign_f16),
194    vk_ep!("sign_f64", crate::vulkan_dispatch::unary_f64::sign_f64),
195    vk_ep!("sign_bf16", crate::vulkan_dispatch::unary_bf16::sign_bf16),
196    vk_ep!("recip_f32", crate::vulkan_dispatch::unary::recip_f32),
197    vk_ep!("recip_f16", crate::vulkan_dispatch::unary_f16::recip_f16),
198    vk_ep!("recip_f64", crate::vulkan_dispatch::unary_f64::recip_f64),
199    vk_ep!("recip_bf16", crate::vulkan_dispatch::unary_bf16::recip_bf16),
200    // ----- Binary: 6 ops, strided f32/f16/f64/bf16 fan (24 symbols). -----
201    vk_ep!("add_f32", crate::vulkan_dispatch::binary::add_f32),
202    vk_ep!("add_f16", crate::vulkan_dispatch::binary_f16::add_f16),
203    vk_ep!("add_f64", crate::vulkan_dispatch::binary_f64::add_f64),
204    vk_ep!("add_bf16", crate::vulkan_dispatch::binary_bf16::add_bf16),
205    vk_ep!("sub_f32", crate::vulkan_dispatch::binary::sub_f32),
206    vk_ep!("sub_f16", crate::vulkan_dispatch::binary_f16::sub_f16),
207    vk_ep!("sub_f64", crate::vulkan_dispatch::binary_f64::sub_f64),
208    vk_ep!("sub_bf16", crate::vulkan_dispatch::binary_bf16::sub_bf16),
209    vk_ep!("mul_f32", crate::vulkan_dispatch::binary::mul_f32),
210    vk_ep!("mul_f16", crate::vulkan_dispatch::binary_f16::mul_f16),
211    vk_ep!("mul_f64", crate::vulkan_dispatch::binary_f64::mul_f64),
212    vk_ep!("mul_bf16", crate::vulkan_dispatch::binary_bf16::mul_bf16),
213    vk_ep!("div_f32", crate::vulkan_dispatch::binary::div_f32),
214    vk_ep!("div_f16", crate::vulkan_dispatch::binary_f16::div_f16),
215    vk_ep!("div_f64", crate::vulkan_dispatch::binary_f64::div_f64),
216    vk_ep!("div_bf16", crate::vulkan_dispatch::binary_bf16::div_bf16),
217    vk_ep!("maximum_f32", crate::vulkan_dispatch::binary::maximum_f32),
218    vk_ep!(
219        "maximum_f16",
220        crate::vulkan_dispatch::binary_f16::maximum_f16
221    ),
222    vk_ep!(
223        "maximum_f64",
224        crate::vulkan_dispatch::binary_f64::maximum_f64
225    ),
226    vk_ep!(
227        "maximum_bf16",
228        crate::vulkan_dispatch::binary_bf16::maximum_bf16
229    ),
230    vk_ep!("minimum_f32", crate::vulkan_dispatch::binary::minimum_f32),
231    vk_ep!(
232        "minimum_f16",
233        crate::vulkan_dispatch::binary_f16::minimum_f16
234    ),
235    vk_ep!(
236        "minimum_f64",
237        crate::vulkan_dispatch::binary_f64::minimum_f64
238    ),
239    vk_ep!(
240        "minimum_bf16",
241        crate::vulkan_dispatch::binary_bf16::minimum_bf16
242    ),
243    // ----- Affine: strided f32/f16/f64 fan + contiguous bf16 (all in the `affine` module). -----
244    vk_ep!("affine_f32", crate::vulkan_dispatch::affine::affine_f32),
245    vk_ep!("affine_f16", crate::vulkan_dispatch::affine::affine_f16),
246    vk_ep!("affine_f64", crate::vulkan_dispatch::affine::affine_f64),
247    vk_ep!("affine_bf16", crate::vulkan_dispatch::affine::affine_bf16),
248    // ----- Clamp / PowI: single-dtype f32. -----
249    vk_ep!("clamp_f32", crate::vulkan_dispatch::clamp::clamp_f32),
250    vk_ep!("powi_f32", crate::vulkan_dispatch::powi::powi_f32),
251];
252
253/// The Vulkan matmul family's `symbol → production wrapper` map — the FULL
254/// family: 6 per-combo `(MatMul, [lhs,rhs,out])` wrapper bindings. Contract:
255/// `fuel-dispatch/kernel-contracts/vulkan/matmul.fkc.md`, re-authored per-combo (the cast
256/// family's per-pair precedent). Each section declares a single dtype per operand
257/// + a `fixed(OUT)` / `passthrough(lhs)` output, so none of them dtype-fan — the
258///
259/// importer keys `[lhs, rhs, out]` (inputs-then-output), byte-for-byte the deleted
260/// hand-written `table.register_with_precision(OpKind::MatMul, &[lhs, rhs, out], …)`
261/// regs.
262///
263/// Each symbol is one production wrapper that route-picks its internal Slang
264/// kernels (matvec / reg-tile / tiled for f32; matvec_bf16_b / matmul_tiled_bf16_b
265/// / matmul_coop* + matmul_small_* fallbacks for the mixed combos) at dispatch
266/// time — the route-pick is NOT a table binding, so there is exactly one
267/// `KernelRef` per key (no duplicate-at-key which `finalize` would reject). Caps
268/// ride through contiguous-only (`awkward_layout_strategy: requires_contiguous`
269/// ⇒ `strided_input == false`), byte-for-byte the deleted `register_with_precision`
270/// regs (the coop / vec4 loads require canonical row-major; a strided operand is
271/// auto-Contiguized first).
272pub static VULKAN_MATMUL_ENTRY_POINTS: &[(&str, KernelRef)] = &[
273    // f32 GEMM/GEMV wrapper (matvec / reg-tile / tiled route-pick).
274    vk_ep!("matmul_f32", crate::vulkan_dispatch::matmul::matmul_f32),
275    // Mixed-precision f32 × bf16 → f32 (matvec_bf16_b / matmul_tiled_bf16_b / coop).
276    vk_ep!(
277        "matmul_f32_bf16_b",
278        crate::vulkan_dispatch::matmul::matmul_f32_bf16_b
279    ),
280    // Cooperative-matrix bf16 × bf16 → f32 (coop + matmul_small_bf16_bf16_f32).
281    vk_ep!(
282        "matmul_bf16_bf16_f32",
283        crate::vulkan_dispatch::matmul::matmul_bf16_bf16_f32
284    ),
285    // Cooperative-matrix bf16 × bf16 → bf16, downcast store (coop + small).
286    vk_ep!(
287        "matmul_bf16_bf16_bf16",
288        crate::vulkan_dispatch::matmul::matmul_bf16_bf16_bf16
289    ),
290    // Cooperative-matrix f16 × f16 → f16, downcast store (coop + small).
291    vk_ep!(
292        "matmul_f16_f16_f16",
293        crate::vulkan_dispatch::matmul::matmul_f16_f16_f16
294    ),
295    // Cooperative-matrix f16 × f16 → f32 (coop + matmul_small_f16_f16_f32).
296    vk_ep!(
297        "matmul_f16_f16_f32",
298        crate::vulkan_dispatch::matmul::matmul_f16_f16_f32
299    ),
300];
301
302/// The Vulkan conv2d family's `symbol → production wrapper` map — the FULL
303/// family: 3 per-(op, dtype) `(Conv2D, [x, weight, out])` wrapper bindings.
304/// Contract: `fuel-dispatch/kernel-contracts/vulkan/conv.fkc.md`, re-authored per-(op,
305/// dtype) (the matmul family's per-combo precedent). Each section declares a
306/// single dtype per operand + a `passthrough(x)` output, so none of them
307/// dtype-fan — the importer keys `[x, weight, out]` (inputs-then-output),
308/// byte-for-byte the deleted hand-written
309/// `table.register_with_precision(OpKind::Conv2D, &[T, T, T], …)` regs.
310///
311/// Each symbol is one production wrapper (`conv2d::conv2d_f32/bf16/f16`) that
312/// runs the WHOLE conv internally (`VulkanBackend::conv2d_*_bytes`: NCHW im2col
313/// → GEMM, the coop tensor-core GEMM for bf16/f16) — the two-stage pipeline is
314/// NOT a table binding, so there is exactly one `KernelRef` per key. NO bias key
315/// is mapped: the wrappers bail on a 3-input (bias) call, so the contract
316/// declares no optional bias operand and each section keys only `[x, weight,
317/// out]` (unlike the CPU conv family's optional-bias dual key). Caps ride
318/// through contiguous-only (`requires_contiguous` ⇒ `strided_input == false`) —
319/// conv2d_im2col reads canonical row-major NCHW, so a strided operand is
320/// auto-Contiguized first.
321pub static VULKAN_CONV_ENTRY_POINTS: &[(&str, KernelRef)] = &[
322    // f32 conv (im2col + f32 GEMM route-pick).
323    vk_ep!("conv2d_f32", crate::vulkan_dispatch::conv2d::conv2d_f32),
324    // bf16 conv (im2col_bf16 + cooperative-matrix bf16 GEMM).
325    vk_ep!("conv2d_bf16", crate::vulkan_dispatch::conv2d::conv2d_bf16),
326    // f16 conv (im2col + cooperative-matrix f16 GEMM).
327    vk_ep!("conv2d_f16", crate::vulkan_dispatch::conv2d::conv2d_f16),
328];
329
330/// The Vulkan **select** family's `symbol → production wrapper` map — the FULL
331/// family: 16 (op, dtype) keys across IndexSelect (4), Gather (6), MaskedFill
332/// (6). Contract: `fuel-dispatch/kernel-contracts/vulkan/select.fkc.md`, authored per-op
333/// (the conv/matmul per-combo precedent, with dtype fan-out §3.4). Each section
334/// declares a BASE `entry_point` fanned over its dtype list, so the importer
335/// resolves `<base>_<suffix>` and keys `[data, index, out]` (data dtype + fixed
336/// index dtype + passthrough(data) output), byte-for-byte the deleted hand-written
337/// `register_with_precision(OpKind::{IndexSelect,Gather,MaskedFill}, …)` regs.
338///
339/// IndexSelect fans to FOUR distinct per-dtype wrappers
340/// (`indexing::index_select_{f32,f16,bf16,f64}`). Gather + MaskedFill each dispatch
341/// through ONE dtype-agnostic wrapper (`gather::gather`, `masked_fill::masked_fill`)
342/// that picks its element byte-width from the output dtype — so every fanned dtype
343/// symbol maps to the SAME `KernelRef` (a synthetic-base umbrella, the pad_cpu
344/// precedent; distinct dtype keys ⇒ legal sibling registrations of one wrapper).
345/// Caps ride through contiguous-only (`requires_contiguous` ⇒ `strided_input ==
346/// false`) — byte-level data movers read/write own-shape flat buffers; a strided
347/// operand is auto-Contiguized first.
348pub static VULKAN_SELECT_ENTRY_POINTS: &[(&str, KernelRef)] = &[
349    // IndexSelect: 4 distinct per-dtype wrappers.
350    vk_ep!(
351        "index_select_f32",
352        crate::vulkan_dispatch::indexing::index_select_f32
353    ),
354    vk_ep!(
355        "index_select_f16",
356        crate::vulkan_dispatch::indexing::index_select_f16
357    ),
358    vk_ep!(
359        "index_select_bf16",
360        crate::vulkan_dispatch::indexing::index_select_bf16
361    ),
362    vk_ep!(
363        "index_select_f64",
364        crate::vulkan_dispatch::indexing::index_select_f64
365    ),
366    // Gather: 6 dtype symbols → the ONE dtype-agnostic gather wrapper.
367    vk_ep!("gather_f32", crate::vulkan_dispatch::gather::gather),
368    vk_ep!("gather_f16", crate::vulkan_dispatch::gather::gather),
369    vk_ep!("gather_bf16", crate::vulkan_dispatch::gather::gather),
370    vk_ep!("gather_f64", crate::vulkan_dispatch::gather::gather),
371    vk_ep!("gather_u8", crate::vulkan_dispatch::gather::gather),
372    vk_ep!("gather_u32", crate::vulkan_dispatch::gather::gather),
373    // MaskedFill: 6 dtype symbols → the ONE dtype-agnostic masked_fill wrapper.
374    vk_ep!(
375        "masked_fill_f32",
376        crate::vulkan_dispatch::masked_fill::masked_fill
377    ),
378    vk_ep!(
379        "masked_fill_f16",
380        crate::vulkan_dispatch::masked_fill::masked_fill
381    ),
382    vk_ep!(
383        "masked_fill_bf16",
384        crate::vulkan_dispatch::masked_fill::masked_fill
385    ),
386    vk_ep!(
387        "masked_fill_f64",
388        crate::vulkan_dispatch::masked_fill::masked_fill
389    ),
390    vk_ep!(
391        "masked_fill_u8",
392        crate::vulkan_dispatch::masked_fill::masked_fill
393    ),
394    vk_ep!(
395        "masked_fill_u32",
396        crate::vulkan_dispatch::masked_fill::masked_fill
397    ),
398];
399
400/// The Vulkan **scatter** family's `symbol → production wrapper` map — the FULL
401/// family: 8 (op, dtype) keys across IndexAdd (4) + ScatterAdd (4). Contract:
402/// `fuel-dispatch/kernel-contracts/vulkan/scatter.fkc.md`, authored per-op with dtype
403/// fan-out (§3.4). Each section declares a BASE `entry_point` fanned over
404/// `[F32, F64, BF16, F16]` (the `base` + `src` operands SHARE that list ⇒ they
405/// fan together), so the importer resolves `<base>_<suffix>` and keys the 4-slot
406/// `[base, U32, src, out]` (`passthrough(base)` output), byte-for-byte the deleted
407/// hand-written `register_with_precision(OpKind::{IndexAdd,ScatterAdd}, …)` regs.
408///
409/// Each fanned symbol resolves to its distinct per-dtype wrapper
410/// (`index_add::index_add_*`, `scatter_add::scatter_add_*`). Caps ride through
411/// contiguous-only (`requires_contiguous` ⇒ `strided_input == false`); precision is
412/// the contract's audited nondeterministic `none(reason)` seed (bounded-CAS atomic
413/// accumulate, scheduler-dependent order).
414pub static VULKAN_SCATTER_ENTRY_POINTS: &[(&str, KernelRef)] = &[
415    // IndexAdd: 4 distinct per-dtype wrappers.
416    vk_ep!(
417        "index_add_f32",
418        crate::vulkan_dispatch::index_add::index_add_f32
419    ),
420    vk_ep!(
421        "index_add_f64",
422        crate::vulkan_dispatch::index_add::index_add_f64
423    ),
424    vk_ep!(
425        "index_add_bf16",
426        crate::vulkan_dispatch::index_add::index_add_bf16
427    ),
428    vk_ep!(
429        "index_add_f16",
430        crate::vulkan_dispatch::index_add::index_add_f16
431    ),
432    // ScatterAdd: 4 distinct per-dtype wrappers.
433    vk_ep!(
434        "scatter_add_f32",
435        crate::vulkan_dispatch::scatter_add::scatter_add_f32
436    ),
437    vk_ep!(
438        "scatter_add_f64",
439        crate::vulkan_dispatch::scatter_add::scatter_add_f64
440    ),
441    vk_ep!(
442        "scatter_add_bf16",
443        crate::vulkan_dispatch::scatter_add::scatter_add_bf16
444    ),
445    vk_ep!(
446        "scatter_add_f16",
447        crate::vulkan_dispatch::scatter_add::scatter_add_f16
448    ),
449];
450
451/// The Vulkan **movement** family's `symbol → production wrapper` map — the FULL
452/// family: 8 (op, dtype) keys across Concat (4) + CumSum (4). Contract:
453/// `fuel-dispatch/kernel-contracts/vulkan/movement.fkc.md`, authored per-op with dtype
454/// fan-out (§3.4). Each section declares a BASE `entry_point` fanned over its dtype
455/// list, resolving `<base>_<suffix>` to each distinct per-dtype wrapper and keying
456/// `[T, T]` (`passthrough(input)` output), byte-for-byte the deleted hand-written
457/// `register_with_caps_and_precision(OpKind::{Concat,CumSum}, …, strided, …)` regs.
458///
459/// Both are STRIDE-AWARE (`strided: accepted` ⇒ `strided_input == true`) — the
460/// caps-through-import proof for this family. Concat precision is byte-exact
461/// (bitwise); CumSum takes the conservative UNAUDITED author seed (the elementwise
462/// pointwise precedent).
463pub static VULKAN_MOVEMENT_ENTRY_POINTS: &[(&str, KernelRef)] = &[
464    // Concat: 4 distinct per-dtype wrappers.
465    vk_ep!("concat_f32", crate::vulkan_dispatch::concat::concat_f32),
466    vk_ep!("concat_f16", crate::vulkan_dispatch::concat::concat_f16),
467    vk_ep!("concat_bf16", crate::vulkan_dispatch::concat::concat_bf16),
468    vk_ep!("concat_f64", crate::vulkan_dispatch::concat::concat_f64),
469    // CumSum: 4 distinct per-dtype wrappers.
470    vk_ep!("cumsum_f32", crate::vulkan_dispatch::cumsum::cumsum_f32),
471    vk_ep!("cumsum_f64", crate::vulkan_dispatch::cumsum::cumsum_f64),
472    vk_ep!("cumsum_f16", crate::vulkan_dispatch::cumsum::cumsum_f16),
473    vk_ep!("cumsum_bf16", crate::vulkan_dispatch::cumsum::cumsum_bf16),
474];
475
476/// The Vulkan **shape** family's `symbol → production wrapper` map — the FULL
477/// family: 28 (op, dtype) keys across Triu (7) + Tril (7) + Flip (7) + Roll (7)
478/// over `[F32, F16, BF16, F64, I32, U32, I64]`. Contract:
479/// `fuel-dispatch/kernel-contracts/vulkan/shape.fkc.md`, authored per-op with dtype fan-out
480/// (§3.4). Each op is ONE dtype-agnostic wrapper (`triangular::triu` /
481/// `triangular::tril` / `flip::flip` / `roll::roll`) that picks its byte-width from
482/// the dtype — so every fanned `<base>_<suffix>` symbol maps to the SAME `KernelRef`
483/// (a synthetic-base umbrella, the pad_cpu precedent). Distinct dtype keys ⇒ legal
484/// sibling registrations of one wrapper, byte-for-byte the deleted hand-written
485/// regs.
486///
487/// Caps split by op: Triu/Tril `requires_contiguous` (`strided_input == false`),
488/// Flip/Roll `strided: accepted` (`strided_input == true`) — the caps-through-import
489/// proof. All are byte-exact (bitwise, `max_ulp: 0`).
490pub static VULKAN_SHAPE_ENTRY_POINTS: &[(&str, KernelRef)] = &[
491    // Triu: 7 dtype symbols → the ONE dtype-agnostic triu wrapper.
492    vk_ep!("triu_f32", crate::vulkan_dispatch::triangular::triu),
493    vk_ep!("triu_f16", crate::vulkan_dispatch::triangular::triu),
494    vk_ep!("triu_bf16", crate::vulkan_dispatch::triangular::triu),
495    vk_ep!("triu_f64", crate::vulkan_dispatch::triangular::triu),
496    vk_ep!("triu_i32", crate::vulkan_dispatch::triangular::triu),
497    vk_ep!("triu_u32", crate::vulkan_dispatch::triangular::triu),
498    vk_ep!("triu_i64", crate::vulkan_dispatch::triangular::triu),
499    // Tril: 7 dtype symbols → the ONE dtype-agnostic tril wrapper.
500    vk_ep!("tril_f32", crate::vulkan_dispatch::triangular::tril),
501    vk_ep!("tril_f16", crate::vulkan_dispatch::triangular::tril),
502    vk_ep!("tril_bf16", crate::vulkan_dispatch::triangular::tril),
503    vk_ep!("tril_f64", crate::vulkan_dispatch::triangular::tril),
504    vk_ep!("tril_i32", crate::vulkan_dispatch::triangular::tril),
505    vk_ep!("tril_u32", crate::vulkan_dispatch::triangular::tril),
506    vk_ep!("tril_i64", crate::vulkan_dispatch::triangular::tril),
507    // Flip: 7 dtype symbols → the ONE dtype-agnostic flip wrapper (stride-aware).
508    vk_ep!("flip_f32", crate::vulkan_dispatch::flip::flip),
509    vk_ep!("flip_f16", crate::vulkan_dispatch::flip::flip),
510    vk_ep!("flip_bf16", crate::vulkan_dispatch::flip::flip),
511    vk_ep!("flip_f64", crate::vulkan_dispatch::flip::flip),
512    vk_ep!("flip_i32", crate::vulkan_dispatch::flip::flip),
513    vk_ep!("flip_u32", crate::vulkan_dispatch::flip::flip),
514    vk_ep!("flip_i64", crate::vulkan_dispatch::flip::flip),
515    // Roll: 7 dtype symbols → the ONE dtype-agnostic roll wrapper (stride-aware).
516    vk_ep!("roll_f32", crate::vulkan_dispatch::roll::roll),
517    vk_ep!("roll_f16", crate::vulkan_dispatch::roll::roll),
518    vk_ep!("roll_bf16", crate::vulkan_dispatch::roll::roll),
519    vk_ep!("roll_f64", crate::vulkan_dispatch::roll::roll),
520    vk_ep!("roll_i32", crate::vulkan_dispatch::roll::roll),
521    vk_ep!("roll_u32", crate::vulkan_dispatch::roll::roll),
522    vk_ep!("roll_i64", crate::vulkan_dispatch::roll::roll),
523];
524
525/// The Vulkan **pad-copy** family's `symbol → production wrapper` map — the FULL
526/// family: 21 (op, dtype) keys across Pad (6) + PadBackward (6) + Copy (9).
527/// Contract: `fuel-dispatch/kernel-contracts/vulkan/pad-copy.fkc.md`, authored per-op with
528/// dtype fan-out (§3.4). Each op is ONE dtype-agnostic wrapper (`pad::pad_const` /
529/// `pad::pad_backward` / `copy_to_cpu_vulkan`) that picks its byte-width from the
530/// dtype — so every fanned `<base>_<suffix>` symbol maps to the SAME `KernelRef`
531/// (a synthetic-base umbrella, the pad_cpu precedent). Distinct dtype keys ⇒ legal
532/// sibling registrations of one wrapper, byte-for-byte the deleted hand-written
533/// regs. Caps ride through contiguous-only (`requires_contiguous` ⇒
534/// `strided_input == false`); precision byte-exact (bitwise, `max_ulp: 0`).
535pub static VULKAN_PAD_COPY_ENTRY_POINTS: &[(&str, KernelRef)] = &[
536    // Pad: 6 dtype symbols → the ONE dtype-agnostic pad_const wrapper.
537    vk_ep!("pad_f32", crate::vulkan_dispatch::pad::pad_const),
538    vk_ep!("pad_f16", crate::vulkan_dispatch::pad::pad_const),
539    vk_ep!("pad_bf16", crate::vulkan_dispatch::pad::pad_const),
540    vk_ep!("pad_f64", crate::vulkan_dispatch::pad::pad_const),
541    vk_ep!("pad_u8", crate::vulkan_dispatch::pad::pad_const),
542    vk_ep!("pad_u32", crate::vulkan_dispatch::pad::pad_const),
543    // PadBackward: 6 dtype symbols → the ONE dtype-agnostic pad_backward wrapper.
544    vk_ep!(
545        "pad_backward_f32",
546        crate::vulkan_dispatch::pad::pad_backward
547    ),
548    vk_ep!(
549        "pad_backward_f16",
550        crate::vulkan_dispatch::pad::pad_backward
551    ),
552    vk_ep!(
553        "pad_backward_bf16",
554        crate::vulkan_dispatch::pad::pad_backward
555    ),
556    vk_ep!(
557        "pad_backward_f64",
558        crate::vulkan_dispatch::pad::pad_backward
559    ),
560    vk_ep!("pad_backward_u8", crate::vulkan_dispatch::pad::pad_backward),
561    vk_ep!(
562        "pad_backward_u32",
563        crate::vulkan_dispatch::pad::pad_backward
564    ),
565    // Copy: 9 dtype symbols → the ONE dtype-agnostic D2H copy wrapper.
566    vk_ep!("copy_f32", crate::vulkan_dispatch::copy_to_cpu_vulkan),
567    vk_ep!("copy_f16", crate::vulkan_dispatch::copy_to_cpu_vulkan),
568    vk_ep!("copy_bf16", crate::vulkan_dispatch::copy_to_cpu_vulkan),
569    vk_ep!("copy_f64", crate::vulkan_dispatch::copy_to_cpu_vulkan),
570    vk_ep!("copy_u32", crate::vulkan_dispatch::copy_to_cpu_vulkan),
571    vk_ep!("copy_u8", crate::vulkan_dispatch::copy_to_cpu_vulkan),
572    vk_ep!("copy_i16", crate::vulkan_dispatch::copy_to_cpu_vulkan),
573    vk_ep!("copy_i32", crate::vulkan_dispatch::copy_to_cpu_vulkan),
574    vk_ep!("copy_i64", crate::vulkan_dispatch::copy_to_cpu_vulkan),
575];
576
577/// The Vulkan **write-slice** family's `symbol → production wrapper` map — the
578/// FULL family: 18 (op, dtype) keys across WriteSlice (9) + WriteSliceRotating (9).
579/// Contract: `fuel-dispatch/kernel-contracts/vulkan/write-slice.fkc.md`, authored per-op
580/// with dtype fan-out (§3.4). BYTE-WIDTH-keyed: each op's 9 dtype symbols collapse
581/// to FOUR wrappers by element size (`b1/b2/b4/b8`) — the cast family's "several
582/// sections share one wrapper" precedent. The link registry maps each fanned
583/// `<base>_<suffix>` symbol to the byte-width wrapper for that dtype's size, keying
584/// `[T, T]` byte-for-byte the deleted hand-written
585/// `register_with_precision(OpKind::{WriteSlice,WriteSliceRotating}, …)` regs. Caps
586/// ride through contiguous-only (`requires_contiguous` ⇒ `strided_input == false`);
587/// precision byte-exact (bitwise, `max_ulp: 0`).
588pub static VULKAN_WRITE_SLICE_ENTRY_POINTS: &[(&str, KernelRef)] = &[
589    // WriteSlice: 9 dtype symbols → 4 byte-width wrappers (b4/b2/b8/b1).
590    vk_ep!(
591        "write_slice_f32",
592        crate::vulkan_dispatch::write_slice::write_slice_b4
593    ),
594    vk_ep!(
595        "write_slice_i32",
596        crate::vulkan_dispatch::write_slice::write_slice_b4
597    ),
598    vk_ep!(
599        "write_slice_u32",
600        crate::vulkan_dispatch::write_slice::write_slice_b4
601    ),
602    vk_ep!(
603        "write_slice_f16",
604        crate::vulkan_dispatch::write_slice::write_slice_b2
605    ),
606    vk_ep!(
607        "write_slice_bf16",
608        crate::vulkan_dispatch::write_slice::write_slice_b2
609    ),
610    vk_ep!(
611        "write_slice_f64",
612        crate::vulkan_dispatch::write_slice::write_slice_b8
613    ),
614    vk_ep!(
615        "write_slice_i64",
616        crate::vulkan_dispatch::write_slice::write_slice_b8
617    ),
618    vk_ep!(
619        "write_slice_u8",
620        crate::vulkan_dispatch::write_slice::write_slice_b1
621    ),
622    vk_ep!(
623        "write_slice_i8",
624        crate::vulkan_dispatch::write_slice::write_slice_b1
625    ),
626    // WriteSliceRotating: 9 dtype symbols → 4 byte-width rotating wrappers.
627    vk_ep!(
628        "write_slice_rotating_f32",
629        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b4
630    ),
631    vk_ep!(
632        "write_slice_rotating_i32",
633        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b4
634    ),
635    vk_ep!(
636        "write_slice_rotating_u32",
637        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b4
638    ),
639    vk_ep!(
640        "write_slice_rotating_f16",
641        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b2
642    ),
643    vk_ep!(
644        "write_slice_rotating_bf16",
645        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b2
646    ),
647    vk_ep!(
648        "write_slice_rotating_f64",
649        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b8
650    ),
651    vk_ep!(
652        "write_slice_rotating_i64",
653        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b8
654    ),
655    vk_ep!(
656        "write_slice_rotating_u8",
657        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b1
658    ),
659    vk_ep!(
660        "write_slice_rotating_i8",
661        crate::vulkan_dispatch::write_slice_rotating::write_slice_rotating_b1
662    ),
663];
664
665/// The Vulkan **rope** family's `symbol → production wrapper` map — the FULL
666/// family: 4 (Rope, [x, cos, sin, out]) per-dtype bindings. Contract:
667/// `fuel-dispatch/kernel-contracts/vulkan/rope.fkc.md`, authored with dtype fan-out (§3.4):
668/// the single section declares a BASE `entry_point` fanned over `[F32, F16, F64,
669/// BF16]` (the `x` + `cos` + `sin` operands SHARE that list ⇒ they fan together),
670/// resolving `rope_<suffix>` to each distinct per-dtype wrapper and keying the
671/// 4-slot `[x, cos, sin, out]` (`passthrough(x)` output), byte-for-byte the deleted
672/// hand-written `register_with_caps_and_precision(OpKind::Rope, …, strided, …)`
673/// regs. STRIDE-AWARE (`strided: accepted` ⇒ `strided_input == true`) — the
674/// caps-through-import proof; precision is the conservative UNAUDITED author seed
675/// (the elementwise pointwise precedent).
676pub static VULKAN_ROPE_ENTRY_POINTS: &[(&str, KernelRef)] = &[
677    vk_ep!("rope_f32", crate::vulkan_dispatch::attention::rope_f32),
678    vk_ep!("rope_f16", crate::vulkan_dispatch::attention::rope_f16),
679    vk_ep!("rope_f64", crate::vulkan_dispatch::attention::rope_f64),
680    vk_ep!("rope_bf16", crate::vulkan_dispatch::attention::rope_bf16),
681];
682
683/// The Vulkan **reduce** family's `symbol → production wrapper` map — the FULL
684/// family: 24 (op, dtype) keys across SumReduce / MaxReduce / MinReduce /
685/// MeanReduce (16, key `[T, T]`) + ArgMaxDim / ArgMinDim (8, key `[T, U32]`).
686/// Contract: `fuel-dispatch/kernel-contracts/vulkan/reduce-prims.fkc.md`, authored per-op
687/// with dtype fan-out (§3.4) — the production per-(op, dtype) binding model that
688/// supersedes the aspirational `vulkan/reduce.fkc.md` op-id-selector corpus. Each
689/// section fans a BASE `entry_point` over `[F32, F16, BF16, F64]` to the DISTINCT
690/// per-dtype wrapper, byte-for-byte the deleted hand-written
691/// `register_with_precision(OpKind::{SumReduce,…,ArgMinDim}, …)` regs. Caps ride
692/// through contiguous-only (`requires_contiguous` ⇒ `strided_input == false`);
693/// value reduces are audited nondeterministic none(reason), arg reduces bitwise
694/// exact.
695pub static VULKAN_REDUCE_ENTRY_POINTS: &[(&str, KernelRef)] = &[
696    // Value reduces: 4 ops × 4 dtypes → 16 distinct wrappers.
697    vk_ep!("reduce_sum_f32", crate::vulkan_dispatch::reduce::sum_f32),
698    vk_ep!("reduce_sum_f16", crate::vulkan_dispatch::reduce::sum_f16),
699    vk_ep!("reduce_sum_bf16", crate::vulkan_dispatch::reduce::sum_bf16),
700    vk_ep!("reduce_sum_f64", crate::vulkan_dispatch::reduce::sum_f64),
701    vk_ep!("reduce_max_f32", crate::vulkan_dispatch::reduce::max_f32),
702    vk_ep!("reduce_max_f16", crate::vulkan_dispatch::reduce::max_f16),
703    vk_ep!("reduce_max_bf16", crate::vulkan_dispatch::reduce::max_bf16),
704    vk_ep!("reduce_max_f64", crate::vulkan_dispatch::reduce::max_f64),
705    vk_ep!("reduce_min_f32", crate::vulkan_dispatch::reduce::min_f32),
706    vk_ep!("reduce_min_f16", crate::vulkan_dispatch::reduce::min_f16),
707    vk_ep!("reduce_min_bf16", crate::vulkan_dispatch::reduce::min_bf16),
708    vk_ep!("reduce_min_f64", crate::vulkan_dispatch::reduce::min_f64),
709    vk_ep!("reduce_mean_f32", crate::vulkan_dispatch::reduce::mean_f32),
710    vk_ep!("reduce_mean_f16", crate::vulkan_dispatch::reduce::mean_f16),
711    vk_ep!(
712        "reduce_mean_bf16",
713        crate::vulkan_dispatch::reduce::mean_bf16
714    ),
715    vk_ep!("reduce_mean_f64", crate::vulkan_dispatch::reduce::mean_f64),
716    // Index reduces: 2 ops × 4 dtypes → 8 distinct wrappers.
717    vk_ep!(
718        "arg_max_f32",
719        crate::vulkan_dispatch::arg_reduce::argmax_f32
720    ),
721    vk_ep!(
722        "arg_max_f16",
723        crate::vulkan_dispatch::arg_reduce::argmax_f16
724    ),
725    vk_ep!(
726        "arg_max_bf16",
727        crate::vulkan_dispatch::arg_reduce::argmax_bf16
728    ),
729    vk_ep!(
730        "arg_max_f64",
731        crate::vulkan_dispatch::arg_reduce::argmax_f64
732    ),
733    vk_ep!(
734        "arg_min_f32",
735        crate::vulkan_dispatch::arg_reduce::argmin_f32
736    ),
737    vk_ep!(
738        "arg_min_f16",
739        crate::vulkan_dispatch::arg_reduce::argmin_f16
740    ),
741    vk_ep!(
742        "arg_min_bf16",
743        crate::vulkan_dispatch::arg_reduce::argmin_bf16
744    ),
745    vk_ep!(
746        "arg_min_f64",
747        crate::vulkan_dispatch::arg_reduce::argmin_f64
748    ),
749];
750
751/// The Vulkan **norm** family's `symbol → production wrapper` map — the FULL
752/// family: 20 (op, dtype) keys across SoftmaxLastDim (4) + SoftmaxLastDimBackward
753/// (4) + LayerNormLastDim (4) + LayerNormLastDimBackward (4) + RmsNormLastDim (4).
754/// Contract: `fuel-dispatch/kernel-contracts/vulkan/norm.fkc.md`, authored per-op with dtype
755/// fan-out (§3.4). Each section fans a BASE `entry_point` over `[F32, F16, BF16,
756/// F64]` to the DISTINCT per-dtype wrapper (`softmax::*`, `norm::*`), keying forward
757/// families `[T, T]` and backward families `[T, T, T]` (`[y,g,dx]` / `[x,g,dx]`,
758/// both inputs sharing the fanned list), byte-for-byte the deleted hand-written
759/// `register_with_precision(OpKind::{SoftmaxLastDim,…,RmsNormLastDim}, …)` regs.
760/// Caps ride through contiguous-only (`requires_contiguous` ⇒ `strided_input ==
761/// false`); precision is the audited nondeterministic none(reason) seed
762/// (per-row subgroup-tree FADD order).
763pub static VULKAN_NORM_ENTRY_POINTS: &[(&str, KernelRef)] = &[
764    // Softmax forward + backward.
765    vk_ep!(
766        "softmax_last_dim_f32",
767        crate::vulkan_dispatch::softmax::softmax_f32
768    ),
769    vk_ep!(
770        "softmax_last_dim_f16",
771        crate::vulkan_dispatch::softmax::softmax_f16
772    ),
773    vk_ep!(
774        "softmax_last_dim_bf16",
775        crate::vulkan_dispatch::softmax::softmax_bf16
776    ),
777    vk_ep!(
778        "softmax_last_dim_f64",
779        crate::vulkan_dispatch::softmax::softmax_f64
780    ),
781    vk_ep!(
782        "softmax_last_dim_backward_f32",
783        crate::vulkan_dispatch::softmax::softmax_last_dim_backward_f32
784    ),
785    vk_ep!(
786        "softmax_last_dim_backward_f16",
787        crate::vulkan_dispatch::softmax::softmax_last_dim_backward_f16
788    ),
789    vk_ep!(
790        "softmax_last_dim_backward_bf16",
791        crate::vulkan_dispatch::softmax::softmax_last_dim_backward_bf16
792    ),
793    vk_ep!(
794        "softmax_last_dim_backward_f64",
795        crate::vulkan_dispatch::softmax::softmax_last_dim_backward_f64
796    ),
797    // LayerNorm forward + backward.
798    vk_ep!(
799        "layer_norm_last_dim_f32",
800        crate::vulkan_dispatch::norm::layer_norm_f32
801    ),
802    vk_ep!(
803        "layer_norm_last_dim_f16",
804        crate::vulkan_dispatch::norm::layer_norm_f16
805    ),
806    vk_ep!(
807        "layer_norm_last_dim_bf16",
808        crate::vulkan_dispatch::norm::layer_norm_bf16
809    ),
810    vk_ep!(
811        "layer_norm_last_dim_f64",
812        crate::vulkan_dispatch::norm::layer_norm_f64
813    ),
814    vk_ep!(
815        "layer_norm_last_dim_backward_f32",
816        crate::vulkan_dispatch::norm::layer_norm_backward_f32
817    ),
818    vk_ep!(
819        "layer_norm_last_dim_backward_f16",
820        crate::vulkan_dispatch::norm::layer_norm_backward_f16
821    ),
822    vk_ep!(
823        "layer_norm_last_dim_backward_bf16",
824        crate::vulkan_dispatch::norm::layer_norm_backward_bf16
825    ),
826    vk_ep!(
827        "layer_norm_last_dim_backward_f64",
828        crate::vulkan_dispatch::norm::layer_norm_backward_f64
829    ),
830    // RmsNorm forward.
831    vk_ep!(
832        "rms_norm_last_dim_f32",
833        crate::vulkan_dispatch::norm::rms_f32
834    ),
835    vk_ep!(
836        "rms_norm_last_dim_f16",
837        crate::vulkan_dispatch::norm::rms_f16
838    ),
839    vk_ep!(
840        "rms_norm_last_dim_bf16",
841        crate::vulkan_dispatch::norm::rms_bf16
842    ),
843    vk_ep!(
844        "rms_norm_last_dim_f64",
845        crate::vulkan_dispatch::norm::rms_f64
846    ),
847];
848
849/// The Vulkan **QMatMul** family's `symbol → production wrapper` map — the FULL
850/// family: ONE `(QMatMul, [F32, U32, F32])` binding. Contract:
851/// `fuel-dispatch/kernel-contracts/vulkan/qmatmul.fkc.md`, authored as a single primitive
852/// `op_kind: QMatMul` section (the CPU quant-matmul primitive precedent + the
853/// linear-quant U8→U32 logical-weight reconciliation). The section declares a
854/// single dtype per operand (`activations` F32, `weight` U32) + a `fixed(F32)`
855/// output, so it does NOT dtype-fan — the importer keys `[F32, U32, F32]`
856/// (inputs-then-output), byte-for-byte the deleted hand-written
857/// `table.register_with_precision(OpKind::QMatMul, &[F32, U32, F32], …)` reg.
858///
859/// The ONE `qmatmul_vk` wrapper route-picks its per-format Vulkan kernels
860/// (`qmatvec_q4_0` / `matmul_q4_0_tiled` for Q4_0; dequant-then-`matmul_f32` for
861/// Q4_K_M / Q8_0) at dispatch time by `OpParams::QMatMul.quant_type` — that
862/// route-pick is NOT a table binding, so there is exactly one `KernelRef` at the
863/// key. Caps ride through contiguous-only (`requires_contiguous` ⇒
864/// `strided_input == false`): the GGML weight stream has a fixed per-block layout,
865/// so a strided operand is auto-Contiguized first.
866pub static VULKAN_QMATMUL_ENTRY_POINTS: &[(&str, KernelRef)] = &[vk_ep!(
867    "qmatmul_vk",
868    crate::vulkan_dispatch::qmatmul::qmatmul_vk
869)];
870
871/// The Vulkan **FlashAttention** family's `symbol → production wrapper` map —
872/// the FULL family: 6 sections resolving to 6 distinct wrappers, keyed as 12
873/// bindings (each section's `alibi_slopes` optional-last fan doubles it). The
874/// forward `OpKind::FlashAttn` at THREE per-dtype wrappers
875/// (`flash_attn::flash_attn_{f32,bf16,f16}`) + the three backward selectors
876/// `OpKind::FlashAttnBackward{Q,K,V}` at f32-only wrappers
877/// (`flash_attn::flash_attn_backward_{q,k,v}_f32`). Contract:
878/// `fuel-dispatch/kernel-contracts/vulkan/attention.fkc.md`, authored per-(op, dtype)
879/// (the conv2d + CPU-attention per-dtype-section precedent).
880///
881/// Because the forward wrappers are DISTINCT per dtype, each section is
882/// SINGLE-dtype-per-operand and names its `entry_point` in FULL (no dtype-fan
883/// suffix), so the importer resolves the symbol AS-IS — the cast-family
884/// precedent. The importer keys `[q,k,v,(alibi,)out]` (forward) and
885/// `[q,k,v,do,(alibi,)out]` (backward), byte-for-byte the deleted hand-written
886/// `register_with_precision(OpKind::{FlashAttn,FlashAttnBackward{Q,K,V}}, …)`
887/// regs. Caps ride through contiguous-only (`requires_contiguous` ⇒
888/// `strided_input == false`); precision is the corrected audited-nondeterministic
889/// `none(reason)` seed (single-pass shared-mem softmax reduction; the retired
890/// `VULKAN_{FLOAT,HALF}_POINTWISE_PRECISION` consts over-claimed bit-stability).
891pub static VULKAN_ATTENTION_ENTRY_POINTS: &[(&str, KernelRef)] = &[
892    // Forward: 3 distinct per-dtype wrappers.
893    vk_ep!(
894        "flash_attn_f32",
895        crate::vulkan_dispatch::flash_attn::flash_attn_f32
896    ),
897    vk_ep!(
898        "flash_attn_bf16",
899        crate::vulkan_dispatch::flash_attn::flash_attn_bf16
900    ),
901    vk_ep!(
902        "flash_attn_f16",
903        crate::vulkan_dispatch::flash_attn::flash_attn_f16
904    ),
905    // Backward Q/K/V: f32-only distinct per-selector wrappers.
906    vk_ep!(
907        "flash_attn_backward_q_f32",
908        crate::vulkan_dispatch::flash_attn::flash_attn_backward_q_f32
909    ),
910    vk_ep!(
911        "flash_attn_backward_k_f32",
912        crate::vulkan_dispatch::flash_attn::flash_attn_backward_k_f32
913    ),
914    vk_ep!(
915        "flash_attn_backward_v_f32",
916        crate::vulkan_dispatch::flash_attn::flash_attn_backward_v_f32
917    ),
918];
919
920/// The built-in Vulkan backend's [`LinkRegistry`] — resolves a contract's
921/// `entry_point` symbols against [`VULKAN_CAST_ENTRY_POINTS`] +
922/// [`VULKAN_ELEMENTWISE_ENTRY_POINTS`] + [`VULKAN_MATMUL_ENTRY_POINTS`] +
923/// [`VULKAN_CONV_ENTRY_POINTS`] (and the future Vulkan families as they migrate
924/// off their hand-written regs). Unresolved → `None`, which the importer turns
925/// into a typed `UnknownEntryPoint` error (never a panic, never a fabricated
926/// pointer).
927pub struct VulkanLinkRegistry;
928
929impl LinkRegistry for VulkanLinkRegistry {
930    fn resolve_primitive(&self, symbol: &str) -> Option<KernelRef> {
931        // Chain every migrated Vulkan family's table; each symbol is unique
932        // across families (cast_*, per-op elementwise, matmul_*, conv2d_*), so
933        // order is immaterial.
934        VULKAN_CAST_ENTRY_POINTS
935            .iter()
936            .chain(VULKAN_ELEMENTWISE_ENTRY_POINTS.iter())
937            .chain(VULKAN_MATMUL_ENTRY_POINTS.iter())
938            .chain(VULKAN_CONV_ENTRY_POINTS.iter())
939            .chain(VULKAN_SELECT_ENTRY_POINTS.iter())
940            .chain(VULKAN_SCATTER_ENTRY_POINTS.iter())
941            .chain(VULKAN_MOVEMENT_ENTRY_POINTS.iter())
942            .chain(VULKAN_SHAPE_ENTRY_POINTS.iter())
943            .chain(VULKAN_PAD_COPY_ENTRY_POINTS.iter())
944            .chain(VULKAN_WRITE_SLICE_ENTRY_POINTS.iter())
945            .chain(VULKAN_ROPE_ENTRY_POINTS.iter())
946            .chain(VULKAN_REDUCE_ENTRY_POINTS.iter())
947            .chain(VULKAN_NORM_ENTRY_POINTS.iter())
948            .chain(VULKAN_QMATMUL_ENTRY_POINTS.iter())
949            .chain(VULKAN_ATTENTION_ENTRY_POINTS.iter())
950            .find(|(s, _)| *s == symbol)
951            .map(|(_, k)| *k)
952    }
953
954    fn resolve_fused(&self, _symbol: &str) -> Option<KernelRef> {
955        // No fused-op contracts in the Vulkan cast / elementwise corpus — every
956        // section is a primitive `op_kind`.
957        None
958    }
959}