ptx

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ptx manages embedded precompiled CUDA PTX/fatbin modules and caches loaded CUmodule / CUfunction handles per CUDA DeviceContext.

Index

Constants

View Source
const (
	ElemVMMaxInputs      = 12
	ElemVMMaxOutputs     = 6
	ElemVMMaxRegs        = 16
	ElemVMMaxInsts       = 48
	ElemVMMaxConsts      = 12
	ElemVMMultiMaxItems  = 24
	ElemVMMultiMaxIn     = 6
	ElemVMMultiMaxOut    = 4
	ElemVMSharedSlotMark = 0xFF
)

Limits synchronized with kernels/gomlx/elem_vm.cu.

View Source
const (
	ElemVMDomainF32 uint8 = 0
	ElemVMDomainF64 uint8 = 1
	ElemVMDomainI8  uint8 = 2
	ElemVMDomainI16 uint8 = 3
	ElemVMDomainI32 uint8 = 4
	ElemVMDomainI64 uint8 = 5
	ElemVMDomainU8  uint8 = 6
	ElemVMDomainU16 uint8 = 7
	ElemVMDomainU32 uint8 = 8
	ElemVMDomainU64 uint8 = 9

	ElemVMDomainAny uint8 = 0xFF
)

Register-file compute domains for ElemVM (must match kernels/gomlx/elem_vm.cu). Every cluster executes in one concrete domain:

  • ElemVMDomainF32: float32 registers (Float32, Float16, BFloat16, Bool)
  • ElemVMDomainF64: float64 registers (Float64, Bool)
  • ElemVMDomainI8..I64 / U8..U64: exact-width integer registers (matching int/uint + Bool)
  • ElemVMDomainAny: compile-time wildcard for pure-Bool nodes before merging with a typed cluster.
View Source
const (
	ElemVMDTypeF32  uint8 = 0
	ElemVMDTypeBool uint8 = 1
	ElemVMDTypeF16  uint8 = 2
	ElemVMDTypeBF16 uint8 = 3
	ElemVMDTypeF64  uint8 = 4
	ElemVMDTypeI8   uint8 = 5
	ElemVMDTypeI16  uint8 = 6
	ElemVMDTypeI32  uint8 = 7
	ElemVMDTypeI64  uint8 = 8
	ElemVMDTypeU8   uint8 = 9
	ElemVMDTypeU16  uint8 = 10
	ElemVMDTypeU32  uint8 = 11
	ElemVMDTypeU64  uint8 = 12
)

Storage dtype codes for ElemVM inputs and outputs (must match enum ElemVMDType in elem_vm.cu).

View Source
const (
	ElemVMModeFull   uint8 = 0 // in_idx = i
	ElemVMModeScalar uint8 = 1 // in_idx = 0
	ElemVMModeDiv    uint8 = 2 // in_idx = i / param1
	ElemVMModeMod    uint8 = 3 // in_idx = i % param1
	ElemVMModeDivMod uint8 = 4 // in_idx = (i / param1) % param2
)

Input broadcast modes (must match enum ElemVMInMode in elem_vm.cu).

View Source
const (
	VMOpLoadInput   uint8 = 0
	VMOpLoadConst   uint8 = 1
	VMOpStoreOutput uint8 = 2
	VMOpCopy        uint8 = 3
	VMOpRoundF16    uint8 = 4
	VMOpRoundBF16   uint8 = 5

	VMOpNeg        uint8 = 10
	VMOpAbs        uint8 = 11
	VMOpSign       uint8 = 12
	VMOpSqrt       uint8 = 13
	VMOpRsqrt      uint8 = 14
	VMOpExp        uint8 = 15
	VMOpExpm1      uint8 = 16
	VMOpLog        uint8 = 17
	VMOpLog1p      uint8 = 18
	VMOpSin        uint8 = 19
	VMOpCos        uint8 = 20
	VMOpTanh       uint8 = 21
	VMOpSigmoid    uint8 = 22
	VMOpRelu       uint8 = 23
	VMOpSilu       uint8 = 24
	VMOpFloor      uint8 = 25
	VMOpCeil       uint8 = 26
	VMOpRound      uint8 = 27
	VMOpErf        uint8 = 28
	VMOpLogicalNot uint8 = 29
	VMOpToBool     uint8 = 30
	VMOpIsFinite   uint8 = 31
	VMOpIsNaN      uint8 = 32
	VMOpBitNot     uint8 = 33
	VMOpBitCount   uint8 = 34
	VMOpClz        uint8 = 35

	VMOpAdd   uint8 = 40
	VMOpSub   uint8 = 41
	VMOpMul   uint8 = 42
	VMOpDiv   uint8 = 43
	VMOpMax   uint8 = 44
	VMOpMin   uint8 = 45
	VMOpPow   uint8 = 46
	VMOpRem   uint8 = 47
	VMOpAtan2 uint8 = 48

	VMOpEq     uint8 = 50
	VMOpNe     uint8 = 51
	VMOpGt     uint8 = 52
	VMOpGe     uint8 = 53
	VMOpLt     uint8 = 54
	VMOpLe     uint8 = 55
	VMOpLogAnd uint8 = 56
	VMOpLogOr  uint8 = 57
	VMOpLogXor uint8 = 58

	VMOpWhere uint8 = 60
	VMOpClamp uint8 = 61

	VMOpBitAnd   uint8 = 65
	VMOpBitOr    uint8 = 66
	VMOpBitXor   uint8 = 67
	VMOpShl      uint8 = 68
	VMOpShrArith uint8 = 69
	VMOpShrLog   uint8 = 70
)

