zframes

package
v2.0.0-beta.16 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 7 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 zframes stores a file as independent zstd frames, each of Size bytes of it but the last, so that a reader fetches and decodes the frames in parallel: the form a snapshot's process images and weights take on network storage, where every byte read costs and one decoding stream would not keep up with fast storage.

A frame may hold its bytes split into planes: with split 2, the bytes at even offsets and then those at odd ones. BF16 weights keep their sign and exponent in the high byte, which compresses to about a third, and their mantissa in the low one, which does not compress at all: split, a 16-bit tensor takes 0.69 of its size, where zstd alone gets 0.78.

Index

Constants

View Source
const Size = 32 << 20

Size is how many bytes of the file one frame holds.

Variables

This section is empty.

Functions

func DecodeFile

func DecodeFile(ctx context.Context, src string, ends []int64, size int64, split int, w io.Writer) error

DecodeFile writes the file of size bytes that src stores as frames (ends from Encode, stored with split) to w, frame by frame.

func Encode

func Encode(ctx context.Context, src, dst string, workers, split int) ([]int64, int, error)

Encode writes src to dst as frames, workers at a time, and returns each frame's end offset in dst and the split it used: split, or with 0 the one of 1 and 2 that compresses the first frame best.

func Frame

func Frame(ends []int64, size int64, i int) (stored, storedSize, offset, n int64)

Frame is where frame i of a file of size bytes lies, in the stored file (ends from Encode) and in the file itself.

Types

type Decoder

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

Decoder decodes one frame at a time; one per goroutine.

func NewDecoder

func NewDecoder() (*Decoder, error)

NewDecoder makes a Decoder.

func (*Decoder) Close

func (d *Decoder) Close()

Close frees the decoder.

func (*Decoder) Decode

func (d *Decoder) Decode(frame, out []byte, want int64, split int) ([]byte, error)

Decode decodes frame, stored with split, and checks it holds want bytes. The bytes are in out, or the decoder's own buffer: valid until the next Decode.

Jump to

Keyboard shortcuts

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