Skip to main content

Module vulkan_dispatch

Module vulkan_dispatch 

Source
Expand description

Dispatch wrappers + registration for Vulkan-backed kernels. Sibling to baracuda_dispatch (CUDA) and the CPU dispatch in dispatch.rs. Each kernel registers as an alternative at the (op_kind, dtypes, BackendId::Vulkan) decision point in the shared KernelBindingTable.

§V.1 status

Phase 7.6 step 9c Vulkan catch-up V.1.C — the proof-of-life milestone. One op (Add f32) wired end-to-end through the pipelined-executor binding-table dispatch:

  1. The executor’s fuel_dispatch::pipelined::execute_work_item output- allocation match arm sees BackendId::Vulkan and allocates via fuel_vulkan_backend::VulkanBackend::alloc_bytes_handle (V.1.B).
  2. The kernel wrapper here reads inputs (also VulkanStorageBytes with backend handle attached), pulls the backend Arc from the first input, and calls fuel_vulkan_backend::VulkanBackend::binary_add_f32_bytes to dispatch.
  3. The Slang binary.spv kernel runs on the Vulkan device; the pre-allocated output buffer carries the result.

V.2 fans out registrations to the ~25 already-compiled SPIR-V kernels in fuel-vulkan-kernels. V.3 writes new Slang for the kernel families CUDA has and Vulkan doesn’t.

Modules§

affine
Vulkan dispatch wrappers for y = mul * x + add, per dtype.
arg_reduce
Vulkan dispatch wrappers for argmax / argmin reductions, per dtype.
attention
Vulkan dispatch wrappers for rotary position embedding (RoPE), per dtype.
binary
Vulkan dispatch wrappers for f32 elementwise binary ops (add, sub, mul, div, maximum, minimum).
binary_bf16
Vulkan dispatch wrappers for bf16 elementwise binary ops (add, sub, mul, div, maximum, minimum).
binary_f16
Vulkan dispatch wrappers for f16 elementwise binary ops (add, sub, mul, div, maximum, minimum).
binary_f64
Vulkan dispatch wrappers for f64 elementwise binary ops.
cast
Vulkan dispatch wrappers for dtype casts between f32 and f64 / half precision.
cast_f8e4m3
Vulkan dispatch wrappers for casts between F8E4M3 and F32 / F16 / BF16.
clamp
Vulkan dispatch wrappers for y = clamp(x, lo, hi) (f32).
concat
Vulkan dispatch wrappers for concatenation along an axis, per dtype.
conv2d
Vulkan dispatch wrappers for 2-D convolution, per dtype.
cumsum
Vulkan dispatch wrappers for cumulative sum, per dtype.
flash_attn
Vulkan dispatch wrappers for FlashAttention-shape attention forward and backward.
flip
Vulkan dispatch wrappers for flip along an axis.
gather
Vulkan dispatch wrappers for gather along a dimension.
index_add
Vulkan dispatch wrappers for index_add along a dimension, per dtype.
indexing
Vulkan dispatch wrappers for index_select, per dtype.
masked_fill
Vulkan dispatch wrappers for masked fill with a Bool mask.
matmul
Vulkan dispatch wrappers for matrix multiplication entry points, per input/output dtype combination.
norm
Vulkan dispatch wrappers for last-dimension normalisation (RMSNorm and LayerNorm, forward and backward), per dtype.
pad
Vulkan dispatch wrappers for padding forward/backward.
powi
Vulkan dispatch wrappers for integer power, y = x^exp (f32).
qmatmul
Vulkan dispatch wrappers for quantized matmul (only the quant types with a Vulkan kernel; others return an error so the route picker falls back to CPU).
reduce
Vulkan dispatch wrappers for sum / max / min / mean reductions.
roll
Vulkan dispatch wrappers for roll along an axis.
scatter_add
Vulkan dispatch wrappers for scatter_add along a dimension, per dtype.
softmax
Vulkan dispatch wrappers for softmax over the last dimension, forward and backward, per dtype.
triangular
Vulkan dispatch wrappers for triu / tril.
unary
Vulkan dispatch wrappers for f32 elementwise unary ops (neg, sqr, sqrt, exp, log, sin, cos, tanh, …).
unary_bf16
Vulkan dispatch wrappers for bf16 elementwise unary ops (neg, sqr, sqrt, exp, log, sin, cos, tanh, …).
unary_f16
Vulkan dispatch wrappers for f16 elementwise unary ops.
unary_f64
Vulkan dispatch wrappers for f64 elementwise unary ops.
write_slice
Vulkan dispatch wrappers for in-place slice write into a destination buffer (4-byte element widths).
write_slice_rotating
Vulkan dispatch wrappers for rotating slice write for sliding-window K/V caches (rotating axis must be axis 0).

Functions§

copy_to_cpu_vulkan
Dispatch wrapper for (OpKind::Copy, [T, T], Vulkan) — D2H from a Vulkan source storage into a freshly-allocated CPU output. The executor allocates the CPU output before this wrapper runs (see fuel_dispatch::pipelined::WorkItemKind::Copy); the wrapper calls VulkanBackend::download_bytes on the input’s attached backend handle and copies the result into the CPU storage.
register_vulkan_kernels
Register every Vulkan kernel wrapper against its (OpKind, dtypes, BackendId::Vulkan) decision-point key in the shared KernelBindingTable. Each wrapper appears as an alternative alongside any CPU / CUDA / future-backend registrations at the same key. The route picker (architecture v1.0 §04) selects among them at plan time based on input residency + telemetry.