zmf

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 6

README

This repository is archived. ZMF (Zerfoo Model Format) has been replaced by GGUF as the sole model format in the Zerfoo ecosystem. GGUF provides mmap-friendly zero-copy loading, community-standard compatibility (llama.cpp, Ollama), and eliminates the 2x memory overhead of protobuf deserialization. See ADR-037 for the full decision record.

For model conversion, use zonnx which now outputs GGUF directly.

zmf

Zerfoo Model Format

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Tensor_DataType_name = map[int32]string{
		0:  "BFLOAT16",
		1:  "BOOL",
		2:  "FLOAT16",
		3:  "FLOAT32",
		4:  "FLOAT64",
		5:  "FLOAT8",
		6:  "INT16",
		7:  "INT32",
		8:  "INT64",
		9:  "INT8",
		10: "STRING",
		11: "UINT32",
		12: "UINT64",
		13: "UINT8",
		14: "Q4_0",
		15: "Q8_0",
	}
	Tensor_DataType_value = map[string]int32{
		"BFLOAT16": 0,
		"BOOL":     1,
		"FLOAT16":  2,
		"FLOAT32":  3,
		"FLOAT64":  4,
		"FLOAT8":   5,
		"INT16":    6,
		"INT32":    7,
		"INT64":    8,
		"INT8":     9,
		"STRING":   10,
		"UINT32":   11,
		"UINT64":   12,
		"UINT8":    13,
		"Q4_0":     14,
		"Q8_0":     15,
	}
)

Enum value maps for Tensor_DataType.

View Source
var File_zerfoo_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Attribute

type Attribute struct {

	// Types that are valid to be assigned to Value:
	//
	//	*Attribute_F
	//	*Attribute_I
	//	*Attribute_S
	//	*Attribute_Floats
	//	*Attribute_Ints
	//	*Attribute_Strings
	//	*Attribute_B
	//	*Attribute_Tensor
	Value isAttribute_Value `protobuf_oneof:"value"`
	// contains filtered or unexported fields
}

Attribute represents a named parameter for a node.

func (*Attribute) Descriptor deprecated

func (*Attribute) Descriptor() ([]byte, []int)

Deprecated: Use Attribute.ProtoReflect.Descriptor instead.

func (*Attribute) GetB added in v0.2.0

func (x *Attribute) GetB() bool

func (*Attribute) GetF

func (x *Attribute) GetF() float32

func (*Attribute) GetFloats

func (x *Attribute) GetFloats() *Floats

func (*Attribute) GetI

func (x *Attribute) GetI() int64

func (*Attribute) GetInts

func (x *Attribute) GetInts() *Ints

func (*Attribute) GetS

func (x *Attribute) GetS() string

func (*Attribute) GetStrings

func (x *Attribute) GetStrings() *Strings

func (*Attribute) GetTensor added in v0.3.0

func (x *Attribute) GetTensor() *Tensor

func (*Attribute) GetValue

func (x *Attribute) GetValue() isAttribute_Value

func (*Attribute) ProtoMessage

func (*Attribute) ProtoMessage()

func (*Attribute) ProtoReflect

func (x *Attribute) ProtoReflect() protoreflect.Message

func (*Attribute) Reset

func (x *Attribute) Reset()

func (*Attribute) String

func (x *Attribute) String() string

type Attribute_B added in v0.2.0

type Attribute_B struct {
	B bool `protobuf:"varint,7,opt,name=b,proto3,oneof"` // Added boolean support
}

type Attribute_F

type Attribute_F struct {
	F float32 `protobuf:"fixed32,1,opt,name=f,proto3,oneof"`
}

type Attribute_Floats

type Attribute_Floats struct {
	Floats *Floats `protobuf:"bytes,4,opt,name=floats,proto3,oneof"`
}

type Attribute_I

type Attribute_I struct {
	I int64 `protobuf:"varint,2,opt,name=i,proto3,oneof"`
}

type Attribute_Ints

