cudabackend

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 26 Imported by: ? 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.

README

compute-cuda

[!NOTE] Experimental: This backend is freshly made and experimental. It passes the full compute/support/backendtest compliance suite and real-model parity tests (BERT/MiniLM/BGE FP32 & GGUF embedders, Timestral, Qwen 3.5 4B, Gemma 4 E4B, KaLM-Gemma3 12B), while performance tuning and API refinements are still ongoing.

github.com/gomlx/compute-cuda is a Pure-Go (CGO_ENABLED=0) direct CUDA compute backend (package cudabackend, registered as "cuda") for GoMLX / github.com/gomlx/compute.

It dynamically loads NVIDIA's Driver API (libcuda.so.1 / nvcuda.dll) and cuBLAS (libcublas.so.* / cublas64_*.dll) at runtime without CGo or a build-time CUDA Toolkit, and executes precompiled embedded PTX kernels (compute_75) directly on NVIDIA GPUs.

Key Features

  • Pure Go (CGO_ENABLED=0): Zero CGo, zero C/C++ compiler or nvcc required at build time.
  • Native Dynamic Shapes (DynamicShapesNative): Runs variable batch sizes and sequence lengths with zero JIT recompilation stalls.
  • Broad NVIDIA GPU Support: Precompiled compute_75 PTX supports Turing (sm_75, e.g., RTX 2080 Ti) through Blackwell (sm_120, e.g., RTX 5090), with native BFloat16/Float16 Tensor Cores on Ampere+ (cc >= 80) and transparent software BFloat16 adaptation on Turing (cc < 80).
  • Full StandardOps, Control Flow & FusedOps:
    • Element-wise, broadcasting, shape/slicing/indexing, reductions, scans, RNG (Philox, ThreeFry, SplitMix64), DotGeneral (cuBLAS), ConvGeneral (im2col+cuBLAS & direct), pooling, BatchNorm, and closures/control flow (Call, If, While, Sort).
    • Transformer fused ops: all 12 activations/VJP (including SwiGLU), FusedSoftmax, FusedLayerNorm/VJP, FusedDense/VJP, FusedAttentionQKVProjection, FlashAttention-style online-softmax FusedScaledDotProductAttention, and FusedTopK.
    • Quantized ops: QuantizedGather, FusedQuantizedDense, and FusedQuantizedDenseVJP across QuantLinear, QuantNF4, and all 12 GGML/GGUF formats (Q4_0, Q4_1, Q5_0, Q5_1, Q8_0, IQ4_NL, Q2_K, Q3_K, Q4_K, Q5_K, Q6_K, Q8_K), with GPU dequantization + cuBLAS Tensor Core prefill for M >= 16.
  • Stream-Ordered VRAM Pool & Zero-Copy Views: Uses CUDA 11.2+ cuMemAllocAsync/cuMemFreeAsync stream-ordered memory pools, ref-counted zero-copy views (Reshape, Bitcast, Identity, contiguous Transpose/BroadcastInDim/Slice), and in-place buffer donation reuse.

Usage

With GoMLX Default Backends

On Linux (amd64/arm64) and Windows (amd64), "cuda" is included automatically when importing GoMLX's default backends (exclude at build time with -tags=nocuda):

import (
	"github.com/gomlx/compute"
	_ "github.com/gomlx/gomlx/backends/default"
)

Select it at runtime via GOMLX_BACKEND:

export GOMLX_BACKEND=cuda
# Or target a specific GPU ordinal:
export GOMLX_BACKEND="cuda:device=1"
Direct Import (Pure-Go Binary)

Import compute-cuda directly alongside gobackend (or alone) for a CGO_ENABLED=0 binary without XLA/ONNX dependencies:

import (
	"github.com/gomlx/compute"
	_ "github.com/gomlx/compute-cuda"
)

Runtime Requirements & Library Discovery

