@vintcessun: 预训练原来可以这么省?1B模型、~$1000就能从零训出可用的基础模型,计算和数据量直接砍掉数百倍。核心不靠堆算力,而是层次递归架构加上潜在空间推理,配合PrefixLM packing和FA3把效率拉满。有点离谱,但论文和代码都开源了。
摘要
HRM-Text发布了一个1B参数的基础模型,声称仅需约$1000即可从零完成预训练,计算量和数据量减少数百倍,采用层级递归架构、潜在空间推理和PrefixLM packing等高效技术,论文与代码均已开源。
查看缓存全文
缓存时间: 2026/06/05 15:15
预训练原来可以这么省?1B模型、~$1000就能从零训出可用的基础模型,计算和数据量直接砍掉数百倍。核心不靠堆算力,而是层次递归架构加上潜在空间推理,配合PrefixLM packing和FA3把效率拉满。有点离谱,但论文和代码都开源了。 https://t.co/opN1NhjATA
sapientinc/HRM-Text
Source: https://github.com/sapientinc/HRM-Text

HRM-Text: Efficient Pretraining Beyond Scaling
🌟 Pretrain a foundation model from scratch with ~$1000. 🌠
HRM-Text is a 1B text generation model based on the HRM architecture, strengthened by task completion and latent space reasoning. It offers a full pretraining framework, making foundation model pretraining accessible with 130-600x less compute and 150-900x less data. It is built upon a hierarchical recurrent architecture, PrefixLM sequence packing, FlashAttention 3 kernels, PyTorch FSDP2 training, evaluation, and checkpoint conversion tooling.
Join 1200+ HRM Developers on Our Discord Community: https://discord.gg/sapient

