Last updated: 2026-11-17

Vulkan Runtime

KV Dtype

All API Sections

KV-cache storage type for the Vulkan backend, decided once per process from the environment. Shader element indices are always in units of elements (or vec4s), never bytes, so the same dispatch code drives every layout:

f32 4 B/elem (ZINC_KV_F16=0) f16 2 B/elem (default) q8 32 int8 + one f16 scale per 32-element block, padded to 36 bytes (ZINC_KV_Q8=1). Rows are block-aligned because head_dim and kv_dim are multiples of 32, so a vec4 index i lives in block i/8 at uint i%8, and the block's scale is its uint 8.

8 exports 0 methods src/compute/kv_dtype.zig

8 exports shown

enum

Layout

#
pub const Layout = enum f32, f16, q8 }

No public doc comment yet.

src/compute/kv_dtype.zig:14

function

layout

#
pub fn layout() Layout

No public doc comment yet.

src/compute/kv_dtype.zig:22

function

f16Enabled

#
pub fn f16Enabled() bool

No public doc comment yet.

src/compute/kv_dtype.zig:27

function

isQ8

#
pub fn isQ8() bool

No public doc comment yet.

src/compute/kv_dtype.zig:31

function

bytesPer32Elems

#
pub fn bytesPer32Elems() u64

Bytes a 32-element block occupies.

Every KV row is a whole number of blocks.

src/compute/kv_dtype.zig:36

function

rowBytes

#
pub fn rowBytes(elems: u64) u64

Bytes for `elems` elements of cache; `elems` must be a multiple of 32.

src/compute/kv_dtype.zig:45

function

elementBytes

#
pub fn elementBytes() u64

Bytes per element for the two uncompressed layouts.

Callers that can see a q8 cache must size rows with rowBytes() instead.

src/compute/kv_dtype.zig:51

function

shaderName

#
pub fn shaderName(comptime base: []const u8) []const u8

Shader variant for the current layout: `base`, `base ++ "_f16kv"`, or `base ++ "_q8kv"`.

Variants that do not exist for a layout are reported as missing pipelines at load time.

src/compute/kv_dtype.zig:62