MegaText is a pre-training framework for large language models on TPUs, built on JAX and inspired by Google’s MaxText and NVIDIA’s Megatron-LM. It keeps data indexing, blending, checkpoint conversion and deployment in one codebase.
Features
- C++ data indexing. Segment-tree bin packing builds indices for 19M documents in 7 seconds, with caching on Google Cloud Storage.
- Multi-source blending. Megatron-style proportional sampling across datasets, set with a simple weight and path config.
- Flexible config. Validated YAML with command-line overrides and templates for 9 architectures.
- Optimizers and schedules. AdamW, Muon and SGD, with constant, cosine and Warmup-Stable-Decay schedules.
- Autotuning. A search over batch size, rematerialization policy and attention block size on synthetic data.
- Checkpoint conversion. Two-way conversion between Hugging Face and MegaText for 8 architectures.
- One-command GKE deployment. Job definitions, Docker build and submission in a single command.
Making Qwen3-Next fast
For Qwen3-Next 8B at 4K context on a TPU v5e-256, kernel and sharding work raised throughput from 61.6 to 84.5 TFLOP/s per device, 37% higher, with step time going from 5.98 to 4.40 seconds. The largest change replaced a triangular solve with a Pallas blockwise inversion. A separate set of memory changes made 16K sequences fit. Every step was checked against the reference paths, on loss curves and on forward and backward tensors.