What it does¶
Supervised fine-tuning¶
Including agentic traces with tool calls and reasoning.
Reinforcement learning¶
Verifiable rewards, multi-turn tool use, GRPO-style groups, vLLM rollouts.
Agent environments¶
Python classes, MCP servers, OpenEnv, NeMo Gym, Harbor tasks in Docker, with emulated harness dialects (opencode, pi, OpenHands, …).
On-policy distillation¶
The student samples, one or more teachers score those tokens, reverse KL.
Off-policy distillation¶
Fixed data against one or more teachers' distributions (online, or a cached top-k), context distillation, hidden-state targets, multi-GPU, plugins for QAT.
Preference optimization¶
DPO, IPO, SLiC-HF, robust and length-normalised DPO, SFT anchor.
Model merging¶
Interpolation, soups, task arithmetic.
Data preparation¶
Drop broken rows and duplicates, hold out an eval set, with the same config you train with.
Continued pretraining¶
Raw text with a loss on every token: a domain, a language or a corpus, from the base model, merged into the instruct model afterwards.
When something is off¶
Loss is NaN or spikes¶
LR too high. Loss NaN/spikes, grad_cosine_sim < 0.
Diagnosis train/grad_norm exploding
Fix learning_rate ÷ 3
Loss is flat¶
LR too low. Loss flat, slow convergence.
Diagnosis eval not improving for 500+ steps
Fix learning_rate × 2
This shows you exactly what the model sees: tokenized text, which tokens have loss, how masking works. Most "loss not decreasing" issues are data masking bugs.
Out of memory¶
Memory pressure. OOM or CUDA malloc fails.
Diagnosis health/cuda_utilization_pct > 95%
Fix Reduce per_device_batch_size, increase loss_num_chunks
Training is slow¶
Slow throughput. tok/s below expected.
Diagnosis health/cuda_utilization_pct low
Fix model.compile: true, increase batch, num_workers
Eval loss rises while train loss falls¶
Overfitting. eval↑ while train↓.
Diagnosis eval/loss diverging from train/loss
Fix epochs: 2, base_merge: true
Outputs become repetitive¶
Representation collapse. Model outputs become repetitive.
Diagnosis health/stable_rank_min < 3
Fix Reduce LR, enable sym_noise
Skills lost after continued pretraining¶
Forgetting. General or chat skills drop while the domain loss falls.
Diagnosis eval/<name>/loss of a general held-out source rising
Fix CPT the base, not the instruct model; replay general text; merge at small λ
Output diversity disappears (RL)¶
Entropy collapse (RL). Output diversity disappearing.
Diagnosis health/output_entropy < 1.5
Fix pre_rl: true, stop early
What you can rely on¶
Correct by construction¶
The loss path is checked step by step against a plain reference loop; packed conversations never see each other; multi-GPU gradients equal single-GPU ones; saved models load with plain from_pretrained.
Masking from the chat template¶
Whole assistant turns are trained as the template renders them, tool calls and end-of-turn tokens included; tools are rendered into the prompt; "loss": false keeps a message as context only.
Token-exact RL¶
What the trainer scores is exactly what the sampler produced, tool results included; nothing is re-tokenized. Rewards are checked answers, hidden tests, LLM judges or any Python function.
Memory¶
Chunked losses (the full logits are never materialised), selective activation checkpointing, gradient release, 8-bit optimizers. A Qwen3.5-4B fine-tune (attention pathway, 36% of the weights) fits in about 16 GiB.
Long sequences on one GPU¶
SeCO: chunk-by-chunk training with a cache gives the exact gradient, verified against full backpropagation on 27 architectures, including the Qwen3.5 and LFM2 hybrids.
Training you can inspect¶
wandb and trackio with grad norm, spike and clip counters, gradient noise scale, entropy and the generalisation gap on one step axis; best-checkpoint tracking on eval loss.
Crash-safe¶
Re-run the same command to resume from the last complete checkpoint, in the same tracker run.
Scale out¶
FSDP across GPUs, multi-node SLURM with sharded checkpoints, and a container image for Kubernetes.
Research options, one line each¶
DEFT / DFT / InfoSFT token weighting, Hyperball, power-decay schedules: implemented to their papers' definitions; the benefits are as reported by the papers, not reproduced here.
Install¶
Any HuggingFace causal LM. Optimized for: Qwen 2.5/3/3.5, Llama 3, Gemma 4, Mistral. Hybrid architectures (Qwen3.5 DeltaNet) supported via freeze_non_attention.