Documentation
¶
Index ¶
- Constants
- Variables
- func VkAttentionScoresF32(out, q, kCache *VkBuf, seqLen, nHeads, nKVHeads, headDim int, scale float32) error
- func VkGELUTanhMulF32(gate, up *VkBuf, n int) error
- func VkGemvF32(out, x, w *VkBuf, inDim, outDim int) error
- func VkRMSNormF32(x, w *VkBuf, n int, eps float32) error
- func VkRMSNormNoScaleF32(x *VkBuf, n int, eps float32) error
- func VkRoPEPartialF32(x, freqs *VkBuf, pos, nHeads, headDim, rotHalf int) error
- func VkSiLUMulF32(dst, gate, up *VkBuf, n int) error
- func VkVecAddBF16(dst, a, b *VkBuf, n int) error
- func VkVecAddF32(dst, a, b *VkBuf, n int) error
- func VulkanBF16Ready() bool
- func VulkanDeviceName() string
- func VulkanDrain(ctx context.Context, budget time.Duration) error
- func VulkanInit() bool
- func VulkanInitIntegerDot() bool
- func VulkanIntegerDotEnabled() bool
- func VulkanReady() bool
- func VulkanSetMemoryBudget(budget VulkanMemoryBudget) error
- type VkAddF32
- type VkAttentionF32
- func NewVkAttentionF32(ctx context.Context) (*VkAttentionF32, error)
- func NewVkAttentionKey32F32(ctx context.Context) (*VkAttentionF32, error)
- func NewVkAttentionKey32OutputILPF32(ctx context.Context) (*VkAttentionF32, error)
- func NewVkAttentionKey32PaddedExtentF32(ctx context.Context) (*VkAttentionF32, error)
- func NewVkAttentionKey32PaddedExtentQ48F32(ctx context.Context) (*VkAttentionF32, error)
- func NewVkAttentionKey32ScoreILPF32(ctx context.Context) (*VkAttentionF32, error)
- func NewVkAttentionKey32ScoreILPUnroll4F32(ctx context.Context) (*VkAttentionF32, error)
- type VkBuf
- type VkBuffer
- type VkChannelAffineReLUF32
- type VkCommandBuffer
- type VkCommandPool
- type VkComputeKernel
- func (k *VkComputeKernel) Close() error
- func (k *VkComputeKernel) Dispatch(groupsX, groupsY, groupsZ uint32, bufs []*VkBuf, pushData unsafe.Pointer) error
- func (k *VkComputeKernel) DispatchContext(ctx context.Context, groupsX, groupsY, groupsZ uint32, bufs []*VkBuf, ...) error
- func (k *VkComputeKernel) DispatchF32Context(ctx context.Context, x, y, z uint32, tensors []*VkTensorF32, ...) error
- type VkComputeShader
- type VkConv1D3F32
- type VkConv2DCHWF32
- type VkConvInputLayout
- type VkDescriptorPool
- type VkDescriptorSet
- type VkDescriptorSetLayout
- type VkDevice
- type VkDeviceMemory
- type VkF32Plan
- type VkF32Stage
- type VkFence
- type VkGELUErfF32
- type VkInstance
- type VkLSTMCellF32
- type VkLSTMSequenceF32
- type VkLayerNormF32
- type VkLinearF16WeightF32
- type VkLinearF32
- type VkLinearQ5GroupedF32
- type VkLinearQ5IntegerDotSet
- func NewVkLinearQ5IntegerDotHybridSetStream(ctx context.Context, shapes []VkLinearQ5Shape, ...) (*VkLinearQ5IntegerDotSet, error)
- func NewVkLinearQ5IntegerDotMMQSetStream(ctx context.Context, shapes []VkLinearQ5Shape, ...) (*VkLinearQ5IntegerDotSet, error)
- func NewVkLinearQ5IntegerDotSetStream(ctx context.Context, shapes []VkLinearQ5Shape, ...) (*VkLinearQ5IntegerDotSet, error)
- func (s *VkLinearQ5IntegerDotSet) Close() error
- func (s *VkLinearQ5IntegerDotSet) F32Stage(ctx context.Context, index int, out, x, bias *VkTensorF32) (VkF32Stage, error)
- func (s *VkLinearQ5IntegerDotSet) Stages(ctx context.Context, index int, out, x, bias, scratch *VkTensorF32) ([]VkF32Stage, error)
- func (s *VkLinearQ5IntegerDotSet) StorageBytes() uint64
- type VkLinearQ5Matrix
- type VkLinearQ5Set
- func NewVkLinearQ5Decode4SetStream(ctx context.Context, shapes []VkLinearQ5Shape, ...) (*VkLinearQ5Set, error)
- func NewVkLinearQ5Set(ctx context.Context, matrices []VkLinearQ5Matrix) (result *VkLinearQ5Set, err error)
- func NewVkLinearQ5SetStream(ctx context.Context, shapes []VkLinearQ5Shape, ...) (*VkLinearQ5Set, error)
- type VkLinearQ5Shape
- type VkLinearQ8WeightF32
- type VkLinearQ8WeightMatrix
- type VkLinearQ8WeightSet
- type VkPhysicalDevice
- type VkPipeline
- type VkPipelineLayout
- type VkQueue
- type VkResult
- type VkRoPESequenceF32
- type VkShaderModule
- type VkTensorArena
- type VkTensorArenaStats
- type VkTensorF32
- func (t *VkTensorF32) Download(ctx context.Context, data []float32) error
- func (t *VkTensorF32) Elements() int
- func (t *VkTensorF32) PrefixRows(ctx context.Context, rows int) (*VkTensorF32, error)
- func (t *VkTensorF32) ReshapeF32(ctx context.Context, shape ...int) (*VkTensorF32, error)
- func (t *VkTensorF32) Shape() []int
- func (t *VkTensorF32) Upload(ctx context.Context, data []float32) error
- func (t *VkTensorF32) WithCPURead(ctx context.Context, consume func([]float32) error) error
- func (t *VkTensorF32) WithCPUWrite(ctx context.Context, produce func([]float32) error) error
- type VkTrainingF32
- func (op *VkTrainingF32) AdamWScaledStage(ctx context.Context, parameter, gradient, m, v, ema, clip *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) AdamWStage(ctx context.Context, parameter, gradient, m, v, ema *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) AttentionBackwardPlan(ctx context.Context, dq, dk, dv, dp, ds, q, k, v, prob, dy *VkTensorF32, ...) (*VkF32Plan, error)
- func (op *VkTrainingF32) AttentionBackwardStage(ctx context.Context, dst, q, k, v, prob, dy, aux *VkTensorF32, contextRows int, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) AttentionForwardStage(ctx context.Context, dst, q, k, v, aux *VkTensorF32, contextRows int, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) AttentionReady() bool
- func (op *VkTrainingF32) Close() error
- func (op *VkTrainingF32) CompactEmbeddingAccumulateStage(ctx context.Context, out, previous, compact, index *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) EOSAdmissionStage(ctx context.Context, hidden, weight, bias, dst *VkTensorF32, rows, width int) (VkF32Stage, error)
- func (op *VkTrainingF32) EOSStage(ctx context.Context, dst, x, labels *VkTensorF32, active int, mode uint32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) EmbeddingStage(ctx context.Context, dst, source, ids *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) GELUStage(ctx context.Context, dst, x, seed *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) LSDLossStage(ctx context.Context, dst, prediction, desired, logvar *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) LayerNormBackwardPlan(ctx context.Context, dx, dw, db, xhat, inv, weight, dy *VkTensorF32) (*VkF32Plan, error)
- func (op *VkTrainingF32) LayerNormBackwardStage(ctx context.Context, dst, xhat, inv, weight, dy *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) LinearBackwardStage(ctx context.Context, dst, x, w, dy *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) LinearDualBackwardPlan(ctx context.Context, dx, dt, dw, db, x, xt, w, gv, gt *VkTensorF32) (*VkF32Plan, error)
- func (op *VkTrainingF32) LinearDualBackwardStage(ctx context.Context, dst, x, xt, w, gv, gt *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) LinearDualForwardStage(ctx context.Context, dst, x, xt, w, bias *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) ModDualBackwardStage(ctx context.Context, dst, a, at, b, bt, gv, gt *VkTensorF32, kind, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) ModDualForwardStage(ctx context.Context, dst, a, at, b, bt *VkTensorF32, kind, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) NormDualBackwardPlan(ctx context.Context, dx, dt, dw, db, x, xt, w, gv, gt, stats *VkTensorF32, ...) (*VkF32Plan, error)
- func (op *VkTrainingF32) NormDualBackwardStage(ctx context.Context, dst, x, xt, w, gv, gt, stats *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) NormDualForwardPlan(ctx context.Context, y, yt, stats, scratch, x, xt, w, bias *VkTensorF32, ...) (*VkF32Plan, error)
- func (op *VkTrainingF32) NormDualForwardStage(ctx context.Context, dst, x, xt, w, bias, stats *VkTensorF32, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) NormStatsStage(ctx context.Context, dst, x *VkTensorF32, nonnegative bool) (VkF32Stage, error)
- func (op *VkTrainingF32) ReLUStage(ctx context.Context, dst, x, seed *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) RoPEStage(ctx context.Context, dst, x, table *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) RowStage(ctx context.Context, dst, a, b *VkTensorF32, rows, width, parts, slot int, ...) (VkF32Stage, error)
- func (op *VkTrainingF32) SiLUBackwardStage(ctx context.Context, dst, x, dy *VkTensorF32) (VkF32Stage, error)
- func (op *VkTrainingF32) SiLUDualBackwardStage(ctx context.Context, dx, dt, x, xt, gv, gt *VkTensorF32) (VkF32Stage, error)
- func (op *VkTrainingF32) SiLUDualForwardStage(ctx context.Context, dst, x, xt *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) TimeEmbeddingStage(ctx context.Context, dst, frequency, time, gv, gt *VkTensorF32, mode uint32) (VkF32Stage, error)
- func (op *VkTrainingF32) VectorStage(ctx context.Context, dst, a, b *VkTensorF32, offset int, mode uint32, ...) (VkF32Stage, error)
- type VkTrainingTape
- type VulkanCallError
- type VulkanDeviceLimits
- type VulkanMemoryBudget
- type VulkanMemoryUsage
- type VulkanResidentDriver
- func (d *VulkanResidentDriver) Accumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
- func (d *VulkanResidentDriver) Close() error
- func (d *VulkanResidentDriver) CompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, ...) error
- func (d *VulkanResidentDriver) NewBoundTape(ctx context.Context, t train.Tape, parameters map[int]train.ResidentBuffer, ...) (train.ResidentBoundTape, error)
- func (d *VulkanResidentDriver) NewBuffer(ctx context.Context, n int) (train.ResidentBuffer, error)
- func (d *VulkanResidentDriver) NewReuseBoundTape(ctx context.Context, tape train.Tape, bindings map[int]train.ResidentBuffer, ...) (train.ResidentBoundTape, error)
- func (d *VulkanResidentDriver) NewZeroBoundTape(ctx context.Context, t train.Tape, parameters map[int]train.ResidentBuffer, ...) (train.ResidentBoundTape, error)
- func (d *VulkanResidentDriver) NormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, ...) error
- func (d *VulkanResidentDriver) NormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, ...) error
- func (d *VulkanResidentDriver) NormStats(ctx context.Context, dst, x train.ResidentBuffer, n int, nonnegative bool) error
- func (d *VulkanResidentDriver) Update(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, ...) error
- func (d *VulkanResidentDriver) UpdateScaled(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, ...) error
- func (d *VulkanResidentDriver) ValidateAccumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
- func (d *VulkanResidentDriver) ValidateCompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, ...) error
- func (d *VulkanResidentDriver) ValidateHandoffTape(ctx context.Context, t train.Tape, bindings map[int]train.ResidentBuffer, ...) error
- func (d *VulkanResidentDriver) ValidateNormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, ...) error
- func (d *VulkanResidentDriver) ValidateNormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, ...) error
- func (d *VulkanResidentDriver) ValidateScaledUpdate(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, ...) error
- func (d *VulkanResidentDriver) ValidateUpdate(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, ...) error
- type VulkanShaderContract
- type VulkanSharedWorkspaceDriver
- func (d *VulkanSharedWorkspaceDriver) Accumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
- func (d *VulkanSharedWorkspaceDriver) Close() error
- func (d *VulkanSharedWorkspaceDriver) CompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, ...) error
- func (d *VulkanSharedWorkspaceDriver) Copy(ctx context.Context, dst, source train.ResidentBuffer, n int) error
- func (d *VulkanSharedWorkspaceDriver) NewBoundTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, ...) (train.ResidentBoundTape, error)
- func (d *VulkanSharedWorkspaceDriver) NewBuffer(ctx context.Context, n int) (train.ResidentBuffer, error)
- func (d *VulkanSharedWorkspaceDriver) NewReuseBoundTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, ...) (train.ResidentBoundTape, error)
- func (d *VulkanSharedWorkspaceDriver) NewZeroBoundTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, ...) (train.ResidentBoundTape, error)
- func (d *VulkanSharedWorkspaceDriver) NormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, ...) error
- func (d *VulkanSharedWorkspaceDriver) NormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, ...) error
- func (d *VulkanSharedWorkspaceDriver) NormStats(ctx context.Context, dst, source train.ResidentBuffer, n int, positive bool) error
- func (d *VulkanSharedWorkspaceDriver) Prefix(ctx context.Context, parent train.ResidentBuffer, n int, ...) (train.ResidentBuffer, error)
- func (d *VulkanSharedWorkspaceDriver) Update(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, ...) error
- func (d *VulkanSharedWorkspaceDriver) UpdateScaled(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, ...) error
- func (d *VulkanSharedWorkspaceDriver) ValidateAccumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
- func (d *VulkanSharedWorkspaceDriver) ValidateCompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, ...) error
- func (d *VulkanSharedWorkspaceDriver) ValidateCopy(ctx context.Context, dst, source train.ResidentBuffer, n int) error
- func (d *VulkanSharedWorkspaceDriver) ValidateHandoffTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, ...) error
- func (d *VulkanSharedWorkspaceDriver) ValidateNormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, ...) error
- func (d *VulkanSharedWorkspaceDriver) ValidateNormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, ...) error
- func (d *VulkanSharedWorkspaceDriver) ValidateNormStats(ctx context.Context, dst, source train.ResidentBuffer, n int, positive bool) error
- func (d *VulkanSharedWorkspaceDriver) ValidateScaledUpdate(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, ...) error
- func (d *VulkanSharedWorkspaceDriver) ValidateSharedAccumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
- func (d *VulkanSharedWorkspaceDriver) ValidateSharedInventory(ctx context.Context, owners []train.ResidentBuffer, extents []int) error
- func (d *VulkanSharedWorkspaceDriver) ValidateUpdate(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, ...) error
Constants ¶
const ( VK_SUCCESS VkResult = 0 VK_TIMEOUT VkResult = 2 VK_ERROR_DEVICE_LOST VkResult = -4 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3 VK_STRUCTURE_TYPE_SUBMIT_INFO = 4 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35 VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x00000020 VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001 VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002 VK_SHARING_MODE_EXCLUSIVE = 0 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004 VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7 VK_PIPELINE_BIND_POINT_COMPUTE = 1 VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001 VK_QUEUE_COMPUTE_BIT = 0x00000002 VK_PHYSICAL_DEVICE_TYPE_OTHER = 0 VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1 VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2 VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3 VK_PHYSICAL_DEVICE_TYPE_CPU = 4 VK_NULL_HANDLE = 0 )
Variables ¶
var ( ErrVulkanInFlight = errors.New("Vulkan submission still in flight") ErrVulkanDeviceLost = errors.New("Vulkan device lost; process-level recovery required") ErrVulkanUncertain = errors.New("Vulkan submission state uncertain; process-level recovery required") ErrVulkanClosed = errors.New("Vulkan resource closed") )
var ErrVulkanLimit = errors.New("Vulkan device limit admission failed")
ErrVulkanLimit indicates a request exceeds a queried core limit or no valid limit snapshot is available. It does not mean a shader has been validated.
var ErrVulkanMemoryBudget = errors.New("Vulkan allocation budget exceeded")
ErrVulkanMemoryBudget reports a package-owned allocation budget rejection. It is distinct from native OOM and queried descriptor/dispatch limit failures.
var ErrVulkanShaderContract = errors.New("unsupported or malformed Vulkan shader contract")
Functions ¶
func VkAttentionScoresF32 ¶
func VkAttentionScoresF32(out, q, kCache *VkBuf, seqLen, nHeads, nKVHeads, headDim int, scale float32) error
VkAttentionScoresF32 dispatches GQA attention scores on Vulkan.
func VkGELUTanhMulF32 ¶
VkGELUTanhMulF32 dispatches gate[i] = gelu_tanh(gate[i]) * up[i] on Vulkan.
func VkRMSNormF32 ¶
VkRMSNormF32 dispatches x[i] = w[i] * x[i] / rms(x) on Vulkan.
func VkRMSNormNoScaleF32 ¶
VkRMSNormNoScaleF32 dispatches x[i] = x[i] / rms(x) on Vulkan.
func VkRoPEPartialF32 ¶
VkRoPEPartialF32 rotates [hf,hf+rotHalf] pairs within each head, leaving the tail untouched. Frequencies are [position,rotHalf,cos/sin], and must be a separate allocation from x. Shader uses32-bit indexing; preflight bounds all products before narrowing. One invocation owns both outputs of each pair.
func VkSiLUMulF32 ¶
VkSiLUMulF32 dispatches dst[i] = silu(gate[i]) * up[i] on Vulkan.
func VkVecAddBF16 ¶
VkVecAddBF16 dispatches c[i] = BF16(F32(a[i]) + F32(b[i])) on Vulkan.
func VkVecAddF32 ¶
VkVecAddF32 dispatches c[i] = a[i] + b[i] on Vulkan.
func VulkanBF16Ready ¶
func VulkanBF16Ready() bool
VulkanBF16Ready returns true if Vulkan BF16 compute is available.
func VulkanDeviceName ¶
func VulkanDeviceName() string
VulkanDeviceName returns the Vulkan device name.
func VulkanDrain ¶
VulkanDrain waits only for the currently retained successful submission's fence. It does NOT resubmit commands, reset a fence, use vkQueueWaitIdle or destroy pending resources on timeout. budget (including lane admission) must be >0 and <=30s; context may bound it further. Lost/uncertain submissions remain quarantined until process teardown; a general device-recreation mechanism is not implemented. An unconfirmed fence retains resources. A confirmed fence releases pending state and services deferred legacy Free requests, even when cancellation races completion (Drain then returns the context error). No background worker.
func VulkanInitIntegerDot ¶
func VulkanInitIntegerDot() bool
VulkanInitIntegerDot creates an explicitly enabled Vulkan 1.3 integer-dot device. Requires accelerated unsigned weights × signed packed activations. It never recreates an existing baseline device or silently falls back.
func VulkanIntegerDotEnabled ¶
func VulkanIntegerDotEnabled() bool
func VulkanReady ¶
func VulkanReady() bool
VulkanReady reports current submission admission, not just initialisation. Retained or quarantined work makes it false until a successful drain.
func VulkanSetMemoryBudget ¶
func VulkanSetMemoryBudget(budget VulkanMemoryBudget) error
VulkanSetMemoryBudget changes admission only; it never evicts resources. It can be used before initialisation. A cap below current usage, or a pending/ quarantined submission, rejects the whole update. Zero clears operator caps; this cannot bypass queried limits. No environment/default behaviour changes.
Types ¶
type VkAddF32 ¶
type VkAddF32 struct {
// contains filtered or unexported fields
}
VkAddF32 provides checked arena/plan addition using the unchanged vec_add_f32 shader. Shapes must match exactly, rank1..8; no broadcasting. Exact output alias with either/both inputs is allowed, partial overlap rejected. Caller ensures finite representable sums. No data scan or hidden fallback.
func (*VkAddF32) Forward ¶
func (op *VkAddF32) Forward(ctx context.Context, out, a, b *VkTensorF32) error
func (*VkAddF32) Stage ¶
func (op *VkAddF32) Stage(ctx context.Context, out, a, b *VkTensorF32) (VkF32Stage, error)
Stage checks addition invariants at creation. Returned generic stages are mutable; plans do not recheck these operator-specific shape/alias rules. Callers modifying a stage assume responsibility for shader safety.
type VkAttentionF32 ¶
type VkAttentionF32 struct {
// contains filtered or unexported fields
}
VkAttentionF32 is non-causal, equal-head F32 attention over time-major Q[seqQ,heads*headDim], K/V[seqKV,heads*headDim] and Out shaped like Q. A fused16-query/16-key tile uses online softmax without a quadratic score allocation. headDim is1..64, heads1..32, and both sequence lengths1..4096. No mask, GQA, F16, quantisation or model/default selection is provided. Caller contents must have finite representable dot products and weighted sums; no data scan. Device accuracy/performance still need qualification.
func NewVkAttentionF32 ¶
func NewVkAttentionF32(ctx context.Context) (*VkAttentionF32, error)
func NewVkAttentionKey32F32 ¶
func NewVkAttentionKey32F32(ctx context.Context) (*VkAttentionF32, error)
NewVkAttentionKey32F32 explicitly selects 32-key online softmax with parallel exponent evaluation and F32 FMA. It changes reduction/rounding relative to the baseline and must be separately numerically/task-qualified. No fallback.
func NewVkAttentionKey32OutputILPF32 ¶
func NewVkAttentionKey32OutputILPF32(ctx context.Context) (*VkAttentionF32, error)
NewVkAttentionKey32OutputILPF32 explicitly interleaves four output columns. Each column retains increasing-key FMA order, F32 precision and tile rescale. QKscore unroll4, softmax, layout and barriers are unchanged. Requires headDim64.
func NewVkAttentionKey32PaddedExtentF32 ¶
func NewVkAttentionKey32PaddedExtentF32(ctx context.Context) (*VkAttentionF32, error)
func NewVkAttentionKey32PaddedExtentQ48F32 ¶
func NewVkAttentionKey32PaddedExtentQ48F32(ctx context.Context) (*VkAttentionF32, error)
NewVkAttentionKey32PaddedExtentF32 explicitly matches the original unmasked 256-key padded extent using virtual zero K/V rows. HeadDim64 only; actual tensors remain unchanged. F32 arithmetic stays ordered; output differs from true-key attention. No default/precision/fallback change. NewVkAttentionKey32PaddedExtentQ48F32 is bit-identical to NewVkAttentionKey32PaddedExtentF32 (identical per-output arithmetic order) but each workgroup owns 48 queries, so K/V tiles and barriers are shared by three times as many queries. headDim must be 64. No fallback.
func NewVkAttentionKey32ScoreILPF32 ¶
func NewVkAttentionKey32ScoreILPF32(ctx context.Context) (*VkAttentionF32, error)
NewVkAttentionKey32ScoreILPF32 explicitly interleaves two independent score accumulators while preserving increasing-channel FMA order for each key. The key32 online-softmax and output-reduction orders remain unchanged. This is an opt-in kernel, with no fallback or serving default selection.
func NewVkAttentionKey32ScoreILPUnroll4F32 ¶
func NewVkAttentionKey32ScoreILPUnroll4F32(ctx context.Context) (*VkAttentionF32, error)
NewVkAttentionKey32ScoreILPUnroll4F32 is an explicit headDim64-only kernel. Four channel iterations are statically interleaved without changing each score's ordered FMA, softmax, output recurrence, storage or barriers. No fallback.
func (*VkAttentionF32) Close ¶
func (op *VkAttentionF32) Close() error
func (*VkAttentionF32) Forward ¶
func (op *VkAttentionF32) Forward(ctx context.Context, out, q, k, v *VkTensorF32, heads int) error
func (*VkAttentionF32) Stage ¶
func (op *VkAttentionF32) Stage(ctx context.Context, out, q, k, v *VkTensorF32, heads int) (VkF32Stage, error)
Stage checks exact rank/shape/extents and rejects every output/input overlap. Read-only inputs may alias. Tensors and push words in returned stages are owned slices; modifying generic stages must not bypass these operator checks.
type VkBuf ¶
type VkBuf struct {
// contains filtered or unexported fields
}
VkBuf is a host-visible/coherent buffer. Device-local memory is not required. Package APIs serialize host access and retain buffers during pending work. Resource objects must not be copied; callers cannot access the mapped pointer.
func VkBufAlloc ¶
VkBufAlloc allocates a Vulkan buffer accessible from both host and device.
func (*VkBuf) Download ¶
Download copies float32 data from the buffer. Invalid inputs are ignored for legacy compatibility; callers that need diagnostics should use DownloadChecked.
func (*VkBuf) DownloadChecked ¶
DownloadChecked copies float32 data from the buffer and reports malformed input.
func (*VkBuf) Free ¶
func (b *VkBuf) Free()
Free keeps the legacy signature. Pending buffers are retained and marked for deferred destruction after VulkanDrain confirms completion. After device loss/uncertain submission they stay retained until process teardown. Call FreeChecked when the caller needs to know that immediate destruction failed.
func (*VkBuf) FreeChecked ¶
FreeChecked never defers implicitly. An in-flight/lost error leaves the object untouched; drain then retry. Repeated successful frees are no-ops.
func (*VkBuf) Upload ¶
Upload copies float32 data to the buffer. Invalid inputs are ignored for legacy compatibility; callers that need diagnostics should use UploadChecked.
func (*VkBuf) UploadChecked ¶
UploadChecked copies float32 data to the buffer and reports malformed input.
type VkChannelAffineReLUF32 ¶
type VkChannelAffineReLUF32 struct {
// contains filtered or unexported fields
}
VkChannelAffineReLUF32 applies Out[c,s] = fma(X[c,s],Scale[c],Shift[c]) to contiguous channel-major F32 tensors. Optional ReLU is exact max(value,0) for finite inputs. This covers inference BatchNorm coefficients prepared by a model owner; it does not derive coefficients, scan data, or change defaults. Shapes are X/Out[channels,spatial...] rank2..8 and Scale/Shift[channels].
func NewVkChannelAffineReLUF32 ¶
func NewVkChannelAffineReLUF32(ctx context.Context) (*VkChannelAffineReLUF32, error)
func (*VkChannelAffineReLUF32) Close ¶
func (op *VkChannelAffineReLUF32) Close() error
func (*VkChannelAffineReLUF32) Forward ¶
func (op *VkChannelAffineReLUF32) Forward(ctx context.Context, out, x, scale, shift *VkTensorF32, relu bool) error
func (*VkChannelAffineReLUF32) Stage ¶
func (op *VkChannelAffineReLUF32) Stage(ctx context.Context, out, x, scale, shift *VkTensorF32, relu bool) (VkF32Stage, error)
Stage validates exact shape/storage and alias rules before returning a copied generic plan stage. Out may exactly alias X. Scale/Shift may alias each other, but neither may overlap Out; partial X/Out overlap is rejected.
type VkCommandBuffer ¶
type VkCommandBuffer uintptr
type VkCommandPool ¶
type VkCommandPool uintptr
type VkComputeKernel ¶
type VkComputeKernel struct {
// contains filtered or unexported fields
}
VkComputeKernel is a ready-to-dispatch Vulkan compute shader.
func VkKernelCreate ¶
func VkKernelCreate(spirv []byte, numBuffers int, pushConstantSize int) (*VkComputeKernel, error)
VkKernelCreate builds a compute kernel with1..16 buffers and0..128 push bytes (multiple of4). Partial construction rolls back resources; Close releases a successful completed kernel. Resource objects must not be copied. These bounds also obey queried descriptor/push/local-size/shared-memory limits. The shader must fit InspectVulkanShader's conservative core envelope; this is not full SPIR-V validation; descriptor/push reflection is restricted to flat32-bit layouts. VulkanInit must already have completed without concurrent device/function-pointer replacement.
func VkKernelCreateIntegerDot ¶
func VkKernelCreateIntegerDot(spirv []byte, numBuffers, pushConstantSize int) (*VkComputeKernel, error)
VkKernelCreateIntegerDot admits a packed mixed-signedness integer-dot module only on a device explicitly enabled by VulkanInitIntegerDot. No fallback.
func (*VkComputeKernel) Close ¶
func (k *VkComputeKernel) Close() error
Close destroys a completed, owned kernel once. Never copies the kernel. Pending or lost/uncertain state returns an error without native destruction. Successful closure invalidates cached operation pointers: wrappers return errors; cache recreation/device restart remains a separate future API.
func (*VkComputeKernel) Dispatch ¶
func (k *VkComputeKernel) Dispatch(groupsX, groupsY, groupsZ uint32, bufs []*VkBuf, pushData unsafe.Pointer) error
Dispatch retains the legacy one-second budget, now including queue admission. Caller pushData must point to at least pushSize readable bytes until return.
func (*VkComputeKernel) DispatchContext ¶
func (k *VkComputeKernel) DispatchContext(ctx context.Context, groupsX, groupsY, groupsZ uint32, bufs []*VkBuf, pushData unsafe.Pointer) error
DispatchContext serializes descriptors, command-pool recording, queue and mapped accesses. Fence waits poll in <=10ms slices with a one-second cap; context cancellation prevents submission at checked boundaries. Once submitted, cancellation/timeout retains kernel+buffers and requires VulkanDrain. A driver call in progress cannot be interrupted. Push data remains caller-owned/read-only.
func (*VkComputeKernel) DispatchF32Context ¶
func (k *VkComputeKernel) DispatchF32Context(ctx context.Context, x, y, z uint32, tensors []*VkTensorF32, pushData unsafe.Pointer) error
DispatchF32Context uses tensor byte ranges but retains their backing buffers, once each, through the existing synchronous lane/quarantine lifecycle. An arena referenced by one binding is blocked as a whole, even disjoint views. This method does not assert shader numeric types or model shape semantics: callers must choose an F32-compatible kernel and correctly sized push data.
type VkComputeShader ¶
type VkComputeShader struct {
// contains filtered or unexported fields
}
VkComputeShader wraps a compiled SPIR-V compute pipeline.
func LoadSPIRV ¶
func LoadSPIRV(spirv []byte, numBuffers int) (*VkComputeShader, error)
LoadSPIRV creates a legacy pipeline-only object (no dispatch surface). Close releases it; objects must not be copied. The checked limits match VkKernelCreate. Use VkKernelCreate for owned command/descriptor/fence execution.
func (*VkComputeShader) Close ¶
func (s *VkComputeShader) Close() error
Close releases an unused legacy shader once. It cannot be submitted through the public API, so no fence is required. Global device quarantine still applies.
type VkConv1D3F32 ¶
type VkConv1D3F32 struct {
// contains filtered or unexported fields
}
VkConv1D3F32 owns tiled kernel3/pad1 convolution, stride1 or2, no groups or dilation. W[outCh,inCh,3], B[outCh], output[ceil(inLen/stride),outCh]. Both input layouts produce time-major output, allowing resident stem chains. inLen1..4096,inCh/outCh1..2048. Caller ensures finite representable dot sums; no content scan, quantisation, implicit activation or model/default change.
func NewVkConv1D3F32 ¶
func NewVkConv1D3F32(ctx context.Context) (*VkConv1D3F32, error)
func (*VkConv1D3F32) Close ¶
func (op *VkConv1D3F32) Close() error
func (*VkConv1D3F32) Forward ¶
func (op *VkConv1D3F32) Forward(ctx context.Context, out, x, w, b *VkTensorF32, stride int, layout VkConvInputLayout) error
func (*VkConv1D3F32) Stage ¶
func (op *VkConv1D3F32) Stage(ctx context.Context, out, x, w, b *VkTensorF32, stride int, layout VkConvInputLayout) (VkF32Stage, error)
Stage rejects all output/input overlap and checks exact shape/byte extents. Input/input alias is allowed. Returned generic stage slices are caller-owned. Plans validate generic resources only, not these convolution invariants; callers who modify a stage assume responsibility for shader shape/alias safety.
type VkConv2DCHWF32 ¶
type VkConv2DCHWF32 struct {
// contains filtered or unexported fields
}
VkConv2DCHWF32 applies a bias-free 2-D convolution to contiguous channel-major X[inChannels,frequency,frames] and W[outChannels,inChannels,kernel,kernel]. Out is [outChannels,outFrequency,outFrames]. The checked Community-1 envelope admits kernel3/pad1 or kernel1/pad0, stride1/2, no groups or dilation. Caller-prepared BatchNorm, activation and residual addition are separate ops.
func NewVkConv2DCHWF32 ¶
func NewVkConv2DCHWF32(ctx context.Context) (*VkConv2DCHWF32, error)
func (*VkConv2DCHWF32) Close ¶
func (op *VkConv2DCHWF32) Close() error
func (*VkConv2DCHWF32) Forward ¶
func (op *VkConv2DCHWF32) Forward(ctx context.Context, out, x, weight *VkTensorF32, kernel, stride, padding int) error
func (*VkConv2DCHWF32) Stage ¶
func (op *VkConv2DCHWF32) Stage(ctx context.Context, out, x, weight *VkTensorF32, kernel, stride, padding int) (VkF32Stage, error)
Stage validates complete shape, storage and alias invariants before returning a copied generic stage. Output must be disjoint from input and weights; read-only input and weights may share storage. No host content scan is made.
type VkConvInputLayout ¶
type VkConvInputLayout uint32
VkConvInputLayout is the physical contiguous layout of Conv1D3 input.
const ( VkConvChannelsFirst VkConvInputLayout = iota // X[inCh,inLen] VkConvTimeMajor // X[inLen,inCh] )
type VkDescriptorPool ¶
type VkDescriptorPool uintptr
type VkDescriptorSet ¶
type VkDescriptorSet uintptr
type VkDescriptorSetLayout ¶
type VkDescriptorSetLayout uintptr
type VkDeviceMemory ¶
type VkDeviceMemory uintptr
type VkF32Plan ¶
type VkF32Plan struct {
// contains filtered or unexported fields
}
VkF32Plan owns descriptor sets (one per stage), one command buffer and fence. It records/executes1..64 stages serially per Run, one submission/wait. No DAG, reordering, automatic tensor dtype/shape inference, uploads or model ownership. Copies share state and Close; underlying kernels/arenas are NOT closed by it.
func NewVkF32Plan ¶
func NewVkF32Plan(ctx context.Context, stages []VkF32Stage) (*VkF32Plan, error)
func (*VkF32Plan) Rebind ¶
func (p *VkF32Plan) Rebind(ctx context.Context, stages []VkF32Stage) error
Rebind replaces stage shapes, ranges, workgroups and push constants without allocating native plan resources. The caller must obtain stages through the checked operators and keep their kernels and tensors alive. Kernel identity and descriptor count remain fixed because the existing sets use their original layouts. All stages are preflighted before changing plan state; failure or cancellation leaves the previous plan runnable.
type VkF32Stage ¶
type VkF32Stage struct {
Kernel *VkComputeKernel
Groups [3]uint32
Tensors []*VkTensorF32
PushWords []uint32
// contains filtered or unexported fields
}
VkF32Stage describes one explicitly ordered dispatch. PushWords are raw32bit push data (use math.Float32bits for floats) and must exactly match the kernel's push range. Plan construction copies slices/view metadata; kernels and arena allocations remain caller-owned and are checked again before every run.
type VkGELUErfF32 ¶
type VkGELUErfF32 struct {
// contains filtered or unexported fields
}
VkGELUErfF32 implements the erf GELU form via an explicit erfc approximation, not tanh and not bit-exact libm erf. GPU error/rounding and trained-model quality remain unqualified; source-model tolerances are documented separately. Input data must be finite. No content scan, F16/quantisation or silent fallback.
func NewVkGELUErfF32 ¶
func NewVkGELUErfF32(ctx context.Context) (*VkGELUErfF32, error)
func NewVkGELUOriginalTanhF32 ¶
func NewVkGELUOriginalTanhF32(ctx context.Context) (*VkGELUErfF32, error)
NewVkGELUOriginalTanhF32 returns the explicit original whisper.cpp/GGML tanh-form GELU (op_gelu expression order) on the shared contiguous F32 GELU operator ABI: identical shape/alias/grid admission, one element per invocation. Output differs from the default erf GELU; trained quality is qualified only through the model modes that select it. No default change.
func (*VkGELUErfF32) Close ¶
func (op *VkGELUErfF32) Close() error
func (*VkGELUErfF32) Forward ¶
func (op *VkGELUErfF32) Forward(ctx context.Context, out, x *VkTensorF32) error
func (*VkGELUErfF32) Stage ¶
func (op *VkGELUErfF32) Stage(ctx context.Context, out, x *VkTensorF32) (VkF32Stage, error)
Stage/Forward accept identical contiguous F32 shapes of rank1..8. One invocation owns one element. Exact in-place alias is supported; partial overlap is rejected. The generic returned stage must not be altered to bypass these operator checks. Element counts obey uint32/grid/descriptor bounds.
type VkLSTMCellF32 ¶
type VkLSTMCellF32 struct {
// contains filtered or unexported fields
}
VkLSTMCellF32 updates one unprojected LSTM state from caller-precombined PyTorch-IFGO gates. Gates is [4,hidden]; CellIn/HiddenOut/CellOut are [hidden]. Exact CellOut/CellIn alias is supported. HiddenOut and CellOut must be disjoint. Projection, bias composition, sequence order and bidirectionality are separate.
func NewVkLSTMCellF32 ¶
func NewVkLSTMCellF32(ctx context.Context) (*VkLSTMCellF32, error)
func (*VkLSTMCellF32) Close ¶
func (op *VkLSTMCellF32) Close() error
func (*VkLSTMCellF32) Forward ¶
func (op *VkLSTMCellF32) Forward(ctx context.Context, hiddenOut, cellOut, gates, cellIn *VkTensorF32) error
func (*VkLSTMCellF32) Stage ¶
func (op *VkLSTMCellF32) Stage(ctx context.Context, hiddenOut, cellOut, gates, cellIn *VkTensorF32) (VkF32Stage, error)
type VkLSTMSequenceF32 ¶
type VkLSTMSequenceF32 struct {
// contains filtered or unexported fields
}
VkLSTMSequenceF32 evaluates one direction of an unprojected PyTorch-IFGO LSTM. Input[frames,inputDim], weights[4*hidden,inputDim]/[4*hidden,hidden], biases [4*hidden], mutable hidden/cell[hidden], output[frames,outputWidth]. OutputOffset selects a disjoint direction slice. One workgroup owns the sequential recurrence.
func NewVkLSTMSequenceF32 ¶
func NewVkLSTMSequenceF32(ctx context.Context) (*VkLSTMSequenceF32, error)
func (*VkLSTMSequenceF32) Close ¶
func (op *VkLSTMSequenceF32) Close() error
func (*VkLSTMSequenceF32) Forward ¶
func (op *VkLSTMSequenceF32) Forward(ctx context.Context, output, input, weightIH, weightHH, biasIH, biasHH, hidden, cell *VkTensorF32, outputOffset int, reverse bool) error
func (*VkLSTMSequenceF32) Stage ¶
func (op *VkLSTMSequenceF32) Stage(ctx context.Context, output, input, weightIH, weightHH, biasIH, biasHH, hidden, cell *VkTensorF32, outputOffset int, reverse bool) (VkF32Stage, error)
func (*VkLSTMSequenceF32) StagePacked ¶
func (op *VkLSTMSequenceF32) StagePacked(ctx context.Context, output, input, weightIH, weightHH, biasIH, biasHH, hidden, cell *VkTensorF32, outputOffset int, reverse, packedWeights bool) (VkF32Stage, error)
StagePacked records the sequence with either ordinary row-major weights or column-major packed weights. Packed storage keeps adjacent output rows contiguous without changing any lane's reduction order.
type VkLayerNormF32 ¶
type VkLayerNormF32 struct {
// contains filtered or unexported fields
}
VkLayerNormF32 owns the row-wise LayerNorm pipeline. Forward/Stage use arena tensors directly with no intermediate host transfer. This initial operator uses centered population variance, learned scale+bias and F32 arithmetic. Static/mocked qualification is not device numerical or model qualification. Copies share the underlying kernel lifetime; Close invalidates derived plans.
func NewVkLayerNormF32 ¶
func NewVkLayerNormF32(ctx context.Context) (*VkLayerNormF32, error)
func (*VkLayerNormF32) Close ¶
func (op *VkLayerNormF32) Close() error
func (*VkLayerNormF32) Forward ¶
func (op *VkLayerNormF32) Forward(ctx context.Context, out, x, weight, bias *VkTensorF32, eps float32) error
func (*VkLayerNormF32) Stage ¶
func (op *VkLayerNormF32) Stage(ctx context.Context, out, x, weight, bias *VkTensorF32, eps float32) (VkF32Stage, error)
Stage returns owned descriptor/push slices for NewVkF32Plan. X/Out must have identical [rows,width] shapes, width1..16384. Weight/Bias are [width]. Exact X/Out alias is allowed; partial overlap and any output overlap with parameters is rejected. Read-only inputs may overlap. Epsilon must be positive finite. Contents must be finite and have representable F32 sums/variance: no tensor scan occurs here and overflow/driver rounding are not hidden by fallback. Like any VkF32Stage, callers may mutate it only under their own responsibility.
type VkLinearF16WeightF32 ¶
type VkLinearF16WeightF32 struct {
// contains filtered or unexported fields
}
VkLinearF16WeightF32 owns one immutable row-major IEEE-F16 weight matrix and a mixed-storage projection kernel. Inputs, bias, accumulation and output stay F32. F16 values are packed little-half-first into uint32 storage and widened in the shader. This uses no optional Vulkan 16-bit storage/compute feature. It is a standalone opt-in operator and cannot be placed in VkF32Plan. Copies share kernel/buffer closure; callers must exclude Forward from Close.
func NewVkLinearF16WeightF32 ¶
func NewVkLinearF16WeightF32(ctx context.Context, weights []float32, outDim, inDim int) (result *VkLinearF16WeightF32, err error)
NewVkLinearF16WeightF32 validates, narrows and owns weights[N,K]. Every input must be finite and remain finite after IEEE-F16 rounding. Odd element counts use a zero upper half in the last uint32 word. Construction allocates one dedicated host-visible/coherent weight buffer after creating the kernel.
func (*VkLinearF16WeightF32) Close ¶
func (op *VkLinearF16WeightF32) Close() error
func (*VkLinearF16WeightF32) Forward ¶
func (op *VkLinearF16WeightF32) Forward(ctx context.Context, out, x, bias *VkTensorF32) error
Forward validates X[M,K], Bias[N], Out[M,N]. Output cannot overlap X or Bias. The immutable dedicated weight buffer cannot alias caller arena tensors.
type VkLinearF32 ¶
type VkLinearF32 struct {
// contains filtered or unexported fields
}
VkLinearF32 owns an F32 projection kernel: X[M,K]*W[N,K]^T+B[N]. Constructors select a 16x16 baseline or experimental 32x32 output tile. No quantised interpretation, packing or transpose copy. Static and source- model tests are not device numerical/performance qualification. Stage/Forward use resident arena tensors; caller owns weights/bias/activations. Copies share kernel lifetime and Close invalidates stages/plans referencing the operator.
func NewVkLinearF32 ¶
func NewVkLinearF32(ctx context.Context) (*VkLinearF32, error)
func NewVkLinearRegTile64F32 ¶
func NewVkLinearRegTile64F32(ctx context.Context) (*VkLinearF32, error)
NewVkLinearRegTile64F32 explicitly selects a 64x64 output tile with sixteen accumulators per lane and 16KiB shared memory. F32 precision and K reduction order are unchanged. It is never an implicit fallback or serving default.
func NewVkLinearRegTileF32 ¶
func NewVkLinearRegTileF32(ctx context.Context) (*VkLinearF32, error)
NewVkLinearRegTileF32 explicitly selects an experimental 32x32-output, four-accumulator F32 kernel. Same shapes/alias contract, 8192 shared bytes. No automatic/default selection; device and model qualification is separate.
func (*VkLinearF32) Close ¶
func (op *VkLinearF32) Close() error
func (*VkLinearF32) Forward ¶
func (op *VkLinearF32) Forward(ctx context.Context, out, x, weight, bias *VkTensorF32) error
func (*VkLinearF32) Stage ¶
func (op *VkLinearF32) Stage(ctx context.Context, out, x, weight, bias *VkTensorF32) (VkF32Stage, error)
Stage validates fixed contiguous shapes: X[M,K],Weight[N,K],Bias[N],Out[M,N]. Positive M/N/K<=16384, plus queried resource limits, bound all shader indexing and per-invocation loops. Output may NOT overlap any input, even exact alias. Inputs may overlap each other. Supply a zero bias tensor for no-bias projection. No finite-value scan: caller must ensure representable F32 sums/products.
type VkLinearQ5GroupedF32 ¶
type VkLinearQ5GroupedF32 struct {
// contains filtered or unexported fields
}
VkLinearQ5GroupedF32 owns immutable original GGML Q5_0 blocks (32 values, 22 bytes/block), losslessly repacked into aligned 24-byte blocks. Eight lanes per block widen stored values into F32 shared memory. Input, bias, ordered accumulation and output remain F32. No quantisation or F16 activation rounding is performed. This standalone owner is not admitted to VkF32Plan or defaults. VkLinearQ5Set provides checked plan bindings over shared packed storage. Copies share native closure; callers must exclude Forward from Close.
func NewVkLinearQ5GroupedF32 ¶
func NewVkLinearQ5GroupedF32(ctx context.Context, raw []byte, outDim, inDim int) (result *VkLinearQ5GroupedF32, err error)
NewVkLinearQ5GroupedF32 copies and validates row-major original Q5_0 blocks. K must be divisible by 32. F16 scales must be finite; raw length must exactly match N*K/32*22. Packing preserves every source bit and adds two zero bytes after each scale. The caller may release raw after successful construction.
func (*VkLinearQ5GroupedF32) Close ¶
func (op *VkLinearQ5GroupedF32) Close() error
func (*VkLinearQ5GroupedF32) Forward ¶
func (op *VkLinearQ5GroupedF32) Forward(ctx context.Context, out, x, bias *VkTensorF32) error
Forward validates X[M,K], Bias[N], Out[M,N]. Output cannot overlap X or Bias. The immutable dedicated weight buffer cannot alias caller arena tensors.
type VkLinearQ5IntegerDotSet ¶
type VkLinearQ5IntegerDotSet struct {
// contains filtered or unexported fields
}
VkLinearQ5IntegerDotSet is an explicit experimental arithmetic owner. Original Q5 bytes are unchanged; activations and scales are quantised to Q8_1. It is not F32-equivalent. Callers must provide finite, bounded activations; there is no fallback or implicit device-feature upgrade. Magnitudes above1000, nonfinite values or nonzero block maxima below1e-30 yield NaN scale/sum markers; callers must reject nonfinite final output. Scratch uses uint32 payloads in F32 backing storage, never numerical float uploads/downloads.
func NewVkLinearQ5IntegerDotHybridSetStream ¶
func NewVkLinearQ5IntegerDotHybridSetStream(ctx context.Context, shapes []VkLinearQ5Shape, read func(context.Context, int) ([]byte, error)) (*VkLinearQ5IntegerDotSet, error)
NewVkLinearQ5IntegerDotHybridSetStream adds the ordered F32 activation kernel over the same original packed storage. This is an explicit hybrid arithmetic owner, not an unsupported-device fallback. Callers choose the kernel at build.
func NewVkLinearQ5IntegerDotMMQSetStream ¶
func NewVkLinearQ5IntegerDotMMQSetStream(ctx context.Context, shapes []VkLinearQ5Shape, read func(context.Context, int) ([]byte, error)) (*VkLinearQ5IntegerDotSet, error)
NewVkLinearQ5IntegerDotMMQSetStream selects the explicit four-block-step schedule. Each output keeps the same integer block sums, F32 block epilogue, increasing-block FMA order and final bias add as the base kernel. inDim must be a multiple of 128; there is no fallback to the base schedule.
func NewVkLinearQ5IntegerDotSetStream ¶
func NewVkLinearQ5IntegerDotSetStream(ctx context.Context, shapes []VkLinearQ5Shape, read func(context.Context, int) ([]byte, error)) (*VkLinearQ5IntegerDotSet, error)
func (*VkLinearQ5IntegerDotSet) Close ¶
func (s *VkLinearQ5IntegerDotSet) Close() error
func (*VkLinearQ5IntegerDotSet) F32Stage ¶
func (s *VkLinearQ5IntegerDotSet) F32Stage(ctx context.Context, index int, out, x, bias *VkTensorF32) (VkF32Stage, error)
F32Stage explicitly retains ordered F32 activations/accumulation for one view.
func (*VkLinearQ5IntegerDotSet) Stages ¶
func (s *VkLinearQ5IntegerDotSet) Stages(ctx context.Context, index int, out, x, bias, scratch *VkTensorF32) ([]VkF32Stage, error)
Stages returns quantisation and projection stages. scratch must contain exactly rows*(inDim/32)*9 words and must not overlap any live input/output/bias storage.
func (*VkLinearQ5IntegerDotSet) StorageBytes ¶
func (s *VkLinearQ5IntegerDotSet) StorageBytes() uint64
type VkLinearQ5Matrix ¶
VkLinearQ5Matrix contains original row-major GGML Q5_0 blocks. No requantisation.
type VkLinearQ5Set ¶
type VkLinearQ5Set struct {
// contains filtered or unexported fields
}
VkLinearQ5Set owns one pipeline and one aligned immutable packed allocation. Close plans using its checked stages before closing this owner.
func NewVkLinearQ5Decode4SetStream ¶
func NewVkLinearQ5Decode4SetStream(ctx context.Context, shapes []VkLinearQ5Shape, read func(context.Context, int) ([]byte, error)) (*VkLinearQ5Set, error)
NewVkLinearQ5Decode4SetStream explicitly decodes each original Q5 block with four lanes. Stored values and ordered F32 compute are unchanged; no fallback.
func NewVkLinearQ5Set ¶
func NewVkLinearQ5Set(ctx context.Context, matrices []VkLinearQ5Matrix) (result *VkLinearQ5Set, err error)
func NewVkLinearQ5SetStream ¶
func NewVkLinearQ5SetStream(ctx context.Context, shapes []VkLinearQ5Shape, read func(context.Context, int) ([]byte, error)) (*VkLinearQ5Set, error)
NewVkLinearQ5SetStream admits geometry and native allocation before requesting each matrix once. read must return original Q5_0 bytes of the exact extent; they are synchronously copied into final storage and not retained. Only one matrix needs to be materialised at a time. The callback runs while the Vulkan lane is held and must not call Vulkan tools/operators or mutate prior results. Errors/cancellation return no usable partial owner; failed cleanup preserves an owner with the error for retrying Close. read is never retained.
func (*VkLinearQ5Set) Close ¶
func (s *VkLinearQ5Set) Close() error
func (*VkLinearQ5Set) Stage ¶
func (s *VkLinearQ5Set) Stage(ctx context.Context, index int, out, x, bias *VkTensorF32) (VkF32Stage, error)
func (*VkLinearQ5Set) StorageBytes ¶
func (s *VkLinearQ5Set) StorageBytes() uint64
type VkLinearQ5Shape ¶
type VkLinearQ5Shape struct{ OutDim, InDim int }
VkLinearQ5Shape describes one row-major original Q5_0 matrix.
type VkLinearQ8WeightF32 ¶
type VkLinearQ8WeightF32 struct {
// contains filtered or unexported fields
}
VkLinearQ8WeightF32 owns a symmetric per-output-row Q8 weight matrix. Four signed bytes are packed little-byte-first per uint32; each output row has one F32 scale max(abs(row))/127. X, bias, accumulation and output remain F32. This standalone candidate requires no optional integer-dot Vulkan feature and cannot enter VkF32Plan. Copies share closure; exclude Forward from Close.
func NewVkLinearQ8WeightF32 ¶
func (*VkLinearQ8WeightF32) Close ¶
func (op *VkLinearQ8WeightF32) Close() error
func (*VkLinearQ8WeightF32) Forward ¶
func (op *VkLinearQ8WeightF32) Forward(ctx context.Context, out, x, bias *VkTensorF32) error
func (*VkLinearQ8WeightF32) Stage ¶
func (op *VkLinearQ8WeightF32) Stage(ctx context.Context, out, x, bias *VkTensorF32) (VkF32Stage, error)
Stage validates a Q8 projection for inclusion in VkF32Plan. The returned stage privately retains the packed-weight and scale ranges; the operator must outlive the plan and cannot Close while a submission is pending.
func (*VkLinearQ8WeightF32) StorageBytes ¶
func (op *VkLinearQ8WeightF32) StorageBytes() uint64
StorageBytes reports the immutable packed-weight allocation extent, including descriptor-alignment padding and F32 row scales.
type VkLinearQ8WeightMatrix ¶
VkLinearQ8WeightMatrix describes one row-major F32 matrix to quantise.
type VkLinearQ8WeightSet ¶
type VkLinearQ8WeightSet struct {
// contains filtered or unexported fields
}
VkLinearQ8WeightSet owns one Q8 pipeline and one aligned packed allocation for several immutable matrices. It is intended for model graphs with many linear projections. Copies share closure; every plan using a view must close first.
func NewVkLinearQ8WeightSet ¶
func NewVkLinearQ8WeightSet(ctx context.Context, matrices []VkLinearQ8WeightMatrix) (result *VkLinearQ8WeightSet, err error)
func (*VkLinearQ8WeightSet) Close ¶
func (set *VkLinearQ8WeightSet) Close() error
func (*VkLinearQ8WeightSet) Count ¶
func (set *VkLinearQ8WeightSet) Count() int
func (*VkLinearQ8WeightSet) Stage ¶
func (set *VkLinearQ8WeightSet) Stage(ctx context.Context, index int, out, x, bias *VkTensorF32) (VkF32Stage, error)
func (*VkLinearQ8WeightSet) StorageBytes ¶
func (set *VkLinearQ8WeightSet) StorageBytes() uint64
type VkPhysicalDevice ¶
type VkPhysicalDevice uintptr
type VkPipeline ¶
type VkPipeline uintptr
type VkPipelineLayout ¶
type VkPipelineLayout uintptr
type VkRoPESequenceF32 ¶
type VkRoPESequenceF32 struct {
// contains filtered or unexported fields
}
VkRoPESequenceF32 rotates the two halves of each [row,head,headDim] vector in place. The frequency table is [row,rotHalf,cos/sin]; Q and K may use the same read-only table. This is a plan-compatible device stage. Callers must provide finite inputs and call Close after all plans using it.
func NewVkRoPESequenceF32 ¶
func NewVkRoPESequenceF32(ctx context.Context) (*VkRoPESequenceF32, error)
func (*VkRoPESequenceF32) Close ¶
func (op *VkRoPESequenceF32) Close() error
func (*VkRoPESequenceF32) Forward ¶
func (op *VkRoPESequenceF32) Forward(ctx context.Context, x, freqs *VkTensorF32, heads int) error
func (*VkRoPESequenceF32) Stage ¶
func (op *VkRoPESequenceF32) Stage(ctx context.Context, x, freqs *VkTensorF32, heads int) (VkF32Stage, error)
type VkShaderModule ¶
type VkShaderModule uintptr
type VkTensorArena ¶
type VkTensorArena struct {
// contains filtered or unexported fields
}
VkTensorArena owns one host-visible/coherent VkBuf. F32 tensors are disjoint aligned ranges in that buffer. Allocation is monotonic, with no reset/reuse or per-tensor Free; Close releases the whole buffer only when idle. The capacity is currently <=maxStorageBufferRange, not an arbitrarily large device heap. It is not a resident model, an execution graph or a quantised tensor format.
func NewVkSharedTensorArena ¶
func NewVkSharedTensorArena(ctx context.Context, capacityBytes int) (*VkTensorArena, error)
NewVkSharedTensorArena requires coherent, CPU-cached native memory. No uncached fallback is permitted. It enables scoped CPU/SIMD access to the same allocation used by Vulkan; it does not initialise a device.
func NewVkTensorArena ¶
func NewVkTensorArena(ctx context.Context, capacityBytes int) (*VkTensorArena, error)
func (*VkTensorArena) AllocF32 ¶
func (a *VkTensorArena) AllocF32(ctx context.Context, shape ...int) (*VkTensorF32, error)
AllocF32 reserves a fresh, disjoint range. Contents are uninitialised until an Upload or a shader fully writes them. No native allocation occurs. Rank1..8, dimensions>0 and the complete shape/rounded offset must fit before mutation. Pending use of ANY view blocks reservations/transfers/Close for the arena.
func (*VkTensorArena) AllocF32Aligned ¶
func (a *VkTensorArena) AllocF32Aligned(ctx context.Context, align uint64, shape ...int) (*VkTensorF32, error)
AllocF32Aligned is AllocF32 with the view offset additionally aligned to align bytes (a power of two; 0 keeps the device storage alignment), e.g. for shaders that read the view as uvec4.
func (*VkTensorArena) Close ¶
func (a *VkTensorArena) Close() error
func (*VkTensorArena) Stats ¶
func (a *VkTensorArena) Stats() VkTensorArenaStats
type VkTensorArenaStats ¶
type VkTensorF32 ¶
type VkTensorF32 struct {
// contains filtered or unexported fields
}
VkTensorF32 is a contiguous row-major view with owned shape metadata. It keeps its arena state/backing buffer reachable and exposes no raw handle or mapped pointer. Copies share storage/closure, not ownership of a second allocation.
func (*VkTensorF32) Download ¶
func (t *VkTensorF32) Download(ctx context.Context, data []float32) error
func (*VkTensorF32) Elements ¶
func (t *VkTensorF32) Elements() int
func (*VkTensorF32) PrefixRows ¶
func (t *VkTensorF32) PrefixRows(ctx context.Context, rows int) (*VkTensorF32, error)
PrefixRows returns a non-owning [rows,width] view over the first rows of a rank-two tensor. It does not allocate storage or alter the parent. The arena owner must outlive all uses of the view; transfers and stages still check closure and in-flight state against that owner.
func (*VkTensorF32) ReshapeF32 ¶
func (t *VkTensorF32) ReshapeF32(ctx context.Context, shape ...int) (*VkTensorF32, error)
ReshapeF32 changes only owned shape metadata, never storage. It preserves the exact element count and caller ownership/lifetime, with ordinary binding validation. It does not authorise overlapping writable operations.
func (*VkTensorF32) Shape ¶
func (t *VkTensorF32) Shape() []int
func (*VkTensorF32) Upload ¶
func (t *VkTensorF32) Upload(ctx context.Context, data []float32) error
Upload/Download require the exact tensor length, so an undersized transfer cannot silently leave a tensor partially updated. Cancellation is checked at lane admission and before the copy; the single bounded copy is not preempted. Caller slices must not be accessed concurrently during transfer.
func (*VkTensorF32) WithCPURead ¶
WithCPURead borrows the tensor's native, CPU-cached mapping synchronously. The slice MUST NOT escape the callback, be mutated, or be used asynchronously. The callback must not reenter any Vulkan API (including Close/Stats): the package lane remains held, excluding submission, transfer and destruction. GPU-written data is accessible only after a confirmed fence and the existing compute-to-host barrier. An in-flight/uncertain/lost owner is rejected.
func (*VkTensorF32) WithCPUWrite ¶
WithCPUWrite borrows the same mapping for a synchronous producer. The slice must not escape or be used asynchronously, and Vulkan APIs must not be called from the callback. Errors/cancellation/panics release the lease but do not roll back writes; callers must discard or fully overwrite failed contents before submitting them. Subsequent dispatch uses the host-to-compute barrier.
type VkTrainingF32 ¶
type VkTrainingF32 struct {
// contains filtered or unexported fields
}
VkTrainingF32 owns experimental F32 training pipelines. It never initialises Vulkan itself. Callers must keep finite gradients, nonnegative second moments and all state resident until dispatch completion. Device numerical/performance qualification is separate from SPIR-V compilation and offline admission tests. A failed submitted update requires coherent checkpoint recovery, never retry.
func NewVkTrainingF32 ¶
func NewVkTrainingF32(ctx context.Context) (*VkTrainingF32, error)
func (*VkTrainingF32) AdamWScaledStage ¶
func (op *VkTrainingF32) AdamWScaledStage(ctx context.Context, parameter, gradient, m, v, ema, clip *VkTensorF32, p train.AdamWStep) (VkF32Stage, error)
func (*VkTrainingF32) AdamWStage ¶
func (op *VkTrainingF32) AdamWStage(ctx context.Context, parameter, gradient, m, v, ema *VkTensorF32, p train.AdamWStep) (VkF32Stage, error)
AdamWStage mutates parameter/M/V and, when enabled, EMA. All five exact vector ranges must be disjoint, including the read-only gradient. Disabled EMA still binds distinct owned scratch (it is neither read nor written).
func (*VkTrainingF32) AttentionBackwardPlan ¶
func (op *VkTrainingF32) AttentionBackwardPlan(ctx context.Context, dq, dk, dv, dp, ds, q, k, v, prob, dy *VkTensorF32, contextRows int, scale float32) (*VkF32Plan, error)
AttentionBackwardPlan validates all five stages before any submission. dP and dScore are scratch; dQ/dK/dV are pre-inverse-RoPE outputs. The existing Vulkan plan supplies compute/host dependencies and retains unresolved submissions. All five write ranges must be disjoint from each other and every read-only input, even though individual stages only bind their own dependencies.
func (*VkTrainingF32) AttentionBackwardStage ¶
func (op *VkTrainingF32) AttentionBackwardStage(ctx context.Context, dst, q, k, v, prob, dy, aux *VkTensorF32, contextRows int, mode uint32, scale float32) (VkF32Stage, error)
AttentionBackwardStage is one causal backward primitive, not a complete transformer. Mode0 produces dense dP; mode1 consumes it to produce scaled dScore; mode2/3 consume dScore for dQ/dK; mode4 produces dV. Only mode0/1 write dense [H,S,S]; all other outputs are [S,H,D]. No padding keys. Aux must still be a distinct valid [H,S,S] tensor when unused (mode0/4).
func (*VkTrainingF32) AttentionForwardStage ¶
func (op *VkTrainingF32) AttentionForwardStage(ctx context.Context, dst, q, k, v, aux *VkTensorF32, contextRows int, mode uint32, scale float32) (VkF32Stage, error)
AttentionForwardStage overwrites exact-key causal scores, softmax or weighted values. Q/K/V are [S,H,D], aux is [H,S,S] and never aliases writable output. mode0 aux is unused scratch; mode1 consumes scores; mode2 probabilities.
func (*VkTrainingF32) AttentionReady ¶
func (op *VkTrainingF32) AttentionReady() bool
AttentionReady checks owned host metadata only. Caller still owns native initialisation/device health and must not race Close or replace Vulkan state.
func (*VkTrainingF32) Close ¶
func (op *VkTrainingF32) Close() error
func (*VkTrainingF32) CompactEmbeddingAccumulateStage ¶
func (op *VkTrainingF32) CompactEmbeddingAccumulateStage(ctx context.Context, out, previous, compact, index *VkTensorF32, rows, width, vocabulary int, scale float32) (VkF32Stage, error)
Index content admission is the raw caller's responsibility; all four buffers must stay immutable/alive through the synchronous resident plan execution.
func (*VkTrainingF32) EOSAdmissionStage ¶
func (op *VkTrainingF32) EOSAdmissionStage(ctx context.Context, hidden, weight, bias, dst *VkTensorF32, rows, width int) (VkF32Stage, error)
func (*VkTrainingF32) EOSStage ¶
func (op *VkTrainingF32) EOSStage(ctx context.Context, dst, x, labels *VkTensorF32, active int, mode uint32, weight float32) (VkF32Stage, error)
func (*VkTrainingF32) EmbeddingStage ¶
func (op *VkTrainingF32) EmbeddingStage(ctx context.Context, dst, source, ids *VkTensorF32, rows, width, vocabulary int, mode uint32) (VkF32Stage, error)
Raw callers must admit IDs/index contents; Tape.Validate does so for tapes.
func (*VkTrainingF32) GELUStage ¶
func (op *VkTrainingF32) GELUStage(ctx context.Context, dst, x, seed *VkTensorF32, mode uint32) (VkF32Stage, error)
GELUStage applies tanh-approximate GELU or its VJP to disjoint F32 vectors. As with other raw stages, callers own finite/representable input admission.
func (*VkTrainingF32) LSDLossStage ¶
func (op *VkTrainingF32) LSDLossStage(ctx context.Context, dst, prediction, desired, logvar *VkTensorF32, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) LayerNormBackwardPlan ¶
func (op *VkTrainingF32) LayerNormBackwardPlan(ctx context.Context, dx, dw, db, xhat, inv, weight, dy *VkTensorF32) (*VkF32Plan, error)
LayerNormBackwardPlan overwrites all input/affine derivatives in one validated plan. It consumes pre-affine normalized values and the forward inverse stddev.
func (*VkTrainingF32) LayerNormBackwardStage ¶
func (op *VkTrainingF32) LayerNormBackwardStage(ctx context.Context, dst, xhat, inv, weight, dy *VkTensorF32, mode uint32) (VkF32Stage, error)
LayerNormBackwardStage consumes cached pre-affine Xhat, inverse stddev and affine weight. Each dispatch overwrites one derivative; no atomic addition.
func (*VkTrainingF32) LinearBackwardStage ¶
func (op *VkTrainingF32) LinearBackwardStage(ctx context.Context, dst, x, w, dy *VkTensorF32, mode uint32) (VkF32Stage, error)
LinearBackwardStage returns one overwrite stage: mode0=dX,1=dW,2=dBias. Inputs may alias each other; destination must be disjoint from all inputs. Use separate stages and explicit branch-gradient accumulation as needed.
func (*VkTrainingF32) LinearDualBackwardPlan ¶
func (op *VkTrainingF32) LinearDualBackwardPlan(ctx context.Context, dx, dt, dw, db, x, xt, w, gv, gt *VkTensorF32) (*VkF32Plan, error)
LinearDualBackwardPlan overwrites primal/tangent input, weight and optional bias adjoints. All write ranges are independent. No accumulation or tangent bias is inserted. Pipeline/arena lifetime remains with the caller.
func (*VkTrainingF32) LinearDualBackwardStage ¶
func (op *VkTrainingF32) LinearDualBackwardStage(ctx context.Context, dst, x, xt, w, gv, gt *VkTensorF32, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) LinearDualForwardStage ¶
func (op *VkTrainingF32) LinearDualForwardStage(ctx context.Context, dst, x, xt, w, bias *VkTensorF32, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) ModDualBackwardStage ¶
func (op *VkTrainingF32) ModDualBackwardStage(ctx context.Context, dst, a, at, b, bt, gv, gt *VkTensorF32, kind, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) ModDualForwardStage ¶
func (op *VkTrainingF32) ModDualForwardStage(ctx context.Context, dst, a, at, b, bt *VkTensorF32, kind, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) NormDualBackwardPlan ¶
func (op *VkTrainingF32) NormDualBackwardPlan(ctx context.Context, dx, dt, dw, db, x, xt, w, gv, gt, stats *VkTensorF32, kind uint32) (*VkF32Plan, error)
NormDualBackwardPlan writes input adjoints and affine gradients. kind1 is sample-variance norm and has no bias (db must be nil). Stats come from forward.
func (*VkTrainingF32) NormDualBackwardStage ¶
func (op *VkTrainingF32) NormDualBackwardStage(ctx context.Context, dst, x, xt, w, gv, gt, stats *VkTensorF32, kind, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) NormDualForwardPlan ¶
func (op *VkTrainingF32) NormDualForwardPlan(ctx context.Context, y, yt, stats, scratch, x, xt, w, bias *VkTensorF32, kind uint32, epsilon float32) (*VkF32Plan, error)
NormDualForwardPlan writes stats/value/tangent. Unused stats input in the first stage is a distinct scratch view, not an output alias.
func (*VkTrainingF32) NormDualForwardStage ¶
func (op *VkTrainingF32) NormDualForwardStage(ctx context.Context, dst, x, xt, w, bias, stats *VkTensorF32, kind, mode uint32, epsilon float32) (VkF32Stage, error)
func (*VkTrainingF32) NormStatsStage ¶
func (op *VkTrainingF32) NormStatsStage(ctx context.Context, dst, x *VkTensorF32, nonnegative bool) (VkF32Stage, error)
func (*VkTrainingF32) ReLUStage ¶
func (op *VkTrainingF32) ReLUStage(ctx context.Context, dst, x, seed *VkTensorF32, mode uint32) (VkF32Stage, error)
ReLUStage overwrites an owned forward/VJP vector; derivative at zero is zero.
func (*VkTrainingF32) RoPEStage ¶
func (op *VkTrainingF32) RoPEStage(ctx context.Context, dst, x, table *VkTensorF32, mode uint32) (VkF32Stage, error)
RoPEStage reads X[rows,heads,dim] and table[rows,dim/2,2], shared across heads, and overwrites a disjoint output. mode1 is the input-adjoint R^T. No shader trigonometry, native initialisation or implicit fallback occurs.
func (*VkTrainingF32) RowStage ¶
func (op *VkTrainingF32) RowStage(ctx context.Context, dst, a, b *VkTensorF32, rows, width, parts, slot int, mode uint32) (VkF32Stage, error)
RowStage accepts flat contiguous vectors; row/part geometry is explicit so reshape aliases cannot silently change the gather/scatter convention.
func (*VkTrainingF32) SiLUBackwardStage ¶
func (op *VkTrainingF32) SiLUBackwardStage(ctx context.Context, dst, x, dy *VkTensorF32) (VkF32Stage, error)
SiLUBackwardStage consumes pre-activation X and upstream dY, writing dX. No output/input alias is admitted, including exact in-place use.
func (*VkTrainingF32) SiLUDualBackwardStage ¶
func (op *VkTrainingF32) SiLUDualBackwardStage(ctx context.Context, dx, dt, x, xt, gv, gt *VkTensorF32) (VkF32Stage, error)
SiLUDualBackwardStage evaluates reverse-over-forward SiLU input adjoints from primal/tangent inputs and independent output adjoints. It retains the second derivative needed by the minimal-LSD time-JVP loss, not finite differences.
func (*VkTrainingF32) SiLUDualForwardStage ¶
func (op *VkTrainingF32) SiLUDualForwardStage(ctx context.Context, dst, x, xt *VkTensorF32, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) TimeEmbeddingStage ¶
func (op *VkTrainingF32) TimeEmbeddingStage(ctx context.Context, dst, frequency, time, gv, gt *VkTensorF32, mode uint32) (VkF32Stage, error)
func (*VkTrainingF32) VectorStage ¶
func (op *VkTrainingF32) VectorStage(ctx context.Context, dst, a, b *VkTensorF32, offset int, mode uint32, scale float32) (VkF32Stage, error)
type VkTrainingTape ¶
type VkTrainingTape struct {
// contains filtered or unexported fields
}
VkTrainingTape owns a bounded tensor allocation and ordered plans, while the caller owns kernels. Commands/tensor shapes are validated before allocation. Forward/backward tensor intermediates stay resident between plan chunks. A submitted failure marks terminal and retains all native resources.
func NewVkTrainingTape ¶
func NewVkTrainingTape(ctx context.Context, op *VkTrainingF32, tape train.Tape, maxBytes int64) (*VkTrainingTape, error)
func (*VkTrainingTape) Close ¶
func (t *VkTrainingTape) Close() error
type VulkanCallError ¶
VulkanCallError retains the native status. It never implies that a timeout or failed submit made its resources idle. errors.As exposes Result.
func (*VulkanCallError) Error ¶
func (e *VulkanCallError) Error() string
type VulkanDeviceLimits ¶
type VulkanDeviceLimits struct {
APIVersion uint32
StorageBufferRange uint32
MemoryAllocationCount uint32
StorageBufferOffsetAlignment uint64
PushConstantBytes uint32
BoundDescriptorSets uint32
PerStageStorageBuffers uint32
PerStageResources uint32
DescriptorSetStorageBuffers uint32
WorkgroupCount [3]uint32
WorkgroupSize [3]uint32
WorkgroupInvocations uint32
}
VulkanDeviceLimits is an owned snapshot of queried core compute limits. Kernel construction checks WorkgroupSize/Invocations and SharedMemoryBytes against InspectVulkanShader's bounded metadata contract; Dispatch checks WorkgroupCount. This is not full shader validation. No optional features are enabled or promised (including float16/int8/subgroups).
func VulkanLimits ¶
func VulkanLimits() (VulkanDeviceLimits, error)
VulkanLimits returns a value copy, with no live driver call. Valid limits may be inspected during an ordinary retained submission. Lost/uncertain devices return their quarantine error. Availability is separate from VulkanReady.
type VulkanMemoryBudget ¶
VulkanMemoryBudget limits explicit VkDeviceMemory allocations owned by this package. Zero values mean no additional operator cap. The queried device allocation count and reported per-heap size always apply. Bytes are native memory requirements including padding, not just the requested buffer size. This does not cover opaque driver pipeline/descriptor allocations, other processes, system RAM, or physical free-memory availability.
type VulkanMemoryUsage ¶
type VulkanMemoryUsage struct {
Bytes uint64
Allocations uint32
// Peaks cover the ledger lifetime; freeing buffers never clears them.
PeakBytes uint64
PeakAllocations uint32
HeapBytes [16]uint64
Budget VulkanMemoryBudget
DeviceAllocationLimit uint32
InFlight, Uncertain, DeviceLost bool
}
VulkanMemoryUsage is an independent snapshot. Bytes and Allocations include pending, deferred-free and quarantined buffers until vkFreeMemory returns. HeapBytes uses VkMemoryHeap indices (at most16). No driver query is performed. DeviceLost/InFlight/Uncertain explain retained usage; inspecting it is allowed even when new work and destruction are blocked.
func VulkanMemoryStats ¶
func VulkanMemoryStats() VulkanMemoryUsage
type VulkanResidentDriver ¶
type VulkanResidentDriver struct {
Operator *VkTrainingF32
// contains filtered or unexported fields
}
func (*VulkanResidentDriver) Accumulate ¶
func (d *VulkanResidentDriver) Accumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
func (*VulkanResidentDriver) Close ¶
func (d *VulkanResidentDriver) Close() error
Close owns no tensor storage; failed plans keep their kernels/tensors reachable.
func (*VulkanResidentDriver) CompactEmbeddingAccumulate ¶
func (d *VulkanResidentDriver) CompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, rows, width, vocabulary int, scale float32) error
func (*VulkanResidentDriver) NewBoundTape ¶
func (d *VulkanResidentDriver) NewBoundTape(ctx context.Context, t train.Tape, parameters map[int]train.ResidentBuffer, maxBytes int64) (train.ResidentBoundTape, error)
func (*VulkanResidentDriver) NewBuffer ¶
func (d *VulkanResidentDriver) NewBuffer(ctx context.Context, n int) (train.ResidentBuffer, error)
func (*VulkanResidentDriver) NewReuseBoundTape ¶
func (d *VulkanResidentDriver) NewReuseBoundTape(ctx context.Context, tape train.Tape, bindings map[int]train.ResidentBuffer, maxBytes int64) (train.ResidentBoundTape, error)
func (*VulkanResidentDriver) NewZeroBoundTape ¶
func (d *VulkanResidentDriver) NewZeroBoundTape(ctx context.Context, t train.Tape, parameters map[int]train.ResidentBuffer, maxBytes int64) (train.ResidentBoundTape, error)
func (*VulkanResidentDriver) NormClip ¶
func (d *VulkanResidentDriver) NormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, maxNorm float32) error
func (*VulkanResidentDriver) NormMerge ¶
func (d *VulkanResidentDriver) NormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, mode uint32) error
func (*VulkanResidentDriver) NormStats ¶
func (d *VulkanResidentDriver) NormStats(ctx context.Context, dst, x train.ResidentBuffer, n int, nonnegative bool) error
func (*VulkanResidentDriver) Update ¶
func (d *VulkanResidentDriver) Update(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, step train.AdamWStep) error
func (*VulkanResidentDriver) UpdateScaled ¶
func (d *VulkanResidentDriver) UpdateScaled(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, step train.AdamWStep) error
func (*VulkanResidentDriver) ValidateAccumulate ¶
func (d *VulkanResidentDriver) ValidateAccumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
func (*VulkanResidentDriver) ValidateCompactEmbeddingAccumulate ¶
func (d *VulkanResidentDriver) ValidateCompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, rows, width, vocabulary int, scale float32) error
func (*VulkanResidentDriver) ValidateHandoffTape ¶
func (d *VulkanResidentDriver) ValidateHandoffTape(ctx context.Context, t train.Tape, bindings map[int]train.ResidentBuffer, maxBytes int64) error
func (*VulkanResidentDriver) ValidateNormClip ¶
func (d *VulkanResidentDriver) ValidateNormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, maxNorm float32) error
func (*VulkanResidentDriver) ValidateNormMerge ¶
func (d *VulkanResidentDriver) ValidateNormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, mode uint32) error
func (*VulkanResidentDriver) ValidateScaledUpdate ¶
func (d *VulkanResidentDriver) ValidateScaledUpdate(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, step train.AdamWStep) error
func (*VulkanResidentDriver) ValidateUpdate ¶
func (d *VulkanResidentDriver) ValidateUpdate(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, step train.AdamWStep) error
type VulkanShaderContract ¶
type VulkanShaderContract struct {
LocalSize [3]uint32
// Set0 storage-buffer bindings, one descriptor each (bits0..15). Callers
// may supply unused extra slots. PushBytes is the declared range from zero;
// padded/superset caller ranges are allowed. Both are conservative over all
// module declarations, not entrypoint liveness analysis.
StorageBindings uint32
PushBytes uint32
// IntegerDot is explicit packed mixed-signedness dot arithmetic only.
IntegerDot bool
}
VulkanShaderContract is bounded, conservative module metadata. Successful inspection is NOT full SPIR-V validation or proof of numerical correctness, memory safety or device compatibility. Descriptor/push reflection covers only the narrow scalar-buffer/flat-push envelope documented below. The supported envelope is intentionally narrower than Vulkan: SPIR-V1.0..1.3, Shader only, Logical/GLSL450, one GLCompute main, fixed LocalSize and core32bit types. Extended instructions are limited to FAbs, Sin, Cos, Exp, Log, Sqrt, InverseSqrt and Fma. Workgroup storage may be 32-bit scalars or fixed one-dimensional scalar arrays. No specialization, extensions, optional features or decorated shared layouts.
func InspectVulkanShader ¶
func InspectVulkanShader(code []byte) (VulkanShaderContract, error)
InspectVulkanShader does no driver calls. It copies the input before parsing; callers must not mutate input concurrently. Admission is capped at1MiB/65536 IDs, with a closed opcode envelope and unique result IDs. Optional arithmetic stays rejected here; the explicit integer-dot constructor uses a separate narrow envelope. Known instructions still need normal offline spirv-val validation: function/control-flow/operand semantics remain outside this check. Interfaces support set0 storage blocks of one runtime array of32-bit scalars and one flat32-bit-scalar push block.
type VulkanSharedWorkspaceDriver ¶
type VulkanSharedWorkspaceDriver struct {
// contains filtered or unexported fields
}
VulkanSharedWorkspaceDriver is an explicit adapter for guarded, stable-G shared residency. Existing VulkanResidentDriver allocation/routes are unchanged. Exact copy currently uses coherent mapped native storage under the Vulkan lane; no F32 arithmetic, temporary host staging or shader fallback is involved. This CPU copy must be included in transfer-inclusive performance measurements.
func NewVulkanSharedWorkspaceDriver ¶
func NewVulkanSharedWorkspaceDriver(op *VkTrainingF32) *VulkanSharedWorkspaceDriver
func (*VulkanSharedWorkspaceDriver) Accumulate ¶
func (d *VulkanSharedWorkspaceDriver) Accumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
func (*VulkanSharedWorkspaceDriver) Close ¶
func (d *VulkanSharedWorkspaceDriver) Close() error
func (*VulkanSharedWorkspaceDriver) CompactEmbeddingAccumulate ¶
func (d *VulkanSharedWorkspaceDriver) CompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, rows, width, vocab int, scale float32) error
func (*VulkanSharedWorkspaceDriver) Copy ¶
func (d *VulkanSharedWorkspaceDriver) Copy(ctx context.Context, dst, source train.ResidentBuffer, n int) error
func (*VulkanSharedWorkspaceDriver) NewBoundTape ¶
func (d *VulkanSharedWorkspaceDriver) NewBoundTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, maxBytes int64) (train.ResidentBoundTape, error)
func (*VulkanSharedWorkspaceDriver) NewBuffer ¶
func (d *VulkanSharedWorkspaceDriver) NewBuffer(ctx context.Context, n int) (train.ResidentBuffer, error)
func (*VulkanSharedWorkspaceDriver) NewReuseBoundTape ¶
func (d *VulkanSharedWorkspaceDriver) NewReuseBoundTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, maxBytes int64) (train.ResidentBoundTape, error)
func (*VulkanSharedWorkspaceDriver) NewZeroBoundTape ¶
func (d *VulkanSharedWorkspaceDriver) NewZeroBoundTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, maxBytes int64) (train.ResidentBoundTape, error)
func (*VulkanSharedWorkspaceDriver) NormClip ¶
func (d *VulkanSharedWorkspaceDriver) NormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, maxNorm float32) error
func (*VulkanSharedWorkspaceDriver) NormMerge ¶
func (d *VulkanSharedWorkspaceDriver) NormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, mode uint32) error
func (*VulkanSharedWorkspaceDriver) NormStats ¶
func (d *VulkanSharedWorkspaceDriver) NormStats(ctx context.Context, dst, source train.ResidentBuffer, n int, positive bool) error
func (*VulkanSharedWorkspaceDriver) Prefix ¶
func (d *VulkanSharedWorkspaceDriver) Prefix(ctx context.Context, parent train.ResidentBuffer, n int, access *train.SharedResidentAccess) (train.ResidentBuffer, error)
func (*VulkanSharedWorkspaceDriver) Update ¶
func (d *VulkanSharedWorkspaceDriver) Update(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, s train.AdamWStep) error
func (*VulkanSharedWorkspaceDriver) UpdateScaled ¶
func (d *VulkanSharedWorkspaceDriver) UpdateScaled(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, s train.AdamWStep) error
func (*VulkanSharedWorkspaceDriver) ValidateAccumulate ¶
func (d *VulkanSharedWorkspaceDriver) ValidateAccumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
func (*VulkanSharedWorkspaceDriver) ValidateCompactEmbeddingAccumulate ¶
func (d *VulkanSharedWorkspaceDriver) ValidateCompactEmbeddingAccumulate(ctx context.Context, out, previous, compact, index train.ResidentBuffer, rows, width, vocab int, scale float32) error
func (*VulkanSharedWorkspaceDriver) ValidateCopy ¶
func (d *VulkanSharedWorkspaceDriver) ValidateCopy(ctx context.Context, dst, source train.ResidentBuffer, n int) error
func (*VulkanSharedWorkspaceDriver) ValidateHandoffTape ¶
func (d *VulkanSharedWorkspaceDriver) ValidateHandoffTape(ctx context.Context, t train.Tape, inputs map[int]train.ResidentBuffer, maxBytes int64) error
func (*VulkanSharedWorkspaceDriver) ValidateNormClip ¶
func (d *VulkanSharedWorkspaceDriver) ValidateNormClip(ctx context.Context, dst, a train.ResidentBuffer, elements int64, maxNorm float32) error
func (*VulkanSharedWorkspaceDriver) ValidateNormMerge ¶
func (d *VulkanSharedWorkspaceDriver) ValidateNormMerge(ctx context.Context, dst, a, b train.ResidentBuffer, n int, previous int64, mode uint32) error
func (*VulkanSharedWorkspaceDriver) ValidateNormStats ¶
func (d *VulkanSharedWorkspaceDriver) ValidateNormStats(ctx context.Context, dst, source train.ResidentBuffer, n int, positive bool) error
func (*VulkanSharedWorkspaceDriver) ValidateScaledUpdate ¶
func (d *VulkanSharedWorkspaceDriver) ValidateScaledUpdate(ctx context.Context, p, g, m, v, ema, clip train.ResidentBuffer, n int, s train.AdamWStep) error
func (*VulkanSharedWorkspaceDriver) ValidateSharedAccumulate ¶
func (d *VulkanSharedWorkspaceDriver) ValidateSharedAccumulate(ctx context.Context, dst, a, b train.ResidentBuffer, n int, scale float32) error
func (*VulkanSharedWorkspaceDriver) ValidateSharedInventory ¶
func (d *VulkanSharedWorkspaceDriver) ValidateSharedInventory(ctx context.Context, owners []train.ResidentBuffer, extents []int) error
func (*VulkanSharedWorkspaceDriver) ValidateUpdate ¶
func (d *VulkanSharedWorkspaceDriver) ValidateUpdate(ctx context.Context, p, g, m, v, ema train.ResidentBuffer, n int, s train.AdamWStep) error
Source Files
¶
- debug.go
- vulkan.go
- vulkan_abi.go
- vulkan_add.go
- vulkan_arena.go
- vulkan_attention.go
- vulkan_attention_outputilp.go
- vulkan_attention_padded_extent.go
- vulkan_attention_unroll.go
- vulkan_barrier.go
- vulkan_buf.go
- vulkan_channel_affine.go
- vulkan_conv.go
- vulkan_conv2d_chw.go
- vulkan_dispatch.go
- vulkan_gelu.go
- vulkan_gelu_original.go
- vulkan_glsl.go
- vulkan_init.go
- vulkan_integer_dot.go
- vulkan_layernorm.go
- vulkan_lifetime.go
- vulkan_limits.go
- vulkan_limits_abi.go
- vulkan_linear.go
- vulkan_linear_f16_weight.go
- vulkan_linear_q5_decode4.go
- vulkan_linear_q5_grouped.go
- vulkan_linear_q5_integer_dot.go
- vulkan_linear_q5_set.go
- vulkan_linear_q5_stream.go
- vulkan_linear_q8_weight.go
- vulkan_linear_q8_weight_set.go
- vulkan_lstm_cell.go
- vulkan_lstm_sequence.go
- vulkan_memory.go
- vulkan_ops.go
- vulkan_plan.go
- vulkan_rope_geometry.go
- vulkan_rope_sequence.go
- vulkan_spirv.go
- vulkan_spirv_attention_key32.go
- vulkan_spirv_attention_scoreilp.go
- vulkan_spirv_contract.go
- vulkan_spirv_contract_ops.go
- vulkan_spirv_embedded.go
- vulkan_spirv_layout.go
- vulkan_spirv_linear_q5_grouped.go
- vulkan_spirv_linear_regtile64.go
- vulkan_training.go
- vulkan_training_attention_forward.go
- vulkan_training_backward.go
- vulkan_training_device_scale.go
- vulkan_training_dual.go
- vulkan_training_dual_forward.go
- vulkan_training_dual_plan.go
- vulkan_training_dual_values.go
- vulkan_training_embedding.go
- vulkan_training_embedding_accumulate.go
- vulkan_training_eos.go
- vulkan_training_eos_admission.go
- vulkan_training_global_norm.go
- vulkan_training_handoff.go
- vulkan_training_lsd_loss.go
- vulkan_training_plan.go
- vulkan_training_relu.go
- vulkan_training_resident.go
- vulkan_training_resident_tape.go
- vulkan_training_rope.go
- vulkan_training_shared_workspace.go
- vulkan_training_tape.go
- vulkan_training_time_embedding.go
- vulkan_training_transformer.go
- vulkan_training_vector.go