type Attribute_Ints struct {
	Ints *Ints `protobuf:"bytes,5,opt,name=ints,proto3,oneof"`
}

type Attribute_S

type Attribute_S struct {
	S string `protobuf:"bytes,3,opt,name=s,proto3,oneof"`
}

type Attribute_Strings

type Attribute_Strings struct {
	Strings *Strings `protobuf:"bytes,6,opt,name=strings,proto3,oneof"`
}

type Attribute_Tensor added in v0.3.0

type Attribute_Tensor struct {
	Tensor *Tensor `protobuf:"bytes,8,opt,name=tensor,proto3,oneof"` // Added tensor support for constants
}

type Floats

type Floats struct {
	Val []float32 `protobuf:"fixed32,1,rep,packed,name=val,proto3" json:"val,omitempty"`
	// contains filtered or unexported fields
}

Floats is a wrapper for repeated float values in attributes.

func (*Floats) Descriptor deprecated

func (*Floats) Descriptor() ([]byte, []int)

Deprecated: Use Floats.ProtoReflect.Descriptor instead.

func (*Floats) GetVal

func (x *Floats) GetVal() []float32

func (*Floats) ProtoMessage

func (*Floats) ProtoMessage()

func (*Floats) ProtoReflect

func (x *Floats) ProtoReflect() protoreflect.Message

func (*Floats) Reset

func (x *Floats) Reset()

func (*Floats) String

func (x *Floats) String() string

type Graph

type Graph struct {

	// A map of all trainable parameters (weights, biases) in the model.
	// The key is a unique name for the parameter, e.g., "layers.0.attention.wq.weight".
	Parameters map[string]*Tensor `` /* 147-byte string literal not displayed */
	// A list of all nodes (layers or operations) in the graph.
	// For sequential models, this list should be in execution order.
	Nodes []*Node `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty"`
	// A list describing the input tensors to the graph.
	Inputs []*ValueInfo `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"`
	// A list describing the output tensors of the graph.
	Outputs []*ValueInfo `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"`
	// contains filtered or unexported fields
}

Graph represents the computation graph of the model.

func (*Graph) Descriptor deprecated

func (*Graph) Descriptor() ([]byte, []int)

Deprecated: Use Graph.ProtoReflect.Descriptor instead.

func (*Graph) GetInputs

func (x *Graph) GetInputs() []*ValueInfo

func (*Graph) GetNodes

func (x *Graph) GetNodes() []*Node

func (*Graph) GetOutputs

func (x *Graph) GetOutputs() []*ValueInfo

func (*Graph) GetParameters

func (x *Graph) GetParameters() map[string]*Tensor

func (*Graph) ProtoMessage

func (*Graph) ProtoMessage()

func (*Graph) ProtoReflect

func (x *Graph) ProtoReflect() protoreflect.Message

func (*Graph) Reset

func (x *Graph) Reset()

func (*Graph) String

func (x *Graph) String() string

type Ints

type Ints struct {
	Val []int64 `protobuf:"varint,1,rep,packed,name=val,proto3" json:"val,omitempty"`
	// contains filtered or unexported fields
}

Ints is a wrapper for repeated int64 values in attributes.

func (*Ints) Descriptor deprecated

func (*Ints) Descriptor() ([]byte, []int)

Deprecated: Use Ints.ProtoReflect.Descriptor instead.

func (*Ints) GetVal

func (x *Ints) GetVal() []int64

func (*Ints) ProtoMessage

func (*Ints) ProtoMessage()

func (*Ints) ProtoReflect

func (x *Ints) ProtoReflect() protoreflect.Message

func (*Ints) Reset

func (x *Ints) Reset()

func (*Ints) String

func (x *Ints) String() string

type Metadata

