Skip to main content
The complete Inkling RL implementation is open at the Miles pull request: radixark/miles#1683.

1. Model Introduction

Inkling is a mixture-of-experts transformer released by Thinking Machines Lab, with 975 B total parameters and 41 B active, a context window of up to 1 M tokens, and pretraining on 45 trillion tokens of text, images, audio and video. Its architecture introduces short convolution, attention with relative positional embedding, and a novel MoE design with a shared-expert sink. Miles implements Inkling as a native Megatron model: local and global relative attention, the residual ShortConv, the shared-sink router and experts, and the image and audio encoders, and the same backend drives both full-parameter and LoRA RL. Key highlights:
  • ShortConv: a short causal convolution with a residual connection, applied on the K and V streams and on the attention and MLP/MoE outputs. Miles implements it with fused, packing-aware Triton kernels.
  • Relative attention: a learned relative-position bias replaces positional embeddings; the stack mixes sliding-window and full-attention layers, with context length up to 1 M tokens.
  • Shared-expert sink MoE: sigmoid top-k routing where the router also scores the shared experts and renormalizes their weights together with the selected routed experts’.
  • Train–inference consistency by construction: customized relative-attention score-mod, ShortConv, and FP32 SwiGLU/combine kernels, while Rollout Routing Replay (R3) replays the rollout’s routed expert IDs, including over media-expanded multimodal sequences.

2. Supported Variants

3. Quick start

3.1 One-line launch

3.2 Launcher path defaults

Every option can also be preconfigured via MILES_SCRIPT_<FIELD_NAME_UPPER> env vars (precedence: CLI flag > env var > built-in default). Pass any extra Miles / Megatron / SGLang flags through --extra-args.

4. Script breakdown

This section explains what the launcher does under the hood, and how to drive each stage manually.

4.1 Download model + datasets

Pass --hf-checkpoint <path> to the launcher when the weights are already on a shared filesystem.

4.2 HF → Megatron torch_dist conversion

Inkling ships in BF16, so conversion is a single distributed torch_dist shard (no precision cast). The model definition comes from scripts/models/inkling-975b.sh:
The saved torch_dist checkpoint is parallelism-agnostic: training can load it under any validated TP / PP / EP layout. Point the launcher at the result with --torch-dist.

4.3 Multi-node fan-out

Start each pod with the image and a shared filesystem mounted at the same path on every node, then bring up Ray:
Set MILES_SCRIPT_EXTERNAL_RAY=1 to point the launcher at this existing Ray cluster. When it is unset, the launcher boots a local Ray head itself.

5. Example Recipe Configuration

5.1 Megatron Parallelism

These are the validated layouts shipped with the launcher. Other TP / EP / PP / CP combinations that fit your compute can be supplied via --extra-args (the launcher raises on untested GPU counts to keep you honest).

5.2 Algorithm

GRPO with truncated importance sampling. The launcher defaults: global batch size 32, group size 8, maximum response length 4096 with truncation, Adam with lr 1e-6, constant decay. Rollout Routing Replay is on by default (--use-rollout-routing-replay). It replays only the routed expert IDs; the continuous routed and shared weights are recomputed from the current router under one common normalization, so gradients still flow through both.

5.3 Training attention backends

--inkling-attn-backend selects the training-side attention implementation:

5.4 Rollout & SGLang

Weight updates stream Megatron shards into SGLang’s tensor layout in bounded buckets over CUDA IPC (colocated). In LoRA mode only the adapter is synchronized.

5.5 Optimizer

Within a single GB300 rack the 975 B policy, gradients, and FP32 optimizer state exceed GPU memory, so Miles streams Megatron DistributedOptimizer state between a bounded GPU working set and node-local NVMe. The offload changes storage placement, not the update math. The paused training actor’s weights are additionally disk-backed through torch_memory_saver. LoRA training skips both offloads and uses dynamic batching (--use-dynamic-batch-size --max-tokens-per-gpu 4096) instead of the fixed micro-batch.
  1. Fixed micro-batches for full-parameter runs. Dynamic token packing exposes a PP-p2p × EP-all-to-all NCCL launch-order race on varlen shapes; the launcher pins --micro-batch-size 1 for full-parameter training. Keep it pinned until the pad-to-fixed fix lands.
  2. One LoRA adapter per engine. RL serving uses --sglang-max-loras-per-batch 1 with the triton LoRA backend and virtual experts: the engine holds exactly the current policy’s adapter (see LoRA RL).

6. LoRA RL

--train-mode lora switches the same backend and parallel stack to adapter-only training. The base model stays frozen in both runtimes, and GRPO updates only the low-rank factors: y=Wx+αrB(Ax).y = Wx + \frac{\alpha}{r}\,B(Ax). The adapter follows Inkling’s released LoRA schema, covering the attention, dense MLP, MoE, and LM-head projections (defaults: rank 32, alpha = 32, all-linear). The routed experts use a shared-outer factorization: one factor is shared across experts while the expert-specific factors follow EP sharding. After each optimizer step, Miles exports a serving-ready adapter directly from the distributed training state and hands it to the colocated SGLang worker over CUDA IPC; the frozen base is never re-transferred. This cuts the weight update from 49.4 s to 2.5 s (20×) and brings training-step time to ~85 % of full-parameter training, with no optimizer offload needed. Released Inkling adapters in safetensors format support warm starts via --lora-adapter-path, and per-rank adapter checkpoints allow exact training resume.

7. Multimodal RL

--task geo3k switches to the vision-language recipe: structured multimodal rollouts, Megatron-side vision and audio towers, and routing replay preserved across the media-expanded sequence. Each image or audio sentinel in the rendered prompt expands into its patch/frame positions before packing, and the R3 trace is indexed over the expanded sequence, so replay stays aligned even though SGLang made its routing decisions after expansion. Production recipes keep the vision and audio towers frozen and train the language model (or its adapter) around their embeddings; training the towers is available as an experimental option. The same path supports audio inputs and both full-parameter and LoRA training.