For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python class
ColumnParallelLinear
ColumnParallelLinear
class max.nn.common_layers.linear.ColumnParallelLinear(*args, tp_axis=None, **kwargs)
Bases: Linear
A linear layer whose weight is sharded across its output features.
The constructor shards the layer’s weight and bias the way
col_parallel() does, along tp_axis
(by default TP). On a mesh with
no such axis, the weight stays replicated.
Build a sharded layer on a (dp, tp) mesh:
from max.driver import CPU
from max.nn.common_layers.linear import ColumnParallelLinear
from max.nn.common_layers.mesh_axis import DP, TP
from max.tensor import default_device
from max.tensor.sharding import DeviceMesh, Replicated, Sharded
cpu = CPU()
mesh = DeviceMesh(
devices=(cpu, cpu, cpu, cpu),
mesh_shape=(2, 2),
axis_names=(DP, TP),
)
with default_device(mesh):
layer = ColumnParallelLinear(8, 8, bias=True)
Constructs a linear layer and shards its weight and bias.