type Metadata struct {

	// The name of the tool or framework that produced this model.
	ProducerName string `protobuf:"bytes,1,opt,name=producer_name,json=producerName,proto3" json:"producer_name,omitempty"`
	// The version of the producer.
	ProducerVersion string `protobuf:"bytes,2,opt,name=producer_version,json=producerVersion,proto3" json:"producer_version,omitempty"`
	// The version of the ZMF operator set this model conforms to.
	OpsetVersion int64 `protobuf:"varint,3,opt,name=opset_version,json=opsetVersion,proto3" json:"opset_version,omitempty"`
	// contains filtered or unexported fields
}

Metadata stores information about the model's origin and versioning.

func (*Metadata) Descriptor deprecated

func (*Metadata) Descriptor() ([]byte, []int)

Deprecated: Use Metadata.ProtoReflect.Descriptor instead.

func (*Metadata) GetOpsetVersion

func (x *Metadata) GetOpsetVersion() int64

func (*Metadata) GetProducerName

func (x *Metadata) GetProducerName() string

func (*Metadata) GetProducerVersion

func (x *Metadata) GetProducerVersion() string

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) ProtoReflect

func (x *Metadata) ProtoReflect() protoreflect.Message

func (*Metadata) Reset

func (x *Metadata) Reset()

func (*Metadata) String

func (x *Metadata) String() string

type Model

type Model struct {

	// The computation graph defining the model's architecture.
	Graph *Graph `protobuf:"bytes,1,opt,name=graph,proto3" json:"graph,omitempty"`
	// Metadata about the model, such as its producer.
	Metadata *Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Version of the ZMF format itself.
	ZmfVersion string `protobuf:"bytes,3,opt,name=zmf_version,json=zmfVersion,proto3" json:"zmf_version,omitempty"`
	// contains filtered or unexported fields
}

Model is the top-level container for a serialized Zerfoo model.

func (*Model) Descriptor deprecated

func (*Model) Descriptor() ([]byte, []int)

Deprecated: Use Model.ProtoReflect.Descriptor instead.

func (*Model) GetGraph

func (x *Model) GetGraph() *Graph

func (*Model) GetMetadata

func (x *Model) GetMetadata() *Metadata

func (*Model) GetZmfVersion added in v0.2.0

func (x *Model) GetZmfVersion() string

func (*Model) ProtoMessage

func (*Model) ProtoMessage()

func (*Model) ProtoReflect

func (x *Model) ProtoReflect() protoreflect.Message

func (*Model) Reset

func (x *Model) Reset()

func (*Model) String

func (x *Model) String() string

type Node

type Node struct {

	// A unique name for this node, e.g., "transformer_block_0".
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The type of operation this node performs, e.g., "RMSNorm", "GlobalAttention".
	// This must map to a registered constructor in the importer.
	OpType string `protobuf:"bytes,2,opt,name=op_type,json=opType,proto3" json:"op_type,omitempty"`
	// A list of names of the tensors that are inputs to this node.
	// These can be names of parameters or outputs of other nodes.
	Inputs []string `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"`
	// A list of names for the output tensors of this node.
	Outputs []string `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"`
	// A map of attributes for this node, for values that are not tensors.
	// e.g., "epsilon" for RMSNorm, "hidden_dim" for FFN.
	Attributes map[string]*Attribute `` /* 147-byte string literal not displayed */
	// Common attributes for explicitness
	Epsilon *float32 `protobuf:"fixed32,6,opt,name=epsilon,proto3,oneof" json:"epsilon,omitempty"` // Used in normalization layers
	Perm    []int64  `protobuf:"varint,7,rep,packed,name=perm,proto3" json:"perm,omitempty"`       // Used in transpose operations
	Axis    *int64   `protobuf:"varint,8,opt,name=axis,proto3,oneof" json:"axis,omitempty"`        // Used in reduction operations
	// contains filtered or unexported fields
}

Node represents a single layer or operation in the computation graph.

func (*Node) Descriptor deprecated

func (*Node) Descriptor() ([]byte, []int)

Deprecated: Use Node.ProtoReflect.Descriptor instead.

func (*Node) GetAttributes

func (x *Node) GetAttributes() map[string]*Attribute

func (*Node) GetAxis added in v0.2.0

