Skip to content

Distributed Inkling-2-Mini (26B MoE)

Full source in examples/inkling_mini_2_26b.rs. Run a multi-device CPU smoke test with JACOBI_BACKEND=cpu cargo run --release --example inkling_mini_2_26b -- --small --fp8 --adamw.

What This Shows

  • Distributed Expert Parallelism (EP=8) across 8x H200 GPUs using Mesh::new(&["ep"], &[ep_size]) and shard_map
  • Live next-token cross-entropy training on Hugging Face PleIAs/SYNTH via hub::load_dataset (or --tokens-file for up to 1B+ pre-tokenized tokens)
  • Token-sharded FP8 all_to_all_axis routing across 128 fine-grained experts (16 local experts per GPU, top-8 routing) via nn::moe_swiglu_dispatch_all_to_all_fused_tn
  • Looped-core weight-sharing Transformer (24 physical layers executing 48 logical visits across 3 core passes with low-rank pass gates)
  • Causal depthwise short convolution, L2-clipped RoPE QK heads, gamma-free V RMSNorm, and cuDNN FlashAttention-3 (D=128, 24/8 GQA)
  • Batched distributed Rollout (--rollout) with SageAttention, sliding-window ring-buffer KV caching (window=512), and FP8 KV storage

Expert Parallel Mesh and Routing

Each GPU owns 128 / EP routed experts and processes its local token shard (batch sequences per GPU, batch * EP global sequences). Inside each logical layer visit, moe_swiglu_dispatch_all_to_all_fused_tn performs contiguous FP8 dispatch AllToAll, local fused SwiGLU expert MLP, and zero-atomic FP8 combine AllToAll.

let mesh = Mesh::new(&["ep"], &[ep_size])?;

let r_logits = m_in.matmul(&rw.to_bf16()).to_f32() + &rb;
let (top_vals, top_idx) = r_logits.top_k(cfg.num_experts_per_tok);
let r_weights = top_vals.softmax() * cfg.route_scale;

let moe_cfg = MoeDispatchConfig::default().softcap(cfg.mlp_gate_softcap, cfg.mlp_up_softcap);
let moe_out = moe_swiglu_dispatch_all_to_all_fused_tn(
    &m_in,
    &top_idx,
    &r_weights,
    &wgu,
    &wd,
    cfg.n_routed_experts,
    ep_size,
    (ep_size > 1).then_some("ep"),
    moe_cfg,
)
.reshape(&[b, t, h]);

During the distributed training step, replicated dense weights synchronize across "ep" while sharded expert weights (w_gate_up, w_down) stay local to each GPU.

let adamw_step = shard_map(
    mesh.clone(),
    vec![PartitionSpec::replicated()],
    vec![PartitionSpec::replicated()],
    move |(mut shard, mut opt, ids): (InklingShard, AdamW<InklingShard>, Tensor)| {
        let (mut loss, grads) = value_and_grad(
            |p: InklingShard| p.forward_loss(&cfg_t, ep_size, &ids) * (1.0 / ep_size as f64),
            &shard,
        );
        loss = psum_axis(&loss, "ep");
        let grads = sync_replicated_inkling_grads(grads, ep_size);
        opt.step(&mut shard, &grads);
        (shard, opt, loss)
    },
);

Running and Tuning

# Local 4-device CPU smoke test (6 physical layers / 10 visits, 16 experts, FP8 + AdamW)
JACOBI_BACKEND=cpu cargo run --release --example inkling_mini_2_26b -- --small --fp8 --adamw

# Full 25.85B FP8 training on 8x H200 (global batch 192, 4K context, PleIAs/SYNTH cross-entropy)
JACOBI_MOE_CF=1.00 JACOBI_CKPT_LAYERS=42 JACOBI_LM_CHUNK=8192 \
  cargo run --release --example inkling_mini_2_26b -- --fp8 --skip-fwd --adamw --fp8-mode sr --batch 24 --seq 4096 --runs 15 --lr 3e-4 --warmup 3

# Batched distributed Rollout across 8x H200 (128 4K prompts x 16 GRPO rollouts = 2,048 x 1,024 tokens)
JACOBI_MOE_CF=1.00 cargo run --release --example inkling_mini_2_26b -- \
  --fp8 --skip-fwd --rollout --batch 16 --group 16 --prompt-len 4096 --rollout-len 1024 --window 512 --runs 3

8x H200 141GB Benchmark Results (4K Context, FP8, EP=8, PleIAs/SYNTH)

Measured on random-weight architecture replicas (no HuggingFace weight-parity check). Cluster Peak HBM is reported as device-0 peak HBM x 8.

Mode Global Batch Capacity Factor / Ckpt Peak HBM (Per GPU / Cluster) Throughput 15-Step CE Loss Cost / 1T
Forward (4k) 192 1.00 / N/A 26.25 GB / 210.00 GB 356,043.9 tok/s N/A N/A
Train (Full AdamW, SR, 4k) 192 1.00 / 42 of 48 126.93 GB / 1,015.44 GB 105,419.8 tok/s 12.66 -> 8.32 $73.8k
Train (rank-32 EfficientAdamW, SR, 4k) 192 1.00 / 42 of 48 122.89 GB / 983.12 GB 102,142.6 tok/s 12.66 -> 10.92 $76.1k
Rollout (Sage + SW-512, 4k->1k, 128x16) 2,048 1.00 / N/A 18.72 GB / 149.76 GB 63,084.2 tok/s N/A N/A
Rollout (Sage + SW-512, 4k->1k, 256x1) 256 1.00 / N/A 20.08 GB / 160.64 GB 11,727.1 tok/s N/A N/A