jaccl

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 15 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.

Documentation

Overview

Package jaccl implements RDMA collective communication in Go.

It uses the Apple RDMA bindings directly. It does not call libjaccl or use cgo. The initial implementation targets Apple Thunderbolt RDMA on darwin/ arm64; unsupported platforms return ErrUnsupported.

Index

Constants

View Source
const Uint8 = UInt8

Uint8 is kept as the spelling used by the first Go API.

Variables

View Source
var (
	// ErrUnsupported reports that the local platform or RDMA provider is not supported.
	ErrUnsupported = errors.New("jaccl: unsupported")

	// ErrInvalidConfig reports an invalid group configuration.
	ErrInvalidConfig = errors.New("jaccl: invalid config")

	// ErrProtocol reports an invalid or mismatched peer protocol message.
	ErrProtocol = errors.New("jaccl: protocol error")

	// ErrClosed reports use of a closing or closed group.
	ErrClosed = errors.New("jaccl: group closed")

	// ErrPoisoned reports a group made unsafe by a transport failure.
	ErrPoisoned = errors.New("jaccl: group poisoned")
)

Functions

func Available

func Available() bool

Available reports whether the native JACCL transport is available.

Types

type Config

type Config struct {
	Rank        int
	Size        int
	GroupID     string
	Coordinator string
	Device      string
	// Devices is the upstream JACCL directed connectivity matrix. Each cell
	// names zero or more RDMA devices for one source-to-destination link.
	Devices [][][]string
	// PreferRing asks ConfigFromEnv to choose a valid ring before a mesh.
	PreferRing bool
	Port       uint8
	Topology   Topology
}

Config describes one rank in a group.

func ConfigFromEnv

func ConfigFromEnv() (Config, error)

ConfigFromEnv reads the standalone JACCL configuration variables. It accepts JACCL_* names first, then the MLX_* aliases used by the upstream library.

The returned Config retains the full device matrix for parity tooling. The native backend uses the matrix during setup: a mesh selects its first directed device and a ring retains each directed wire.

type DType

type DType uint8

DType is an element representation used by AllReduce. Its values match the standalone JACCL Dtype enum so an external parity fixture can use the same type table in both implementations.

const (
	// Bool is a boolean element.
	Bool DType = iota
	// Int8 is a signed 8-bit integer element.
	Int8
	// Int16 is a signed 16-bit integer element.
	Int16
	// Int32 is a signed 32-bit integer element.
	Int32
	// Int64 is a signed 64-bit integer element.
	Int64
	// UInt8 is an unsigned 8-bit integer element.
	UInt8
	// UInt16 is an unsigned 16-bit integer element.
	UInt16
	// UInt32 is an unsigned 32-bit integer element.
	UInt32
	// UInt64 is an unsigned 64-bit integer element.
	UInt64
	// Float16 is an IEEE 754 binary16 element.
	Float16
	// BFloat16 is a bfloat16 element.
	BFloat16
	// Float32 is an IEEE 754 binary32 element.
	Float32
	// Float64 is an IEEE 754 binary64 element.
	Float64
	// Complex64 is a pair of IEEE 754 binary32 values.
	Complex64
)

func (DType) Size

func (d DType) Size() (int, error)

Size reports the number of bytes in one value of d.

type Group

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

Group is a live RDMA communicator.

func Open

func Open(ctx context.Context, cfg Config) (*Group, error)

Open validates cfg and opens an RDMA group.

func OpenEnv

func OpenEnv(ctx context.Context) (*Group, error)

OpenEnv reads a standalone JACCL-compatible environment configuration and opens the resulting group.

func (*Group) AllGather

func (g *Group) AllGather(ctx context.Context, dst, src []byte) error

AllGather gathers src from every rank into rank-major dst.

func (*Group) AllMax

func (g *Group) AllMax(ctx context.Context, dst, src []byte, dtype DType) error

AllMax reduces src into dst using the greater value.

func (*Group) AllMin

func (g *Group) AllMin(ctx context.Context, dst, src []byte, dtype DType) error

AllMin reduces src into dst using the lesser value.

func (*Group) AllReduce

func (g *Group) AllReduce(ctx context.Context, dst, src []byte, dtype DType, op ReduceOp) error

AllReduce reduces src into dst.

func (*Group) AllSum

func (g *Group) AllSum(ctx context.Context, dst, src []byte, dtype DType) error

AllSum reduces src into dst using addition.

func (*Group) Barrier

func (g *Group) Barrier(ctx context.Context) error

Barrier waits until every rank enters the barrier.

func (*Group) Close

func (g *Group) Close() error

Close releases the group's resources. It is safe to call more than once.

func (*Group) Rank

func (g *Group) Rank() int

Rank reports the local rank.

func (*Group) Recv

func (g *Group) Recv(ctx context.Context, src int, dst []byte) error

Recv transfers bytes from src into dst.

func (*Group) RegisterBuffer

func (g *Group) RegisterBuffer(buf []byte) error

RegisterBuffer pre-registers a page-aligned buffer (e.g. mmap or Metal unified-memory slab) across all RDMA links in the group so subsequent collectives can use zero-copy direct MRs without hot-path ibv_reg_mr skew. Apple's RDMA provider registers only memory below 1 TiB, so a buffer from the Go heap cannot be registered; collectives on it use staging copies. Shared Metal buffers (macOS 27.2) land below 1 TiB and register. Buffers smaller than 64 KiB, or whose start or length is not a multiple of the page size, are not registered and RegisterBuffer returns nil. Callers should synchronize peers (e.g. Barrier) after registration and call UnregisterBuffer before freeing or unmapping buf.

func (*Group) Send

func (g *Group) Send(ctx context.Context, dst int, src []byte) error

Send transfers src to dst.

func (*Group) Size

func (g *Group) Size() int

Size reports the number of ranks in the group.

func (*Group) UnregisterBuffer

func (g *Group) UnregisterBuffer(buf []byte) error

UnregisterBuffer deregisters a buffer previously registered with RegisterBuffer.

type ReduceOp

type ReduceOp uint8

ReduceOp selects the reduction performed by AllReduce.

const (
	// Sum adds corresponding elements.
	Sum ReduceOp = iota + 1
	// Min selects the smaller corresponding element.
	Min
	// Max selects the larger corresponding element.
	Max
)

type Topology

type Topology interface {
	Peers(rank int) []int
}

Topology reports the directly connected peers for a rank.

Peers must return no duplicate, self, or out-of-range ranks. Open validates both the local report and reciprocal reports exchanged with peers.

func Mesh

func Mesh(size int) Topology

Mesh returns a topology in which every rank connects directly to every other rank.

func Ring

func Ring(size int) Topology

Ring returns a topology in which each rank connects to its two neighbors. A two-rank ring has one peer per rank.

Jump to

Keyboard shortcuts

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