func (x *Node) GetAxis() int64

func (*Node) GetEpsilon added in v0.2.0

func (x *Node) GetEpsilon() float32

func (*Node) GetInputs

func (x *Node) GetInputs() []string

func (*Node) GetName

func (x *Node) GetName() string

func (*Node) GetOpType

func (x *Node) GetOpType() string

func (*Node) GetOutputs

func (x *Node) GetOutputs() []string

func (*Node) GetPerm added in v0.2.0

func (x *Node) GetPerm() []int64

func (*Node) ProtoMessage

func (*Node) ProtoMessage()

func (*Node) ProtoReflect

func (x *Node) ProtoReflect() protoreflect.Message

func (*Node) Reset

func (x *Node) Reset()

func (*Node) String

func (x *Node) String() string

type Quantization added in v0.2.0

type Quantization struct {

	// The scale factor for quantization.
	Scale float32 `protobuf:"fixed32,1,opt,name=scale,proto3" json:"scale,omitempty"`
	// The zero point for quantization.
	ZeroPoint int64 `protobuf:"varint,2,opt,name=zero_point,json=zeroPoint,proto3" json:"zero_point,omitempty"`
	// The minimum value of the quantized range.
	QMin *int64 `protobuf:"varint,3,opt,name=q_min,json=qMin,proto3,oneof" json:"q_min,omitempty"`
	// The maximum value of the quantized range.
	QMax *int64 `protobuf:"varint,4,opt,name=q_max,json=qMax,proto3,oneof" json:"q_max,omitempty"`
	// contains filtered or unexported fields
}

Quantization describes the parameters for affine quantization.

func (*Quantization) Descriptor deprecated added in v0.2.0

func (*Quantization) Descriptor() ([]byte, []int)

Deprecated: Use Quantization.ProtoReflect.Descriptor instead.

func (*Quantization) GetQMax added in v0.2.0

func (x *Quantization) GetQMax() int64

func (*Quantization) GetQMin added in v0.2.0

func (x *Quantization) GetQMin() int64

func (*Quantization) GetScale added in v0.2.0

func (x *Quantization) GetScale() float32

func (*Quantization) GetZeroPoint added in v0.2.0

func (x *Quantization) GetZeroPoint() int64

func (*Quantization) ProtoMessage added in v0.2.0

func (*Quantization) ProtoMessage()

func (*Quantization) ProtoReflect added in v0.2.0

func (x *Quantization) ProtoReflect() protoreflect.Message

func (*Quantization) Reset added in v0.2.0

func (x *Quantization) Reset()

func (*Quantization) String added in v0.2.0

func (x *Quantization) String() string

type Strings

type Strings struct {
	Val []string `protobuf:"bytes,1,rep,name=val,proto3" json:"val,omitempty"`
	// contains filtered or unexported fields
}

Strings is a wrapper for repeated string values in attributes.

func (*Strings) Descriptor deprecated

func (*Strings) Descriptor() ([]byte, []int)

Deprecated: Use Strings.ProtoReflect.Descriptor instead.

func (*Strings) GetVal

func (x *Strings) GetVal() []string

func (*Strings) ProtoMessage

func (*Strings) ProtoMessage()

func (*Strings) ProtoReflect

func (x *Strings) ProtoReflect() protoreflect.Message

func (*Strings) Reset

func (x *Strings) Reset()

func (*Strings) String

func (x *Strings) String() string

type Tensor

type Tensor struct {
	Dtype Tensor_DataType `protobuf:"varint,1,opt,name=dtype,proto3,enum=zmf.Tensor_DataType" json:"dtype,omitempty"`
	// The shape (dimensions) of the tensor.
	Shape []int64 `protobuf:"varint,2,rep,packed,name=shape,proto3" json:"shape,omitempty"`
	// The raw tensor data, stored as bytes.
	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// Optional quantization parameters for the tensor.
	Quant *Quantization `protobuf:"bytes,4,opt,name=quant,proto3,oneof" json:"quant,omitempty"`
	// contains filtered or unexported fields
}

