dtensor

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: 8 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 distributed defines a dtensor.Tensor, a logical tensor distributed across multiple devices organized as a distributed.DeviceMesh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tensor

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

Tensor is a logical tensor meant to be distributed across multiple devices (organized as a distributed.DeviceMesh). It is a container for its shards (concrete tensors.Tensor), one per device. The shards may or may not be stored on a backend (or local on the host), it's up to the caller to manage the shards storage.

The logical distributed Tensor can be either replicated or sharded at each axis. When an axis is sharded, it is shared over a DeviceMesh axis, and the distributed tensor is equally split across that configured mesh axis. When an axis is replicated, the tensor is replicated across all mesh axes.

The idea is that when executing a distributed computation, each device will receive the corresponding tensor shard, replicated and/or sharded, according to the specification.

func NewTensor

func NewTensor(spec *distributed.ShardingSpec, shards []*tensors.Tensor) (*Tensor, error)

NewTensor creates a new distributed Tensor. It assumes the provided shards are already on their respective devices.

func ShardTensor

func ShardTensor(spec *distributed.ShardingSpec, t *tensors.Tensor) (*Tensor, error)

ShardTensor splits a tensor into individual shards. This all happen on the host, and the shards of the returned dtensor.Tensor are local tensors.

func (*Tensor) Clone

func (dt *Tensor) Clone() (*Tensor, error)

Clone creates a copy of the distributed Tensor. It clones each shard on the device it currently resides.

func (*Tensor) DType

func (dt *Tensor) DType() dtypes.DType

DType returns the logical, unsharded shape of the tensor.

func (*Tensor) Finalize

func (dt *Tensor) Finalize() error

Finalize releases the memory associated with the distributed tensor. It calls FinalizeAll on each of the shards. It is safe to call Finalize on an already finalized tensor.

func (*Tensor) FinalizeAll

func (dt *Tensor) FinalizeAll() error

FinalizeAll is an alias to Finalize.

func (*Tensor) Merge

func (dt *Tensor) Merge() (*tensors.Tensor, error)

Merge merges the tensors into one concrete logical tensor.

func (*Tensor) Mesh

func (dt *Tensor) Mesh() *distributed.DeviceMesh

Mesh redt.logicaturns the distributed.DeviceMesh for this tensor.

func (*Tensor) NumShards

func (dt *Tensor) NumShards() int

NumShards returns the number of shards in the distributed tensor.

func (*Tensor) Ok

func (dt *Tensor) Ok() bool

Ok returns whether the distributed tensor is in a valid state -- and hasn't been finalized.

func (*Tensor) Shape

func (dt *Tensor) Shape() shapes.Shape

Shape returns the logical, unsharded shape of the tensor.

func (*Tensor) ShardShape

func (dt *Tensor) ShardShape() shapes.Shape

ShardShape returns the shape of the individual shards.

func (*Tensor) ShardingSpec

func (dt *Tensor) ShardingSpec() *distributed.ShardingSpec

distributed.ShardingSpec returns the sharding specification for this tensor.

func (*Tensor) Shards

func (dt *Tensor) Shards() []*tensors.Tensor

Shards returns the physical tensor shards. They are owned by the dtensor.Tensor object, and the slice shouldn't be modified -- the contents of the individual shards can be modified directly, if they are stored locally.

It returns Tensor.NumDevices() shards.

Jump to

Keyboard shortcuts

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