Launch the Pretraining 🚀
Required Resources
Choose a target size and prepare the corresponding GPU nodes.
- L, 0.6B parameters: 8 H100s, single node, about 50 hours (~$800).
- XL, 1B parameters: 16 H100s, two nodes, about 46 hours (~$1472).
Price estimation based on $2/H100 hour.
The following are benchmark results from the reference runs.
| Size | GPUs | Time | GSM8k | MATH | DROP | MMLU | ARC-C | HellaSwag | Winogrande | BoolQ |
|---|---|---|---|---|---|---|---|---|---|---|
| L (0.6B) | 8 | 50 hrs | 77.6% | 51.2% | 78.6% | 56.6% | 75.9% | 52.7% | 67.6% | 85.0% |
| XL (1B) | 16 | 46 hrs | 84.7% | 56.5% | 82.3% | 60.7% | 81.9% | 63.4% | 72.4% | 86.2% |
Hopper-class GPUs are the expected training target because the attention path depends on FlashAttention 3.
1. Prepare Data
HRM-Text trains from sampled, tokenized data produced by the companion data_io pipeline. Use data_io to clean, tokenize, and stratified-sample the pretraining corpus, then point HRM-Text at the sampled output.
Recommended setups:
- Single node: run the data pipeline and pretraining on the same node. After tokenization, stratified-sample into that node’s shared memory at
/dev/shm/sampled. - Multi-node: keep
data_ioand the tokenized data on shared storage. Mount or expose that directory on every pretraining node, then run stratified sampling independently on each node. Sampling is fast and deterministic, so every node produces the same in-memory training data.
Please first setup data_io, then run the pipeline. After tokenization, run stratified sampling on each training node.
cd <DATA_IO_PATH>
python sample_tokenized.py epochs=4 output_path=/dev/shm/sampled > show_analytics.md
HRM-Text uses 4 training epochs by default. If you change epochs in the training config, change the sampling command to match.
2. Start the Environment
Set up the same environment on every pretraining node.
Recommended: Docker
We recommend running through the published Docker image that contains the full environment. Make sure Docker can see your GPUs, for example through NVIDIA Container Toolkit.
From the repo’s directory:
docker run --gpus all --ipc=host --network=host -it \
-v "$PWD":/workspace \
sapientai/hrm-text:latest
For multi-node runs, mount the same shared workspace on every node. Keeping the code, tokenized data, and checkpoint directory at identical paths avoids version drift between ranks and makes FSDP2 checkpointing straightforward. A common layout is:
/shared/
|-- HRM-Text/
|--- checkpoints/
|-- data_io/
Alternative: Install from Source
If you are not using Docker, first install PyTorch, CUDA, and FlashAttention 3. The tested versions are documented in docker/Dockerfile.
Then install the Python dependencies:
pip install -r requirements.txt
Check Distributed Communication
For multi-node runs, verify NCCL before starting a long job. At minimum, confirm that torchrun can initialize across the intended nodes. If your cluster provides nccl-tests, run both intra-node and inter-node bandwidth checks.
Set Up W&B Tracking
HRM-Text logs training metrics to Weights & Biases. Log in before launching training:
wandb login
For headless runs, get an API key from https://wandb.ai/authorize and run:
wandb login <API_KEY>
3. Launch Pretraining
For the L-size reference run on one 8xH100 node:
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 \
torchrun --nproc_per_node=8 pretrain.py arch/size@arch=L lr=2.5e-4 global_batch_size=172032
For the XL-size reference run on two 8xH100 nodes, run this on each node:
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 \
torchrun \
--nproc_per_node=8 \
--nnodes=2 \
--node_rank=<NODE_RANK> \
--master_addr=<MASTER_ADDR> \
--master_port=<MASTER_PORT> \
pretrain.py
Checkpoints are saved every epoch under checkpoints/. Remember for multi-node runs, each node only saves its own shard, so we recommend mounting a shared storage.
4. Evaluate
Evaluation loads the latest checkpoint epoch automatically when ckpt_epoch is not provided:
python -m evaluation.main ckpt_path="checkpoints/..."
To run a specified set of benchmarks, append run_only=[MATH,DROP,ARC,MMLU] to the command
Evaluation typically needs one 80 GB GPU. If evaluation runs out of memory, lower the batch size by adding generation_config.batch_size=16
The evaluation scripts use Hugging Face datasets, so benchmark data is downloaded on demand.
5. Export to Transformers Format
python -m conversion.convert_to_hf \
--ckpt_path "checkpoints/..." \
--out_dir "<OUTPUT_PATH>"
For evaluation and export, EMA weights are used by default when EMA is present in the checkpoint.
Fine-Tuning (SFT)
Continue-train a pretrain checkpoint on instruction data. Full-parameter only.
Input is a JSONL with one object per line; condition defaults to direct:
{"instruction": "<full prompt>", "response": "<expected output>", "condition": "direct"}
1. Prepare Data
python scripts/prepare_sft_data.py \
--train your.jsonl \
--tokenizer /path/to/tokenizer.json \
--output /dev/shm/sft_data \
--epochs <N>
--epochs must equal the training epochs (one pre-shuffle per epoch).
2. Launch Training
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 \
torchrun --nproc_per_node=8 pretrain.py \
--config-name cfg_sft \
arch/size@arch=XL \
data.path=/dev/shm/sft_data \
resume_from=/path/to/pretrain_ckpt \
+checkpoint_path=/path/to/sft_out
resume_from loads both model weights and optimizer state (including EMA) by default. Add weights_only_resume_from_ema=true to swap the pretrain EMA buffer into the model and start with a fresh optimizer — typical when fine-tuning off a pretrain run. The arch/* flags must match the pretrain checkpoint’s all_config.yaml (override arch.n_layers etc. if it differs from the size preset).
Status
- Training, checkpointing, and evaluation are implemented in this repository.
- Transformers-format export is implemented in
conversion/convert_to_hf.py. - Native Transformers model support is merged and scheduled for the next release.
- Native vLLM support for HRM-Text checkpoints is in progress.
Training Overrides
The default pretraining config is config/cfg_pretrain.yaml:
If project_name, run_name, or checkpoint_path are omitted, rank 0 derives them from the dataset path, architecture name, and a generated slug.
Hydra overrides can be passed directly on the command line:
# Train a vanilla Transformer architecture, size L
torchrun --nproc_per_node=8 pretrain.py \
arch/net@arch=transformer \
arch/size@arch=L
Model Configurations
Architectures live under config/arch/net:
| Config | Model |
|---|---|
hrm | HRM-Text |
transformer | Standard Transformer wrapper |
trm | Tiny Recursive Model baseline |
trm_match_recurrence | TRM configured to match HRM recurrence with half parameters |
rins | Recursive Inference Scaling (RINS) baseline |
ut | Universal Transformer baseline |
Sizes live under config/arch/size:
| Config | Layers | Hidden | Heads |
|---|---|---|---|
B | 12 | 1024 | 8 |
L | 24 | 1280 | 10 |
XL | 32 | 1536 | 12 |
XXL | 72 | 1792 | 14 |
XXL_wide | 32 | 2560 | 20 |
For HRM and RINS, half_layers: true splits the configured layer count evenly between the H and L modules.
Repository Layout
HRM-Text/
|-- config/ # Hydra configs for model, data, and training
|-- conversion/convert_to_hf.py # FSDP2 checkpoint -> HF-style export
|-- evaluation/ # Evaluation engines, benchmark wrappers, configs
|-- models/ # HRM, recurrent baselines, Transformer blocks, LM head
|-- docker/ # Tested CUDA/PyTorch/FlashAttention environment
|-- dataset_new.py # PrefixLM packed dataset loader
|-- multipack_sampler.py # Distributed multipack batch sampler
|-- pretrain.py # FSDP2 pretraining entrypoint
|-- simple_inference_engine.py # Checkpoint loader and compiled generation engine
`-- requirements.txt
Technical Notes
dataset_new.pyloads sampledtokens.npyand per-epoch index arrays, builds PrefixLM batches, masks instruction tokens by default, and emits FlashAttention sequence metadata.multipack_sampler.pyimplements distributed multipack batching with LPT allocation to improve token-slot utilization and balance quadratic attention work.models/flash_attention_prefixlm_v2.pyimplements the two-pass PrefixLM attention path: one bidirectional pass over the prefix region and one causal pass over the response region.models/layers.pycontains RoPE, gated multi-head attention, SwiGLU MLPs, static KV cache helpers, and initialization utilities.models/baselines/hrm_nocarry_bp_warmup.pycontains the main HRM-Text architecture.models/lm_head.pyattaches scaled embeddings, the output head, cross-entropy loss, token accuracy, and sequence exact accuracy.pretrain.pyhandles FSDP2 wrapping, optimizer creation, LR schedule, W&B logging, code/config snapshots, and distributed checkpointing.
Contributions
We welcome contributions that make HRM-Text faster, stronger, or easier to use.
Please send data-pipeline changes to the companion data_io project. Send model, training, inference, evaluation, conversion, infrastructure, and documentation changes here.
Recommended PR categories:
- Docs and tutorials: clarify setup, data prep, launch recipes, evaluation, or checkpoint conversion.
- Evaluation and inference: add benchmark wrappers, improve generation throughput, reduce VRAM, or improve result reporting.
- Training infrastructure: improve FSDP2 stability, efficiency, checkpointing, launch ergonomics, logging, or cluster portability.
- Model and optimizer changes: improve the architecture, recurrence schedule, initialization, attention path, optimizer, or training hyperparameters.
For changes that alter pretraining behavior, we strongly recommend running pretraining at an appropriate scale and including downstream benchmark comparisons against the reference.
For infrastructure changes intended to be behavior-preserving, include before/after speed, memory, or stability measurements and show that benchmark quality does not regress.
For model-quality changes, we evaluate whether the change improves the Pareto frontier of training compute versus performance. Strict improvements and high-ROI changes are good candidates for defaults; valuable tradeoffs with higher cost or lower performance may belong in separate configs.
Citation
If you find this project or our paper useful, please consider citing our paper:
@misc{wang2026hrmtextefficientpretrainingscaling,
title={HRM-Text: Efficient Pretraining Beyond Scaling},
author={Guan Wang and Changling Liu and Chenyu Wang and Cai Zhou and Yuhao Sun and Yifei Wu and Shuai Zhen and Luca Scimeca and Yasin Abbasi Yadkori},
year={2026},
eprint={2605.20613},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2605.20613},
}
License
Apache License 2.0
相似文章
HRM Seems To Be Going Off Right Now
Sapient Intelligence发布了HRM-Text,一个1B参数的文本生成模型,仅用0.04万亿token训练(成本约1000美元),在多个推理基准上超越训练数据多100-1000倍的更大模型,标志着AI训练新范式的开始。
HRM-Text: 仅用1千美元和400亿token训练,采用受大脑启发的分层潜在架构
HRM-Text是一个10亿参数文本生成模型,采用受大脑启发的分层循环架构,仅用400亿token和约1000美元即可实现高效预训练,大幅降低计算和数据需求,使得基础模型训练更加可及。
@cuisitekp: 9B 的模型,把比它大好几倍的模型干下去了。 Ai2 和华盛顿大学那拨做 OLMo / Tülu 的人,放出一篇新论文叫 Tmax,自称是目前最强的开源「终端 agent」RL 训练配方。 成绩:一个 9B 模型在 Terminal-Be…
Ai2和华盛顿大学发布论文Tmax,提出目前最强的开源终端智能体RL训练配方。仅用9B参数模型在Terminal-Bench 2.0上击败更大模型,关键在于低成本生成大量可验证训练数据,而非模型规模或算法。
@NFTCPS: 4GB显存跑70B大模型?这事儿真成了! AirLLM玩了个骚操作——分层推理,不一次性把模型怼进显存,而是一层层加载、算完就扔,硬生生把巨无霸塞进小破卡。 最骚的是:100%开源,白嫖警告 https://github.com/0xSo…
AirLLM 是一个完全开源的工具,通过分层推理技术(逐层加载并立即释放显存),使得 70B 大语言模型可在仅 4GB 显存的 GPU 上运行,无需量化、蒸馏或剪枝,并已支持 Llama3.1 405B 在 8GB 显存上运行。
@QingQ77: 从0训练一个0.1B的端到端全模态模型,一个权重搞定文字、语音、图片输入,输出文字和流式语音。 https://github.com/jingyaogong/minimind-o… MiniMind-O 是一个只有0.1B参数的全模态模型…
MiniMind-O 发布了一个仅 0.1B 参数的端到端全模态模型,支持文本、语音和图片输入及流式语音输出。该项目开源了代码、权重、训练数据和技术报告,强调在普通 GPU 上即可快速训练和推理。