1. Establish the distributed contract
(1 × 9 + 3 × 1) / 4 = 3A simple average would give 5 and change the update.A worker is a process or device participating in a shared job. Data parallelism replicates parameters and divides examples; model parallelism partitions model computations or parameters. Communication connects these pieces, but latency, failures and mismatched collective order can stall a job.
Define the global batch and loss denominator. If local batches differ, averaging local means equally changes the result: combine loss or gradient sums and sample counts, then divide by the global count. Apply nonlinear clipping after aggregation.
- Draw process, device and network boundaries.
- Check each example is assigned exactly once per intended epoch.
- Compare a distributed update against a single-device baseline.
Practice partitioning an uneven batch. Partition a global batch
2. Build a JAX training step
data. The first dimension is sharded; each shard retains all four features. Placement alone does not define the loss or optimizer update.Start on one CPU or accelerator with a pure loss function and jax.value_and_grad; compile the step with jax.jit after checking the uncompiled result. Keep parameters and optimizer state explicit. Random keys must be split deliberately, and checkpoint the key along with the rest of the training state.
For multiple devices, create a mesh and use NamedSharding and PartitionSpec to describe how global arrays are placed. Start with a divisible global batch and inspect actual device shards. For multiple processes, launch the program on each host and initialize jax.distributed before accessing devices or performing device computations. All processes must participate consistently in distributed computations.
import jax
import jax.numpy as jnp
def loss(w, x, y):
return jnp.mean((x @ w - y) ** 2)
@jax.jit
def train_step(w, x, y, learning_rate):
value, grad = jax.value_and_grad(loss)(w, x, y)
return w - learning_rate * grad, value
w = jnp.zeros((2,))
x = jnp.array([[1., 2.], [2., 1.]])
y = jnp.array([1., 0.])
w, value = train_step(w, x, y, 0.01)
print(w, value)- Compare loss and gradients with a small reference.
- Inspect global versus local devices and array sharding.
- Synchronize device work before timing.
Practice weighted gradient aggregation. Reduce gradients across uneven workers
3. Recover a consistent training run
A useful checkpoint includes model parameters, optimizer and schedule state, step, random state and input position. A checkpoint spread across workers must be published only once the required pieces are durable and consistent; the exact commit protocol depends on the checkpoint system.
Test recovery by interrupting a run and comparing its resumed next step with an uninterrupted run. The lab models completeness by rank only; it does not establish atomicity, durability, or protection against corrupted files.
Choose a complete set of worker shards. Choose a complete checkpoint
4. Move from training to GPU kernels with TLX
index < 6 prevents out-of-bounds loads and stores.Triton expresses GPU kernels in tiles; TLX extends Triton with lower-level control over warp execution, memory and asynchronous orchestration. The standalone uTLX extension and the Meta TLX fork have different setup and API surfaces. Follow the selected project’s current installation instructions and supported hardware rather than assuming a kernel works across versions.
Begin with a reference operation such as matrix multiplication. Check partial tiles, data types and numerical error against a trusted implementation. Only then explore asynchronous copies and warp specialization: every producer and consumer must agree on buffer lifetime and synchronization. Benchmark with warmup and device synchronization; record hardware, shapes, versions and end-to-end impact.
JAX does not automatically execute arbitrary TLX code in this exercise. Integrating a custom kernel requires an explicit supported integration path, compatible toolchain and gradient strategy; test both forward and backward behavior.
- Mask loads and stores for partial tiles.
- Check race freedom and synchronization for reused buffers.
- Compare correctness and performance against a framework baseline.
Practice the bounds of a partial GPU tile. Mask the final GPU tile
5. Suggested training sequence
Work through batch partitioning, gradient reduction, tensor-parallel linear layers, checkpoint selection and tile masking in that order. Predict each output before running the tests, then add a custom case that targets a boundary.
For an external project, reproduce the single-device JAX step, extend it to a device mesh using the official JAX tutorials, then reproduce a TLX example on supported hardware. Record loss curves, numerical comparisons, throughput and restart behavior; change one factor at a time.
Open the distributed systems lab track. Open practice
Frequently asked questions
- Do the browser labs run JAX or TLX?
- No. They use standard-library Python to practice selected contracts. Real multi-device training and GPU kernels need separate software and hardware.
- Does TLX replace JAX distributed training?
- No. They operate at different layers: JAX handles array computations and distributed placement, while TLX provides lower-level GPU kernel capabilities through Triton.
Further reading
Start with primary reports and documentation. Community discussions are discovery leads, not evidence on their own.