jaccl

package
v0.6.21 Latest Latest
Warning

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

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

Thread QoS on darwin/arm64

On darwin/arm64, after the first collective on an OS thread, jaccl raises that OS thread's QoS class to UserInteractive and leaves it there so subsequent collectives avoid per-operation QoS syscalls and P-core demotion. Because pthread QoS is an OS-thread attribute, other goroutines later scheduled on that OS thread inherit UserInteractive QoS.

Configure thread QoS per group with Config.WireQoS (WireQoSSticky, WireQoSPerOp, or WireQoSNone). Leaving Config.WireQoS at its zero value (WireQoSDefault) defers to the JACCL_WIRE_QOS environment variable ("sticky", "per_op", or "none") and defaults to WireQoSSticky.

Index

Constants

View Source
const DefaultOpTimeout = 10 * time.Second

DefaultOpTimeout is the built-in wire-stall (no-progress) timeout applied to RDMA operations when the caller's context has no deadline and Config.OpTimeout is zero. It bounds wire stalls after both ranks have entered the operation (resetting on each completion), NOT peer arrival or Barrier agreement (which remain bounded only by the caller's context). Quiet-host 64 MiB collectives measure p99 = 7.34 ms; 10s provides >1300x headroom over normal tail latency while bounding silent UC message loss.

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")

	// ErrPeerAborted reports that a peer rank failed and aborted the group over
	// the out-of-band TCP control channel.
	ErrPeerAborted = errors.New("jaccl: peer aborted")
)

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
	// OpTimeout bounds how long an operation waits without wire progress after
	// both ranks have entered the operation when the caller's context has no
	// deadline. It does not bound peer arrival or Barrier agreement. Zero
	// selects DefaultOpTimeout; a negative value disables the built-in timeout.
	OpTimeout time.Duration
	// WireQoS controls darwin/arm64 OS-thread QoS management during RDMA
	// operations. Zero (WireQoSDefault) defers to JACCL_WIRE_QOS or
	// WireQoSSticky when unset.
	WireQoS WireQoSMode
}

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.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether c is a valid group configuration.

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 address is not a multiple of the page size, are not registered and RegisterBuffer returns nil; any non-zero length is accepted when the start address is page-aligned. 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.

type WireQoSMode

type WireQoSMode uint8

WireQoSMode controls darwin/arm64 OS-thread QoS management during RDMA operations. On other platforms it has no effect.

const (
	// WireQoSDefault defers to the JACCL_WIRE_QOS environment variable, or
	// WireQoSSticky when unset.
	WireQoSDefault WireQoSMode = iota
	// WireQoSSticky promotes each OS thread to UserInteractive on its first
	// operation and leaves it promoted across subsequent calls.
	WireQoSSticky
	// WireQoSPerOp raises the thread to UserInteractive on entry and restores
	// its prior QoS class on return.
	WireQoSPerOp
	// WireQoSNone disables thread QoS management while still pinning the
	// goroutine to its OS thread during RDMA completion polling.
	WireQoSNone
)

func (WireQoSMode) String

func (m WireQoSMode) String() string

String returns the canonical name of m.

Jump to

Keyboard shortcuts

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