Tensor represents a multi-dimensional array of data (e.g., a weight matrix).

func (*Tensor) Descriptor deprecated

func (*Tensor) Descriptor() ([]byte, []int)

Deprecated: Use Tensor.ProtoReflect.Descriptor instead.

func (*Tensor) GetData

func (x *Tensor) GetData() []byte

func (*Tensor) GetDtype

func (x *Tensor) GetDtype() Tensor_DataType

func (*Tensor) GetQuant added in v0.2.0

func (x *Tensor) GetQuant() *Quantization

func (*Tensor) GetShape

func (x *Tensor) GetShape() []int64

func (*Tensor) ProtoMessage

func (*Tensor) ProtoMessage()

func (*Tensor) ProtoReflect

func (x *Tensor) ProtoReflect() protoreflect.Message

func (*Tensor) Reset

func (x *Tensor) Reset()

func (*Tensor) String

func (x *Tensor) String() string

type Tensor_DataType

type Tensor_DataType int32

The data type of the tensor elements.

const (
	Tensor_BFLOAT16 Tensor_DataType = 0
	Tensor_BOOL     Tensor_DataType = 1
	Tensor_FLOAT16  Tensor_DataType = 2
	Tensor_FLOAT32  Tensor_DataType = 3
	Tensor_FLOAT64  Tensor_DataType = 4
	Tensor_FLOAT8   Tensor_DataType = 5
	Tensor_INT16    Tensor_DataType = 6
	Tensor_INT32    Tensor_DataType = 7
	Tensor_INT64    Tensor_DataType = 8
	Tensor_INT8     Tensor_DataType = 9
	Tensor_STRING   Tensor_DataType = 10
	Tensor_UINT32   Tensor_DataType = 11
	Tensor_UINT64   Tensor_DataType = 12
	Tensor_UINT8    Tensor_DataType = 13
	Tensor_Q4_0     Tensor_DataType = 14
	Tensor_Q8_0     Tensor_DataType = 15
)

func (Tensor_DataType) Descriptor

func (Tensor_DataType) Enum

func (x Tensor_DataType) Enum() *Tensor_DataType

func (Tensor_DataType) EnumDescriptor deprecated

func (Tensor_DataType) EnumDescriptor() ([]byte, []int)

Deprecated: Use Tensor_DataType.Descriptor instead.

func (Tensor_DataType) Number

func (Tensor_DataType) String

func (x Tensor_DataType) String() string

func (Tensor_DataType) Type

type ValueInfo

type ValueInfo struct {

	// The name of the tensor.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The data type of the tensor.
	Dtype Tensor_DataType `protobuf:"varint,2,opt,name=dtype,proto3,enum=zmf.Tensor_DataType" json:"dtype,omitempty"`
	// The shape of the tensor. A value of -1 can be used for dynamic dimensions.
	Shape []int64 `protobuf:"varint,3,rep,packed,name=shape,proto3" json:"shape,omitempty"`
	// contains filtered or unexported fields
}

ValueInfo describes a tensor, including its name, type, and shape.

func (*ValueInfo) Descriptor deprecated

func (*ValueInfo) Descriptor() ([]byte, []int)

Deprecated: Use ValueInfo.ProtoReflect.Descriptor instead.

func (*ValueInfo) GetDtype

func (x *ValueInfo) GetDtype() Tensor_DataType

func (*ValueInfo) GetName

func (x *ValueInfo) GetName() string

func (*ValueInfo) GetShape

func (x *ValueInfo) GetShape() []int64

func (*ValueInfo) ProtoMessage

func (*ValueInfo) ProtoMessage()

func (*ValueInfo) ProtoReflect

func (x *ValueInfo) ProtoReflect() protoreflect.Message

func (*ValueInfo) Reset

func (x *ValueInfo) Reset()

func (*ValueInfo) String

func (x *ValueInfo) String() string

Jump to

Keyboard shortcuts

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