Bytecode opcodes (must match enum ElemVMOp in elem_vm.cu).

View Source
const (
	ReduceOpSum    uint32 = 0
	ReduceOpProd   uint32 = 1
	ReduceOpMax    uint32 = 2
	ReduceOpMin    uint32 = 3
	ReduceOpBitAnd uint32 = 4
	ReduceOpBitOr  uint32 = 5
	ReduceOpBitXor uint32 = 6
	ReduceOpLogAnd uint32 = 7
	ReduceOpLogOr  uint32 = 8
	ReduceOpLogXor uint32 = 9
)

ReduceOp matches enum ReduceOp in kernels/gomlx/reduce.cu.

View Source
const (
	ScanOpCumSum uint32 = 0
	ScanOpCumMax uint32 = 1
)

ScanOp matches scan_op in kernels/gomlx/reduce.cu.

View Source
const (
	ModuleBootstrap    = "bootstrap"
	ModuleUnary        = "unary"
	ModuleBinary       = "binary"
	ModuleConvert      = "convert"
	ModuleShape        = "shape"
	ModuleReduce       = "reduce"
	ModuleDot          = "dot"
	ModuleConvPoolBN   = "conv_pool_bn"
	ModuleFused        = "fused"
	ModuleLinearAttn   = "linear_attn"
	ModuleQuant        = "quant"
	ModuleQuantMMQ     = "quant_mmq"
	ModuleElemVM       = "elem_vm"
	ModuleElemVMReduce = "elem_vm_reduce"
)

Module names registered in embeddedModules.

View Source
const (
	ScatterOpSum uint32 = 0
	ScatterOpMax uint32 = 1
	ScatterOpMin uint32 = 2
)

ScatterOp matches enum ScatterOp in kernels/gomlx/shape.cu.

View Source
const ConcatMultiMaxInputs = 24

ConcatMultiMaxInputs is the maximum number of inputs handled in a single concat_multi launch. Larger Concatenates are dispatched in chunks of ConcatMultiMaxInputs.

View Source
const DefaultBlockSize uint32 = 256

DefaultBlockSize is the default 1D CUDA thread block size for element-wise kernels.

View Source
const MaxBroadcastRank = 8