At runtime, the host needs:

  1. An NVIDIA GPU (sm_75 / Turing or newer) with a compatible NVIDIA driver (libcuda.so.1 on Linux, nvcuda.dll on Windows).
  2. NVIDIA cuBLAS (libcublas.so.13, libcublas.so.12, libcublas.so.11, or libcublas.so on Linux; cublas64_13.dll / 12 / 11 on Windows) for dense matrix multiplication (DotGeneral, FusedDense, ConvGeneral, GGML prefill).

Libraries are searched in order:

  1. GOMLX_CUDA_LIB_DIR (explicit directory override list, searched first).
  2. OS dynamic linker paths (LD_LIBRARY_PATH, /etc/ld.so.cache, system dirs on Linux; PATH / System32 on Windows).
  3. CUDA_PATH, CUDA_HOME, CUDA_ROOT (and CONDA_PREFIX, VIRTUAL_ENV for cuBLAS).
  4. Standard OS and versioned CUDA Toolkit directories (e.g. /usr/local/cuda/lib64, /usr/local/cuda-*/lib64 newest-first, /usr/lib/wsl/lib on WSL2, /usr/lib/x86_64-linux-gnu).

Standard NVIDIA CUDA_VISIBLE_DEVICES is respected by the CUDA driver and reported in device-not-found diagnostics.

Limitations

  • FFT is not yet implemented (returns compute.ErrNotImplemented).
  • HasSharedBuffers() is false (discrete GPU VRAM; transfers use async H2D/D2H streams).
  • Native sub-byte dtypes (Int2, Uint2, Int4, Uint4) are supported via Quantization.PackedDType on Uint8 tensors rather than standalone DTypes.
  • Memory offloading / weight streaming (models larger than VRAM) is planned for future work.

Development & Testing

# Pure-Go build & full compliance test suite
CGO_ENABLED=0 go test -v ./...

# Concurrency / race detector verification
go test -race ./...

# Regenerate embedded PTX kernels after editing kernels/gomlx/*.cu (requires nvcc)
go generate ./internal/ptx

See docs/Plan.md for the architecture plan, benchmarks, and design decisions log.

License

This project is licensed under the Apache License, Version 2.0. See LICENSE and THIRD_PARTY_NOTICES.md for details.

Documentation

Overview

Package cudabackend implements a Pure-Go (CGO_ENABLED=0) direct CUDA compute backend for GoMLX (github.com/gomlx/compute).

Importing this package registers the "cuda" backend with github.com/gomlx/compute:

import _ "github.com/gomlx/compute-cuda"

Configuration options can be passed via GOMLX_BACKEND="cuda:<opt1>,<opt2>=<val>" or compute.NewWithConfig("cuda:..."). Supported options:

  • device=<N>: default CUDA device ordinal to target (default: 0).

Index

Constants

View Source
const BackendName = "cuda"

BackendName is the name registered with github.com/gomlx/compute.

Variables

This section is empty.

Functions

func New

func New(config string) (compute.Backend, error)

New constructs a new CUDA compute.Backend using the given configuration string.

Types

type Backend

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

Backend implements compute.Backend using NVIDIA's CUDA Driver API and cuBLAS in Pure Go.

func (*Backend) BufferFromFlatData

func (b *Backend) BufferFromFlatData(deviceNum compute.DeviceNum, flat any, shape shapes.Shape) (compute.Buffer, error)

BufferFromFlatData transfers host flat data into a GPU VRAM buffer.

func (*Backend) Builder

func (b *Backend) Builder(name string) compute.Builder

Builder creates a new computation builder.

func (*Backend) Capabilities

func (b *Backend) Capabilities() compute.Capabilities

Capabilities returns the operations, data types, and features supported by this backend.

func (*Backend) Description

func (b *Backend) Description() string

Description returns a human-readable description of the backend.

func (*Backend) DeviceDescription

func (b *Backend) DeviceDescription(deviceNum compute.DeviceNum) string

DeviceDescription returns a description of the given device ordinal.

func (*Backend) Finalize

func (b *Backend) Finalize()

Finalize releases all backend resources immediately and waits for in-flight operations to finish. Finalize is goroutine-safe and idempotent.

func (*Backend) HasSharedBuffers

func (b *Backend) HasSharedBuffers() bool

HasSharedBuffers returns false because discrete GPU VRAM is not directly CPU-addressable without Unified Memory page-fault overhead.

func (*Backend) IsFinalized

func (b *Backend) IsFinalized() bool

IsFinalized reports whether Finalize has been called on this backend.

func (*Backend) Name

func (b *Backend) Name() string

Name returns the short name of the backend ("cuda").

func (*Backend) NewSharedBuffer

func (b *Backend) NewSharedBuffer(deviceNum compute.DeviceNum, shape shapes.Shape) (compute.Buffer, any, error)

NewSharedBuffer is not supported by the CUDA backend.

func (*Backend) NumDevices

func (b *Backend) NumDevices() int

NumDevices returns the number of CUDA devices exposed by this backend.

func (*Backend) String

func (b *Backend) String() string

String returns the same as Name.

type Buffer

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

Buffer implements compute.Buffer backed by CUDA device VRAM.

func (*Buffer) Backend

func (buf *Buffer) Backend() compute.Backend

Backend returns the owning compute.Backend.

func (*Buffer) CopyToDevice

func (buf *Buffer) CopyToDevice(deviceNum compute.DeviceNum) (compute.Buffer, error)

CopyToDevice returns an independent deep copy of this buffer on deviceNum.

func (*Buffer) Data

func (buf *Buffer) Data() (any, error)

Data returns ErrNotImplemented because HasSharedBuffers is false.

func (*Buffer) DeviceNum

func (buf *Buffer) DeviceNum() (compute.DeviceNum, error)

DeviceNum returns the device holding this buffer.

func (*Buffer) Finalize

func (buf *Buffer) Finalize() error

Finalize releases the GPU memory owned by this buffer. Finalize is goroutine-safe, idempotent, and a safe no-op after Backend.Finalize().

func (*Buffer) Shape

func (buf *Buffer) Shape() (shapes.Shape, error)

Shape returns the buffer's shape.

func (*Buffer) ToFlatData

func (buf *Buffer) ToFlatData(flat any) error

ToFlatData transfers the GPU buffer contents into a Go flat slice matching the buffer's dtype and size.

type Builder

type Builder struct {
	notimplemented.Builder
	// contains filtered or unexported fields
}

Builder implements compute.Builder for the CUDA backend.

func (*Builder) Compile

func (b *Builder) Compile() (compute.Executable, error)

Compile validates and lowers the recorded graph (and all sub-functions/closures) into a runnable *Executable.

func (*Builder) Main

func (b *Builder) Main() compute.Function

Main returns the main function of this computation.

func (*Builder) Name

func (b *Builder) Name() string

Name returns the computation name.

func (*Builder) NewFunction

func (b *Builder) NewFunction(name string) (compute.Function, error)

NewFunction creates a new named function within this builder.

func (*Builder) OpShape

func (b *Builder) OpShape(op compute.Value) (shapes.Shape, error)

OpShape returns the shape of a computation value belonging to any function in this builder.

type Executable

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

Executable represents a compiled CUDA computation ready to run.

func (*Executable) Execute

func (e *Executable) Execute(inputs []compute.Buffer, donate []bool, defaultDevice compute.DeviceNum) ([]compute.Buffer, error)

Execute runs the compiled computation on the GPU.

func (*Executable) Finalize

func (e *Executable) Finalize()

Finalize releases resources associated with this executable. Finalize is goroutine-safe, idempotent, and safe to call after Backend.Finalize().

func (*Executable) Inputs

func (e *Executable) Inputs() ([]string, []shapes.Shape)

Inputs returns the parameter names and shapes in order of creation.

func (*Executable) Outputs

func (e *Executable) Outputs() []shapes.Shape

Outputs returns the output shapes in order passed to Function.Return.

type Function

type Function struct {
	notimplemented.Function
	// contains filtered or unexported fields
}

Function implements compute.Function for the CUDA backend.

func (*Function) Abs

func (f *Function) Abs(x compute.Value) (compute.Value, error)

func (*Function) Add

func (f *Function) Add(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) ArgMinMax

func (f *Function) ArgMinMax(x compute.Value, axis int, outputDType dtypes.DType, isMin bool) (compute.Value, error)

func (*Function) Atan2

func (f *Function) Atan2(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) BatchNormForInference

func (f *Function) BatchNormForInference(operand, scale, offset, mean, variance compute.Value, epsilon float32, featureAxis int) (compute.Value, error)

func (*Function) BatchNormForTraining

func (f *Function) BatchNormForTraining(operand, scale, offset compute.Value, epsilon float32, featureAxis int) (compute.Value, compute.Value, compute.Value, error)

func (*Function) BatchNormGradient

func (f *Function) BatchNormGradient(operand, scale, mean, variance, gradOutput compute.Value, epsilon float32, featureAxis int) (compute.Value, compute.Value, compute.Value, error)

func (*Function) BitCount

func (f *Function) BitCount(x compute.Value) (compute.Value, error)

func (*Function) Bitcast

func (f *Function) Bitcast(x compute.Value, targetDType dtypes.DType) (compute.Value, error)

func (*Function) BitwiseAnd

func (f *Function) BitwiseAnd(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) BitwiseNot

func (f *Function) BitwiseNot(x compute.Value) (compute.Value, error)

func (*Function) BitwiseOr

func (f *Function) BitwiseOr(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) BitwiseXor

func (f *Function) BitwiseXor(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) BroadcastInDim

func (f *Function) BroadcastInDim(operand compute.Value, outputShape shapes.Shape, broadcastAxes []int) (compute.Value, error)

func (*Function) Builder

func (f *Function) Builder() compute.Builder

Builder returns the owning builder.

func (*Function) Call

func (f *Function) Call(target compute.Function, inputs ...compute.Value) ([]compute.Value, error)

func (*Function) Ceil

func (f *Function) Ceil(x compute.Value) (compute.Value, error)

func (*Function) Clamp

func (f *Function) Clamp(minVal, x, maxVal compute.Value) (compute.Value, error)

func (*Function) Closure

func (f *Function) Closure() (compute.Function, error)

Closure creates a new closure function nested inside f that may capture values from ancestor scopes.

func (*Function) Clz

func (f *Function) Clz(x compute.Value) (compute.Value, error)

func (*Function) Complex

func (f *Function) Complex(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Concatenate

func (f *Function) Concatenate(axis int, operands ...compute.Value) (compute.Value, error)

func (*Function) Conj

func (f *Function) Conj(x compute.Value) (compute.Value, error)

func (*Function) Constant

func (f *Function) Constant(flat any, dims ...int) (compute.Value, error)

Constant creates a constant node backed by flat host slice data copied into the graph.

func (*Function) ConstantFromBuffer

func (f *Function) ConstantFromBuffer(buf compute.Buffer, donate bool) (compute.Value, error)

ConstantFromBuffer creates a constant node backed by an existing CUDA buffer.

func (*Function) ConvGeneral

func (f *Function) ConvGeneral(
	input, kernel compute.Value,
	axes compute.ConvolveAxesConfig,
	strides []int,
	paddings [][2]int,
	inputDilations, kernelDilations []int,
	channelGroupCount, batchGroupCount int,
) (compute.Value, error)

func (*Function) ConvertDType

func (f *Function) ConvertDType(x compute.Value, dtype dtypes.DType) (compute.Value, error)

func (*Function) Cos

func (f *Function) Cos(x compute.Value) (compute.Value, error)

func (*Function) CumMax

func (f *Function) CumMax(operand compute.Value, axis int, options compute.CumSumOptions) (compute.Value, error)

func (*Function) CumSum

func (f *Function) CumSum(operand compute.Value, axis int, options compute.CumSumOptions) (compute.Value, error)

func (*Function) Div

func (f *Function) Div(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) DotGeneral

func (f *Function) DotGeneral(
	lhs compute.Value,
	lhsContractingAxes, lhsBatchAxes []int,
	rhs compute.Value,
	rhsContractingAxes, rhsBatchAxes []int,
	config compute.DotGeneralConfig,
) (compute.Value, error)

DotGeneral records a generalized tensor contraction (batched matrix multiplication / einsum).

func (*Function) DynamicBroadcastInDim

func (f *Function) DynamicBroadcastInDim(operand compute.Value, broadcastAxes []int, dimensions ...compute.DynamicDimensionSpec) (compute.Value, error)

func (*Function) DynamicDimensionSize

func (f *Function) DynamicDimensionSize(operand compute.Value, axis int) (compute.Value, error)

func (*Function) DynamicIota

func (f *Function) DynamicIota(dtype dtypes.DType, iotaAxis int, dimensions ...compute.DynamicDimensionSpec) (compute.Value, error)

func (*Function) DynamicPad

func (f *Function) DynamicPad(x, fillValue compute.Value, axesConfig ...compute.DynamicPadAxis) (compute.Value, error)

func (*Function) DynamicReshape

func (f *Function) DynamicReshape(operand compute.Value, dimensions ...compute.DynamicDimensionSpec) (compute.Value, error)

func (*Function) DynamicShape

func (f *Function) DynamicShape(operand compute.Value) (compute.Value, error)

func (*Function) DynamicSlice

func (f *Function) DynamicSlice(operand compute.Value, startIndices []compute.Value, sliceDims []int) (compute.Value, error)

func (*Function) DynamicUpdateSlice

func (f *Function) DynamicUpdateSlice(operand, update compute.Value, startIndices []compute.Value) (compute.Value, error)

func (*Function) Equal

func (f *Function) Equal(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) EqualTotalOrder

func (f *Function) EqualTotalOrder(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Erf

func (f *Function) Erf(x compute.Value) (compute.Value, error)

func (*Function) Exp

func (f *Function) Exp(x compute.Value) (compute.Value, error)

func (*Function) Expm1

func (f *Function) Expm1(x compute.Value) (compute.Value, error)

func (*Function) Floor

func (f *Function) Floor(x compute.Value) (compute.Value, error)

func (*Function) FusedActivation

func (f *Function) FusedActivation(x compute.Value, cfg compute.ActivationConfig) (compute.Value, error)

FusedActivation applies the configured activation function (including SwiGLU).

func (*Function) FusedActivationVJP

func (f *Function) FusedActivationVJP(y, x, dOutput compute.Value, cfg compute.ActivationConfig) (compute.Value, error)

FusedActivationVJP computes the VJP of FusedActivation.

func (*Function) FusedAttentionQKVProjection

func (f *Function) FusedAttentionQKVProjection(
	x, wQKV, biasQ, biasK, biasV compute.Value,
	queryDim, keyValueDim int,
) (query, key, value compute.Value, err error)

FusedAttentionQKVProjection performs fused Q/K/V linear projection + split + optional biases.

func (*Function) FusedDense

func (f *Function) FusedDense(x, weight, bias compute.Value, options compute.DenseConfig) (compute.Value, error)

FusedDense performs fused matmul + optional bias + optional activation.

func (*Function) FusedDenseVJP

func (f *Function) FusedDenseVJP(x, weight, bias, y, dOutput compute.Value, options compute.DenseConfig) (dx, dWeight, dBias compute.Value, err error)

FusedDenseVJP computes gradients (dx, dWeight, dBias) for FusedDense.

func (*Function) FusedLayerNorm

func (f *Function) FusedLayerNorm(x compute.Value, axes []int, epsilon float64, gamma, beta compute.Value) (compute.Value, error)

FusedLayerNorm applies layer normalization over specified axes with optional gamma and beta.

func (*Function) FusedLayerNormVJP

func (f *Function) FusedLayerNormVJP(x, dOutput compute.Value, axes []int, epsilon float64, gamma, beta compute.Value) (dx, dGamma, dBeta compute.Value, err error)

FusedLayerNormVJP computes gradients (dx, dGamma, dBeta) for FusedLayerNorm.

func (*Function) FusedQuantizedDense

func (f *Function) FusedQuantizedDense(x, weight, bias compute.Value, options compute.FusedQuantizedDenseConfig) (compute.Value, error)

FusedQuantizedDense performs fused quantized matrix multiplication + optional bias + optional activation + optional output re-quantization across QuantLinear, QuantNF4, and QuantGGML.

func (*Function) FusedQuantizedDenseVJP

func (f *Function) FusedQuantizedDenseVJP(
	x, weight, bias, y, dOutput compute.Value,
	options compute.FusedQuantizedDenseConfig,
) (dx, dBias compute.Value, err error)

FusedQuantizedDenseVJP computes gradients (dx, dBias) for FusedQuantizedDense keeping quantized weights frozen.

func (*Function) FusedScaledDotProductAttention

func (f *Function) FusedScaledDotProductAttention(
	query, key, value compute.Value,
	axesLayout compute.AttentionAxesLayout,
	options *compute.ScaledDotProductAttentionConfig,
) (output compute.Value, statesForVJP []compute.Value, err error)

FusedScaledDotProductAttention computes FlashAttention-style multi-head scaled dot-product attention.

func (*Function) FusedSoftmax

func (f *Function) FusedSoftmax(x compute.Value, axis int) (compute.Value, error)

FusedSoftmax computes softmax along the specified non-negative axis.

func (*Function) FusedTopK

func (f *Function) FusedTopK(operand compute.Value, k int, cfg compute.FusedTopKConfig) (values, indices compute.Value, err error)

FusedTopK selects the k largest (or smallest) elements and their Int32 indices along cfg.Axis.

func (*Function) Gather

func (f *Function) Gather(
	operand, startIndices compute.Value,
	indexVectorAxis int,
	offsetOutputAxes, collapsedSliceAxes, startIndexMap, sliceSizes []int,
	indicesAreSorted bool,
) (compute.Value, error)

func (*Function) GreaterOrEqual

func (f *Function) GreaterOrEqual(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) GreaterOrEqualTotalOrder

func (f *Function) GreaterOrEqualTotalOrder(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) GreaterThan

func (f *Function) GreaterThan(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) GreaterThanTotalOrder

func (f *Function) GreaterThanTotalOrder(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Identity

func (f *Function) Identity(x compute.Value) (compute.Value, error)

func (*Function) If

func (f *Function) If(pred compute.Value, trueBranch, falseBranch compute.Function) ([]compute.Value, error)

func (*Function) Imag

func (f *Function) Imag(x compute.Value) (compute.Value, error)

func (*Function) Iota

func (f *Function) Iota(shape shapes.Shape, iotaAxis int) (compute.Value, error)

func (*Function) IsFinite

func (f *Function) IsFinite(x compute.Value) (compute.Value, error)

func (*Function) IsNaN

func (f *Function) IsNaN(x compute.Value) (compute.Value, error)

func (*Function) LessOrEqual

func (f *Function) LessOrEqual(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) LessOrEqualTotalOrder

func (f *Function) LessOrEqualTotalOrder(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) LessThan

func (f *Function) LessThan(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) LessThanTotalOrder

func (f *Function) LessThanTotalOrder(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Log

func (f *Function) Log(x compute.Value) (compute.Value, error)

func (*Function) Log1p

func (f *Function) Log1p(x compute.Value) (compute.Value, error)

func (*Function) LogicalAnd

func (f *Function) LogicalAnd(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) LogicalNot

func (f *Function) LogicalNot(x compute.Value) (compute.Value, error)

func (*Function) LogicalOr

func (f *Function) LogicalOr(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) LogicalXor

func (f *Function) LogicalXor(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Logistic

func (f *Function) Logistic(x compute.Value) (compute.Value, error)

func (*Function) Max

func (f *Function) Max(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Min

func (f *Function) Min(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Mul

func (f *Function) Mul(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Name

func (f *Function) Name() string

Name returns the function name ("" for closures).

func (*Function) Neg

func (f *Function) Neg(x compute.Value) (compute.Value, error)

func (*Function) NonZero

func (f *Function) NonZero(operand compute.Value, cfg compute.NonZeroConfig) (compute.Value, error)

func (*Function) NotEqual

func (f *Function) NotEqual(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) NotEqualTotalOrder

func (f *Function) NotEqualTotalOrder(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) OptimizationBarrier

func (f *Function) OptimizationBarrier(operands ...compute.Value) ([]compute.Value, error)

func (*Function) Pad

func (f *Function) Pad(x, fillValue compute.Value, axesConfig ...compute.PadAxis) (compute.Value, error)

func (*Function) Parameter

func (f *Function) Parameter(name string, shape shapes.Shape, sharding *compute.ShardingSpec) (compute.Value, error)

Parameter creates a computation input parameter (supporting both static and dynamic shapes).

func (*Function) Parent

func (f *Function) Parent() compute.Function

Parent returns the parent function for closures, or nil for top-level functions.

func (*Function) Pow

func (f *Function) Pow(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) QuantizedGather

func (f *Function) QuantizedGather(x, indices compute.Value, xQuantization *compute.Quantization) (compute.Value, error)

QuantizedGather performs quantized row gather (embedding lookup) with on-the-fly unpacking or dequantization across QuantNone, QuantLinear, QuantNF4, and all 12 QuantGGML types.

func (*Function) RNGBitGenerator

func (f *Function) RNGBitGenerator(state compute.Value, shape shapes.Shape, algorithm compute.RNGAlgorithm) (compute.Value, compute.Value, error)

func (*Function) Real

func (f *Function) Real(x compute.Value) (compute.Value, error)

func (*Function) ReduceBitwiseAnd

func (f *Function) ReduceBitwiseAnd(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceBitwiseOr

func (f *Function) ReduceBitwiseOr(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceBitwiseXor

func (f *Function) ReduceBitwiseXor(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceLogicalAnd

func (f *Function) ReduceLogicalAnd(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceLogicalOr

func (f *Function) ReduceLogicalOr(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceLogicalXor

func (f *Function) ReduceLogicalXor(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceMax

func (f *Function) ReduceMax(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceMin

func (f *Function) ReduceMin(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceProduct

func (f *Function) ReduceProduct(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceSum

func (f *Function) ReduceSum(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) ReduceWindow

func (f *Function) ReduceWindow(
	input compute.Value,
	reductionType compute.ReduceOpType,
	windowDimensions, strides, inputDilations, windowDilations []int,
	paddings [][2]int,
) (compute.Value, error)

func (*Function) Rem

func (f *Function) Rem(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Reshape

func (f *Function) Reshape(x compute.Value, dimensions ...int) (compute.Value, error)

func (*Function) Return

func (f *Function) Return(outputs []compute.Value, shardings []*compute.ShardingSpec) error

Return marks the outputs of this function.

func (*Function) Reverse

func (f *Function) Reverse(x compute.Value, axes ...int) (compute.Value, error)

func (*Function) Round

func (f *Function) Round(x compute.Value) (compute.Value, error)

func (*Function) Rsqrt

func (f *Function) Rsqrt(x compute.Value) (compute.Value, error)

func (*Function) ScatterMax

func (f *Function) ScatterMax(operand, scatterIndices, updates compute.Value, indexVectorAxis int, updateWindowAxes, insertedWindowAxes, scatterAxesToOperandAxes []int, indicesAreSorted, uniqueIndices bool) (compute.Value, error)

func (*Function) ScatterMin

func (f *Function) ScatterMin(operand, scatterIndices, updates compute.Value, indexVectorAxis int, updateWindowAxes, insertedWindowAxes, scatterAxesToOperandAxes []int, indicesAreSorted, uniqueIndices bool) (compute.Value, error)

func (*Function) ScatterSum

func (f *Function) ScatterSum(operand, scatterIndices, updates compute.Value, indexVectorAxis int, updateWindowAxes, insertedWindowAxes, scatterAxesToOperandAxes []int, indicesAreSorted, uniqueIndices bool) (compute.Value, error)

func (*Function) SchedulingBarrier

func (f *Function) SchedulingBarrier(operand compute.Value, dependencies ...compute.Value) (compute.Value, error)

func (*Function) SelectAndScatterMax

func (f *Function) SelectAndScatterMax(operand, source compute.Value, windowDimensions, windowStrides []int, paddings [][2]int) (compute.Value, error)

func (*Function) SelectAndScatterMin

func (f *Function) SelectAndScatterMin(operand, source compute.Value, windowDimensions, windowStrides []int, paddings [][2]int) (compute.Value, error)

func (*Function) Shape

func (f *Function) Shape(v compute.Value) (shapes.Shape, error)

Shape returns the inferred shape of value v.

func (*Function) ShiftLeft

func (f *Function) ShiftLeft(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) ShiftRightArithmetic

func (f *Function) ShiftRightArithmetic(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) ShiftRightLogical

func (f *Function) ShiftRightLogical(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Sign

func (f *Function) Sign(x compute.Value) (compute.Value, error)

func (*Function) Sin

func (f *Function) Sin(x compute.Value) (compute.Value, error)

func (*Function) Slice

func (f *Function) Slice(x compute.Value, starts, limits, strides []int) (compute.Value, error)

func (*Function) Sort

func (f *Function) Sort(comparator compute.Function, axis int, isStable bool, inputs ...compute.Value) ([]compute.Value, error)

func (*Function) Sqrt

func (f *Function) Sqrt(x compute.Value) (compute.Value, error)

func (*Function) Sub

func (f *Function) Sub(lhs, rhs compute.Value) (compute.Value, error)

func (*Function) Tanh

func (f *Function) Tanh(x compute.Value) (compute.Value, error)

func (*Function) Transpose

func (f *Function) Transpose(x compute.Value, permutation ...int) (compute.Value, error)

func (*Function) Where

func (f *Function) Where(condition, onTrue, onFalse compute.Value) (compute.Value, error)

func (*Function) While

func (f *Function) While(cond, body compute.Function, initialState ...compute.Value) ([]compute.Value, error)

Directories

Path Synopsis
internal
arena
Package arena provides pooled, zero-allocation scratch storage for low-latency CUDA Driver API and cuBLAS calls (such as cuLaunchKernel kernelParams arrays and scalar argument buffers).
Package arena provides pooled, zero-allocation scratch storage for low-latency CUDA Driver API and cuBLAS calls (such as cuLaunchKernel kernelParams arrays and scalar argument buffers).
cublas
Package cublas provides Pure-Go (CGO_ENABLED=0) dynamic bindings to NVIDIA's cuBLAS library (libcublas.so.13 / libcublas.so.12 / libcublas.so) built on top of internal/dynlib.
Package cublas provides Pure-Go (CGO_ENABLED=0) dynamic bindings to NVIDIA's cuBLAS library (libcublas.so.13 / libcublas.so.12 / libcublas.so) built on top of internal/dynlib.
driver
Package driver provides Pure-Go bindings to NVIDIA's CUDA Driver API (libcuda.so.1 / nvcuda.dll) loaded dynamically via internal/dynlib.
Package driver provides Pure-Go bindings to NVIDIA's CUDA Driver API (libcuda.so.1 / nvcuda.dll) loaded dynamically via internal/dynlib.
dynlib
Package dynlib isolates all Pure-Go dynamic shared library loading (currently backed by github.com/ebitengine/purego) behind a minimal internal API.
Package dynlib isolates all Pure-Go dynamic shared library loading (currently backed by github.com/ebitengine/purego) behind a minimal internal API.
pool
Package pool implements a lock-free per-P object pool modeled after go-xla/internal/pool, providing very low-latency object reuse for hot-path CUDA Driver API / cuBLAS calls.
Package pool implements a lock-free per-P object pool modeled after go-xla/internal/pool, providing very low-latency object reuse for hot-path CUDA Driver API / cuBLAS calls.
ptx
Package ptx manages embedded precompiled CUDA PTX/fatbin modules and caches loaded CUmodule / CUfunction handles per CUDA DeviceContext.
Package ptx manages embedded precompiled CUDA PTX/fatbin modules and caches loaded CUmodule / CUfunction handles per CUDA DeviceContext.

Jump to

Keyboard shortcuts

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