ggml

package
v0.28.21 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 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 ggml provides graph-level decomposed dequantization for GGML block formats.

These functions express GGML dequantization (Q4_0, Q8_0, IQ4_NL) as standard graph primitives (Bitcast, BitwiseAnd, ShiftRightLogical, Slice, ConvertDType, etc.) so that any backend — including XLA for GPU — can execute them. The simplego backend uses faster fused SIMD implementations when available; these decomposed versions serve as the automatic fallback via InternalFusedOpCaller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanDecompose

func CanDecompose(t compute.GGMLQuantType) bool

CanDecompose returns true for GGML quantization types that have a graph-level decomposed implementation (Q4_0, Q8_0, IQ4_NL).

func DenseDecomposed

func DenseDecomposed(x, weights *Node, ggmlType compute.GGMLQuantType,
	bias *Node, optionalActivation ...activation.Type) *Node

DenseDecomposed performs quantized dense (linear) transformation using graph-level dequantization of GGML block-format weights.

It computes y = activation(x @ dequant(weights) + bias).

Parameters:

  • x: [batch..., K] Float32 input activations.
  • weights: [N, bytesPerRow] Uint8 in native GGML block layout.
  • ggmlType: the GGML block format (Q4_0, Q8_0, IQ4_NL).
  • bias: [N] Float32 (nil for no bias).
  • activation: optional activation function.

func Dequantize

func Dequantize(weights *Node, ggmlType compute.GGMLQuantType, N int) *Node

Dequantize dequantizes GGML block-format weights to [N, K] Float32 using graph primitives.

weights is shaped [N, numBlocks * bytesPerBlock] Uint8 in native GGML block layout, where N is the number of output rows (output features for dense, vocab size for embedding lookup). K is the logical feature dimension: K = numBlocks * valuesPerBlock, and is fixed per quantization type (e.g. Q4_0 has 32 values per 18-byte block).

N is passed explicitly rather than inferred from weights.Shape() because the caller may have reshaped gathered rows into [totalRows, bytesPerRow] where totalRows differs from the original table's first dimension.

func EmbeddingLookupDecomposed

func EmbeddingLookupDecomposed(table, indices *Node, ggmlType compute.GGMLQuantType) *Node

EmbeddingLookupDecomposed performs a quantized embedding lookup using graph-level dequantization.

It gathers raw Uint8 rows from the quantized table, then dequantizes only the selected rows to Float32.

Parameters:

  • table: [vocabSize, bytesPerRow] Uint8 with native GGML block layout.
  • indices: integer tensor with last dimension = 1 (Gather convention).
  • ggmlType: the GGML block format (Q4_0, Q8_0, IQ4_NL).

Output: Float32 tensor with shape [batch..., K] where K is the logical embedding dimension.

Types

This section is empty.

Jump to

Keyboard shortcuts

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