MaxBroadcastRank is the maximum tensor rank supported by inline value-passed BroadcastSpec. Must stay synchronized with MAX_BCAST_RANK in kernels/gomlx/*.cu.

View Source
const MaxSpatialRank = 6

MaxSpatialRank is the maximum spatial dimensionality supported by ConvGeneral kernels.

View Source
const QuantWarpBlockSize uint32 = 128

QuantWarpBlockSize is the block size (4 warps = 128 threads) used by warp-per-output quantized dense kernels.

View Source
const SDPABlockSize uint32 = 128

SDPABlockSize matches SDPA_BLOCK_SIZE in kernels/gomlx/fused.cu.

View Source
const SDPAMaxHeadDim = 1024

SDPAMaxHeadDim matches SDPA_MAX_HEAD_DIM in kernels/gomlx/fused.cu.

View Source
const SliceMultiMaxOutputs = 24

SliceMultiMaxOutputs is the maximum number of sibling Slice outputs handled in a single split_multi launch. Larger sibling slice groups are dispatched in chunks of SliceMultiMaxOutputs.

View Source
const TopKMaxKernelK = 64

TopKMaxKernelK matches TOPK_MAX_K in kernels/gomlx/fused.cu.

View Source
const XQ8BlockMetaBytes uint64 = 8

XQ8BlockMetaBytes is the byte size of struct XQ8BlockMeta in kernels/gomlx/quant_mmq.cu.

Variables

This section is empty.

Functions

func BinaryOpCode

func BinaryOpCode(op compute.OpType) (uint32, bool)

BinaryOpCode maps compute.OpType to kernels/gomlx/binary.cu enum BinaryOp.

func CmpOpCode

func CmpOpCode(op compute.OpType) (uint32, bool)

CmpOpCode maps comparison ops to kernels/gomlx/binary.cu enum CmpOp.

func DTypeCode

func DTypeCode(dt dtypes.DType) (uint32, bool)

DTypeCode maps dtypes.DType to kernels/gomlx/convert.cu enum DTypeCode.

func DTypeSuffix

func DTypeSuffix(dt dtypes.DType) (string, bool)

DTypeSuffix returns the kernel symbol suffix for a compute dtype (e.g., Float32 -> "f32").

func ElemVMDTypeBytes added in v0.1.2

func ElemVMDTypeBytes(dt uint8) uint64

ElemVMDTypeBytes returns the storage byte width for an ElemVMDType code.

func ElemVMDTypeCode added in v0.1.2

func ElemVMDTypeCode(dt dtypes.DType) (uint8, bool)

ElemVMDTypeCode maps supported compute dtypes to ElemVMDType codes.

func ElemVMDomainSuffix added in v0.1.2

func ElemVMDomainSuffix(domain uint8) string

ElemVMDomainSuffix returns the CUDA kernel suffix ("f32", "f64", "i8".."u64") for domain.

func ElemVMMultiKernelName added in v0.1.2

func ElemVMMultiKernelName(domain uint8) string

ElemVMMultiKernelName returns the CUDA kernel entry point in ModuleElemVM for a horizontally batched fusedMultiElemVM in the given compute domain.

func ElemVMReduceKernelName added in v0.1.2

func ElemVMReduceKernelName(variant string, domain uint8) string

ElemVMReduceKernelName returns the CUDA kernel entry point in ModuleElemVMReduce for variant ("small", "warp", or "block") and the given compute domain.

func ElemVMSingleKernelName added in v0.1.2

func ElemVMSingleKernelName(domain uint8) string

ElemVMSingleKernelName returns the CUDA kernel entry point in ModuleElemVM for a single-tensor fusedElemVM in the given compute domain.

func ElemVMVecKernelName added in v0.1.2

func ElemVMVecKernelName(domain uint8) string

ElemVMVecKernelName returns the vectorized CUDA kernel entry point in ModuleElemVM for a single-tensor fusedElemVM in the given compute domain.

func ElemVMVecWidth added in v0.1.2

func ElemVMVecWidth(domain uint8) uint64

ElemVMVecWidth returns the vector width (elements per thread) of fused_elem_vm_vec_<domain>. Domains with 1/2/4-byte elements use 4; 8-byte domains (f64, i64, u64) use 2.

func EncodeElemVMInst added in v0.1.2

func EncodeElemVMInst(op, dst, src0, src1 uint8) uint32

EncodeElemVMInst packs a single 32-bit ElemVM bytecode instruction. For ternary ops (VMOpWhere, VMOpClamp), pass src1 = (regB & 0xF) | ((regC & 0xF) << 4).

func Grid1D

func Grid1D(n uint64, blockSize uint32) uint32

Grid1D computes ceil(n / blockSize) as a uint32 grid dimension.

func LinearAttnDTypeCode added in v0.1.2

func LinearAttnDTypeCode(dt dtypes.DType) (uint32, bool)

LinearAttnDTypeCode maps floating-point dtypes to LA_DT_* constants in kernels/gomlx/linear_attn.cu.

func MagicDivU32 added in v0.1.2

func MagicDivU32(d uint32) (mul uint32, shift uint8)

MagicDivU32 computes (mul, shift) for exact unsigned 32-bit division by any d >= 1:

  • If d <= 1: returns (0, 0); device fast_div_u32 returns n.
  • If d >= 2: for all n in [0, 0xFFFFFFFF], t = umulhi(mul, n); q = (t + ((n - t) >> 1)) >> (shift - 1) == n / d, r = n - q * d == n % d.

func PredOpCode

func PredOpCode(op compute.OpType) (uint32, bool)

PredOpCode maps float predicate ops to kernels/gomlx/unary.cu enum PredOp.

func QuantDTypeCode

func QuantDTypeCode(dt dtypes.DType) (uint32, bool)

QuantDTypeCode maps compute dtypes to the QDT_* constants in kernels/gomlx/quant.cu.

func QuantMMQGGMLKernelName added in v0.1.2

func QuantMMQGGMLKernelName(ggmlType compute.GGMLQuantType, tile MMQTileVariant) (string, bool)

QuantMMQGGMLKernelName returns the INT8 Tensor Core MMQ family kernel name for ggmlType and tile variant.

func RowMajorStrides

func RowMajorStrides(dims []int) [MaxBroadcastRank]uint64

RowMajorStrides computes contiguous row-major element strides for dims.

func UnaryOpCode

func UnaryOpCode(op compute.OpType) (uint32, bool)

UnaryOpCode maps compute.OpType to kernels/gomlx/unary.cu enum UnaryOp.

Types

type BroadcastSpec

type BroadcastSpec struct {
	Dims       [MaxBroadcastRank]uint64
	LHSStrides [MaxBroadcastRank]uint64
	RHSStrides [MaxBroadcastRank]uint64
	Rank       uint32
	// contains filtered or unexported fields
}

BroadcastSpec matches struct BroadcastSpec in kernels/gomlx/bootstrap.cu (200 bytes, 8-byte aligned).

func BuildBroadcastSpec

func BuildBroadcastSpec(lhs, rhs, out shapes.Shape) (BroadcastSpec, bool, error)

BuildBroadcastSpec builds a BroadcastSpec for binary broadcasting between lhs and rhs into out. Returns needsBcast=false when lhs, rhs, and out have identical dimensions (contiguous fast path).

type ConcatMultiSpec added in v0.1.2

type ConcatMultiSpec struct {
	InPtrs        [ConcatMultiMaxInputs]uint64
	ColEnds       [ConcatMultiMaxInputs]uint64
	ChunkBaseCol  uint64
	OutRowElems   uint64
	ChunkRowElems uint64
	NumInputs     uint32
	// contains filtered or unexported fields
}

ConcatMultiSpec matches struct ConcatMultiSpec in kernels/gomlx/shape.cu (416 bytes).

type Conv1DDepthwiseSpec added in v0.1.2

type Conv1DDepthwiseSpec struct {
	KSpStride   uint64
	KChanStride uint64
	Batch       uint32
	InS         uint32
	OutS        uint32
	Channels    uint32
	KSize       uint32
	Stride      uint32
	PadLow      int32
	InDil       uint32
	KDil        uint32
	// contains filtered or unexported fields
}

Conv1DDepthwiseSpec matches struct Conv1DDepthwiseSpec in kernels/gomlx/conv_pool_bn.cu (56 bytes, 8-byte aligned).

type ConvDirectSpec

type ConvDirectSpec struct {
	OutDims           [MaxBroadcastRank]uint64
	InStrides         [MaxBroadcastRank]uint64
	KStrides          [MaxBroadcastRank]uint64
	InSpDims          [MaxSpatialRank]uint64
	KSpDims           [MaxSpatialRank]uint64
	Strides           [MaxSpatialRank]uint64
	PadLow            [MaxSpatialRank]int64
	InDilations       [MaxSpatialRank]uint64
	KDilations        [MaxSpatialRank]uint64
	KSpSize           uint64
	KInChans          uint64
	OutBatchSize      uint64
	OutChansPerCGroup uint64
	OutChansPerBGroup uint64
	Rank              uint32
	SpatialRank       uint32
	InBatchAxis       uint32
	InChanAxis        uint32
	KInChanAxis       uint32
	KOutChanAxis      uint32
	OutBatchAxis      uint32
	OutChanAxis       uint32
	InSpAxes          [MaxSpatialRank]uint32
	KSpAxes           [MaxSpatialRank]uint32
	OutSpAxes         [MaxSpatialRank]uint32
	ChanGroups        uint32
	BatchGroups       uint32
}

ConvDirectSpec matches struct ConvDirectSpec in kernels/gomlx/conv_pool_bn.cu.

type DynamicSliceSpec

type DynamicSliceSpec struct {
	OpDims    [MaxBroadcastRank]uint64
	OpStrides [MaxBroadcastRank]uint64
	SliceDims [MaxBroadcastRank]uint64
	IdxPtrs   [MaxBroadcastRank]uint64
	Rank      uint32
	IdxDT     uint32
}

DynamicSliceSpec matches struct DynamicSliceSpec in kernels/gomlx/shape.cu.

type ElemVMMultiBatch added in v0.1.2

type ElemVMMultiBatch struct {
	SharedInPtrs [ElemVMMaxInputs]uint64
	VarSlotMap   [ElemVMMaxInputs]uint8
	NumItems     uint32
	Items        [ElemVMMultiMaxItems]ElemVMMultiItem
}

ElemVMMultiBatch matches struct ElemVMMultiBatch in kernels/gomlx/elem_vm.cu (2224 bytes).

type ElemVMMultiItem added in v0.1.2

type ElemVMMultiItem struct {
	InPtrs   [ElemVMMultiMaxIn]uint64
	OutPtrs  [ElemVMMultiMaxOut]uint64
	N        uint32
	BlockEnd uint32
}

ElemVMMultiItem matches struct ElemVMMultiItem in kernels/gomlx/elem_vm.cu (88 bytes).

type ElemVMProgram added in v0.1.2

type ElemVMProgram struct {
	Consts    [ElemVMMaxConsts]uint64
	Insts     [ElemVMMaxInsts]uint32
	InParam1  [ElemVMMaxInputs]uint32
	InParam2  [ElemVMMaxInputs]uint32
	InMul1    [ElemVMMaxInputs]uint32
	InMul2    [ElemVMMaxInputs]uint32
	InShift1  [ElemVMMaxInputs]uint8
	InShift2  [ElemVMMaxInputs]uint8
	InDTypes  [ElemVMMaxInputs]uint8
	InModes   [ElemVMMaxInputs]uint8
	OutDTypes [ElemVMMaxOutputs]uint8
	NumInsts  uint8
	Domain    uint8
}

ElemVMProgram matches struct ElemVMProgram in kernels/gomlx/elem_vm.cu (536 bytes). Consts stores raw bit-encoded inline scalar constants for the program's Domain:

  • F32 domain: uint64(math.Float32bits(f))
  • F64 domain: math.Float64bits(d)
  • Signed int domain: uint64(int64(v)) (sign-extended)
  • Unsigned int domain: uint64(v) (zero-extended)

InMul1/InShift1 and InMul2/InShift2 hold precomputed MagicDivU32 reciprocals for InParam1 and InParam2 so GPU div/mod indexing executes in ~4 cycles via __umulhi.

type ElemVMPtrs added in v0.1.2

type ElemVMPtrs struct {
	InPtrs  [ElemVMMaxInputs]uint64
	OutPtrs [ElemVMMaxOutputs]uint64
}

ElemVMPtrs matches struct ElemVMPtrs in kernels/gomlx/elem_vm.cu (144 bytes).

type GatherSpec

type GatherSpec struct {
	OutDims           [MaxBroadcastRank]uint64
	OpDims            [MaxBroadcastRank]uint64
	OpStrides         [MaxBroadcastRank]uint64
	SliceSizes        [MaxBroadcastRank]uint64
	IdxBatchStrides   [MaxBroadcastRank]uint64
	IdxVecStride      uint64
	OutToOpOffsetAxis [MaxBroadcastRank]int32
	StartIndexMap     [MaxBroadcastRank]int32
	OutRank           uint32
	OpRank            uint32
	IdxVecLen         uint32
	IdxDT             uint32
}

GatherSpec matches struct GatherSpec in kernels/gomlx/shape.cu.

type Im2Col2DNHWCSpec added in v0.1.1

type Im2Col2DNHWCSpec struct {
	Batch   uint32
	InH     uint32
	InW     uint32
	CIn     uint32
	OutH    uint32
	OutW    uint32
	KH      uint32
	KW      uint32
	StrideH uint32
	StrideW uint32
	PadH    int32
	PadW    int32
	InDilH  uint32
	InDilW  uint32
	KDilH   uint32
	KDilW   uint32
}

Im2Col2DNHWCSpec matches struct Im2Col2DNHWCSpec in kernels/gomlx/conv_pool_bn.cu (64 bytes, 4-byte aligned).

type Im2ColSpec

type Im2ColSpec struct {
	OutSpatialDims   [MaxSpatialRank]uint64
	KSpatialDims     [MaxSpatialRank]uint64
	InSpatialDims    [MaxSpatialRank]uint64
	InSpatialStrides [MaxSpatialRank]uint64
	Strides          [MaxSpatialRank]uint64
	PadLow           [MaxSpatialRank]int64
	InDilations      [MaxSpatialRank]uint64
	KDilations       [MaxSpatialRank]uint64
	InBatchStride    uint64
	InChanStride     uint64
	BatchOut         uint64
	OutSpSize        uint64
	KSpSize          uint64
	CInPerGroup      uint64
	SpatialRank      uint32
	ChanGroups       uint32
}

Im2ColSpec matches struct Im2ColSpec in kernels/gomlx/conv_pool_bn.cu.

type InlineI64Spec

type InlineI64Spec struct {
	Vals [MaxBroadcastRank]int64
}

InlineI64Spec matches struct InlineI64Spec in kernels/gomlx/shape.cu.

type LinearAttnSpec added in v0.1.2

type LinearAttnSpec struct {
	B                uint64
	S                uint64
	NumKHeads        uint64
	NumVHeads        uint64
	HeadKDim         uint64
	HeadVDim         uint64
	QueryScaleF32    float32
	IsBSHD           uint32
	QKVDType         uint32
	GDType           uint32
	BetaDType        uint32
	StateDType       uint32
	DecayMode        uint32 // 0=none, 1=scalar, 2=channel
	HasBeta          uint32
	HasInitState     uint32
	UseQKL2Norm      uint32
	TiledKVHeads     uint32
	ReturnFinalState uint32
	QueryScaleF64    float64
}

LinearAttnSpec matches struct LinearAttnSpec in kernels/gomlx/linear_attn.cu (104 bytes, 8-byte aligned).

type MMQTileVariant added in v0.1.2

type MMQTileVariant uint8

MMQTileVariant selects the tile dimensions for INT8 Tensor Core MMQ kernels.

const (
	MMQTileTiny  MMQTileVariant = iota // BM=16, BN=64, 128 threads (small-M prefill M <= 16)
	MMQTileSmall                       // BM=64, BN=64, 128 threads (medium-M / narrow-N)
	MMQTileLarge                       // BM=128, BN=128, 256 threads (large prefill / batching)
)

type PadSpec

type PadSpec struct {
	OutDims      [MaxBroadcastRank]uint64
	InDims       [MaxBroadcastRank]uint64
	InStrides    [MaxBroadcastRank]uint64
	Start        [MaxBroadcastRank]int64
	InteriorStep [MaxBroadcastRank]uint64
	Rank         uint32
	// contains filtered or unexported fields
}

PadSpec matches struct PadSpec in kernels/gomlx/shape.cu.

type QuantDenseSpec

type QuantDenseSpec struct {
	M            uint64
	K            uint64
	N            uint64
	WSRowBlk     uint64
	WSColBlk     uint64
	WSNumColBlks uint64
	WZRowBlk     uint64
	WZColBlk     uint64
	WZNumColBlks uint64
	XSColBlk     uint64
	XSNumColBlks uint64
	XZColBlk     uint64
	XZNumColBlks uint64
	OSColBlk     uint64
	OSNumColBlks uint64
	OZColBlk     uint64
	OZNumColBlks uint64
	WBytesPerRow uint64
	XBytesPerRow uint64
	Scheme       uint32
	GGMLWType    uint32
	GGMLXType    uint32
	VPB          uint32
	BPBW         uint32
	BPBX         uint32
	WeightLayout uint32
	XDT          uint32
	WDT          uint32
	WSDT         uint32
	WZDT         uint32
	XSDT         uint32
	XZDT         uint32
	BiasDT       uint32
	OSDT         uint32
	OZDT         uint32
	OutDT        uint32
	ActType      uint32
	HasWZP       uint32
	XSKind       uint32
	XZKind       uint32
	HasBias      uint32
	BiasIsI32    uint32
	HasOutQuant  uint32
	OSKind       uint32
	OZKind       uint32
	// contains filtered or unexported fields
}

QuantDenseSpec matches struct QuantDenseSpec in kernels/gomlx/quant.cu (264 bytes, 8-byte aligned).

type QuantGatherSpec

type QuantGatherSpec struct {
	NumRowsOut      uint64
	VocabSize       uint64
	K               uint64
	ScaleRowBlk     uint64
	ScaleColBlk     uint64
	ScaleNumColBlks uint64
	ZPRowBlk        uint64
	ZPColBlk        uint64
	ZPNumColBlks    uint64
	Scheme          uint32
	XDT             uint32
	IdxDT           uint32
	ScaleDT         uint32
	ZPDT            uint32
	OutDT           uint32
	HasZP           uint32
	// contains filtered or unexported fields
}

QuantGatherSpec matches struct QuantGatherSpec in kernels/gomlx/quant.cu (104 bytes, 8-byte aligned).

type QuantMMQLinearSpec added in v0.1.2

type QuantMMQLinearSpec struct {
	M            uint64
	K            uint64
	N            uint64
	WSRowBlk     uint64
	WSColBlk     uint64
	WSNumColBlks uint64
	WZRowBlk     uint64
	WZColBlk     uint64
	WZNumColBlks uint64
	WeightLayout uint32
	WDT          uint32
	WSDT         uint32
	WZDT         uint32
	HasWZP       uint32
	OutDT        uint32
	BiasDT       uint32
	HasBias      uint32
	ActType      uint32
	GridM        uint32
	GridN        uint32
	// contains filtered or unexported fields
}

QuantMMQLinearSpec matches struct QuantMMQLinearSpec in kernels/gomlx/quant_mmq.cu (120 bytes, 8-byte aligned).

type QuantMMQSpec added in v0.1.2

type QuantMMQSpec struct {
	M            uint64
	K            uint64
	N            uint64
	WBytesPerRow uint64
	OutDT        uint32
	BiasDT       uint32
	HasBias      uint32
	ActType      uint32
	GridM        uint32
	GridN        uint32
	GGMLType     uint32
	// contains filtered or unexported fields
}

QuantMMQSpec matches struct QuantMMQSpec in kernels/gomlx/quant_mmq.cu (64 bytes, 8-byte aligned).

type ReduceSpec

type ReduceSpec struct {
	OutDims      [MaxBroadcastRank]uint64
	OutInStrides [MaxBroadcastRank]uint64
	RedDims      [MaxBroadcastRank]uint64
	RedInStrides [MaxBroadcastRank]uint64
	RedSize      uint64
	OutRank      uint32
	RedRank      uint32
}

ReduceSpec matches struct ReduceSpec in kernels/gomlx/reduce.cu.

type ReduceWindowSpec

type ReduceWindowSpec struct {
	OutDims       [MaxBroadcastRank]uint64
	InDims        [MaxBroadcastRank]uint64
	InStrides     [MaxBroadcastRank]uint64
	WinDims       [MaxBroadcastRank]uint64
	Strides       [MaxBroadcastRank]uint64
	BaseDilations [MaxBroadcastRank]uint64
	WinDilations  [MaxBroadcastRank]uint64
	PadLow        [MaxBroadcastRank]int64
	WinSize       uint64
	Rank          uint32
	Op            uint32
}

ReduceWindowSpec matches struct ReduceWindowSpec in kernels/gomlx/conv_pool_bn.cu.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry lazily loads embedded PTX modules into a single CUDA DeviceContext and caches CUmodule and CUfunction handles for fast, lock-free lookup on the hot path.

func NewRegistry

func NewRegistry(devCtx *driver.DeviceContext) *Registry

NewRegistry creates a new PTX module/function cache bound to devCtx.

func (*Registry) GetFunctionInContext

func (r *Registry) GetFunctionInContext(moduleName, kernelName string) (driver.Function, error)

GetFunctionInContext returns the cached CUfunction for (moduleName, kernelName), lazily loading the module if needed. Caller MUST already be executing inside devCtx.WithContext.

func (*Registry) PreloadModulesInContext added in v0.1.1

func (r *Registry) PreloadModulesInContext(moduleNames []string) error

PreloadModulesInContext ensures all specified embedded PTX modules are loaded into the CUDA context (no-op for already-loaded modules). Called before cuStreamBeginCapture so cuModuleLoadDataEx never runs during stream capture.

func (*Registry) UnloadAll

func (r *Registry) UnloadAll()

UnloadAll unloads every loaded CUmodule from the CUDA context. Must be called before DeviceContext.Release().

type RoPESpec added in v0.1.1

type RoPESpec struct {
	OuterDims     [MaxBroadcastRank]uint64
	CosRowStrides [MaxBroadcastRank]uint64
	TotalRows     uint64
	HeadDim       uint64
	DimStart      uint64
	RotaryHalfDim uint64
	OuterRank     uint32
	Interleaved   uint32
	Inverse       uint32
	CosIsF32      uint32
}

RoPESpec matches struct RoPESpec in kernels/gomlx/fused.cu (176 bytes, 8-byte aligned).

type SDPASpec

type SDPASpec struct {
	BatchSize       uint64
	NumHeads        uint64
	NumKVHeads      uint64
	SeqLen          uint64
	KVLen           uint64
	HeadDim         uint64
	QBatchStride    uint64
	QHeadStride     uint64
	QSeqStride      uint64
	KVBatchStride   uint64
	KVHeadStride    uint64
	KVSeqStride     uint64
	MaskBatchStride uint64
	MaskHeadStride  uint64
	MaskSeqStride   uint64
	MaskKVStride    uint64
	BiasBatchStride uint64
	BiasHeadStride  uint64
	BiasSeqStride   uint64
	BiasKVStride    uint64
	Scale           float64
	Causal          uint32
	MaskMode        uint32 // 0=none, 1=bool, 2=additive
	HasBias         uint32
	HasSeqLens      uint32
}

SDPASpec matches struct SDPASpec in kernels/gomlx/fused.cu (184 bytes, 8-byte aligned).

type ScatterSpec

type ScatterSpec struct {
	UpdDims           [MaxBroadcastRank]uint64
	OpDims            [MaxBroadcastRank]uint64
	OpStrides         [MaxBroadcastRank]uint64
	IdxBatchStrides   [MaxBroadcastRank]uint64
	IdxVecStride      uint64
	UpdToOpWindowAxis [MaxBroadcastRank]int32
	ScatterToOpAxis   [MaxBroadcastRank]int32
	UpdRank           uint32
	OpRank            uint32
	IdxVecLen         uint32
	IdxDT             uint32
}

ScatterSpec matches struct ScatterSpec in kernels/gomlx/shape.cu.

type SelectAndScatterSpec

type SelectAndScatterSpec struct {
	SrcDims   [MaxBroadcastRank]uint64
	OpDims    [MaxBroadcastRank]uint64
	OpStrides [MaxBroadcastRank]uint64
	WinDims   [MaxBroadcastRank]uint64
	Strides   [MaxBroadcastRank]uint64
	PadLow    [MaxBroadcastRank]int64
	WinSize   uint64
	Rank      uint32
	IsMin     uint32
}

SelectAndScatterSpec matches struct SelectAndScatterSpec in kernels/gomlx/conv_pool_bn.cu.

type SliceMultiSpec added in v0.1.2

type SliceMultiSpec struct {
	OutPtrs          [SliceMultiMaxOutputs]uint64
	SrcColStarts     [SliceMultiMaxOutputs]uint64
	OutColEnds       [SliceMultiMaxOutputs]uint64
	SrcRowElems      uint64
	TotalOutRowElems uint64
	Outer            uint64
	NumOutputs       uint32
	// contains filtered or unexported fields
}

SliceMultiSpec matches struct SliceMultiSpec in kernels/gomlx/shape.cu (608 bytes).

type SplitMultiSpec added in v0.1.1

type SplitMultiSpec struct {
	OutPtrs  [4]uint64
	BiasPtrs [4]uint64
	Offsets  [4]uint64
	Dims     [4]uint64
	NumRows  uint64
	TotalOut uint64
	Count    uint32
	// contains filtered or unexported fields
}

SplitMultiSpec matches struct SplitMultiSpec in kernels/gomlx/fused.cu (152 bytes, 8-byte aligned).

type StridedCopySpec

type StridedCopySpec struct {
	Dims       [MaxBroadcastRank]uint64
	Strides    [MaxBroadcastRank]int64
	BaseOffset int64
	Rank       uint32
	// contains filtered or unexported fields
}

StridedCopySpec matches struct StridedCopySpec in kernels/gomlx/shape.cu.

type TernaryBroadcastSpec

type TernaryBroadcastSpec struct {
	Dims [MaxBroadcastRank]uint64
	S0   [MaxBroadcastRank]uint64
	S1   [MaxBroadcastRank]uint64
	S2   [MaxBroadcastRank]uint64
	Rank uint32
	// contains filtered or unexported fields
}

TernaryBroadcastSpec matches struct TernaryBroadcastSpec in kernels/gomlx/common.cuh (264 bytes).

func BuildTernaryBroadcastSpec

func BuildTernaryBroadcastSpec(s0, s1, s2, out shapes.Shape) (TernaryBroadcastSpec, bool, error)

BuildTernaryBroadcastSpec constructs a 3-operand broadcast spec for Where / Clamp. Returns needsBcast=false if all three inputs already match out's dimensions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL