Update model card and VRAM notes
Browse files- README.md +190 -50
- VRAM_OOM_NOTES_2026-05-24.md +141 -0
README.md
CHANGED
|
@@ -15,76 +15,216 @@ pipeline_tag: text-generation
|
|
| 15 |
|
| 16 |
# KoHRM-Text-1.4B
|
| 17 |
|
| 18 |
-
`KoHRM-Text-1.4B`
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
##
|
| 23 |
|
| 24 |
-
|
|
| 25 |
|---|---|
|
| 26 |
-
| model
|
| 27 |
-
|
|
| 28 |
-
|
|
| 29 |
-
|
|
| 30 |
-
|
|
| 31 |
-
|
|
| 32 |
-
| dtype | bfloat16 |
|
| 33 |
-
| tokenizer | byte-level BPE, NFC normalization |
|
| 34 |
-
| vocab | 131,072 |
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|---|---:|
|
| 42 |
-
|
|
| 43 |
-
|
|
| 44 |
-
|
|
| 45 |
| shell command | 2.68 |
|
| 46 |
-
| tool JSON | 3.32 |
|
| 47 |
| Python code | 3.37 |
|
| 48 |
-
|
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
##
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
- Optimizer: HRM-Text upstream Adam-atan2
|
| 70 |
-
- Context: 4096 tokens
|
| 71 |
-
- Hardware: 8 x NVIDIA H200
|
| 72 |
-
- Current stage-1 global batch: 229,376 tokens
|
| 73 |
-
- Checkpoint policy: main repo์๋ `safetensors`, raw FSDP2๋ ๋ณ๋ raw checkpoint repo
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
##
|
| 80 |
|
| 81 |
-
|
| 82 |
-
- stage0b safetensors HF upload: complete
|
| 83 |
-
- unsafe raw DCP files removed from main HF repo
|
| 84 |
-
- stage-1 HRM fast-cap training: in progress
|
| 85 |
-
- final Transformers conversion: not yet produced
|
| 86 |
-
- public benchmark score: not yet evaluated for this model
|
| 87 |
|
| 88 |
-
|
|
|
|
| 89 |
|
| 90 |
-
ํ์ฌ checkpoint artifact๋ ์ค๊ฐ ํ์ต ์ฐ์ถ๋ฌผ์
๋๋ค. ์์ ์ฑ ์ ๋ ฌ, ์ต์ข
instruction tuning, ์ต์ข
benchmark, ๋ฐฐํฌ์ฉ ๋ณํ์ด ๋๋ ๋ชจ๋ธ์ด ์๋๋๋ค. ํ๊ตญ์ด ํฐ๋ฏธ๋/ํด์ฝ ๋ฅ๋ ฅ์ ๋ชฉํ ์์ญ์ด์ง๋ง, stage-0๋ง์ผ๋ก๋ ์์ฑ๋ ์ฑ๋ฅ์ ๋ณด์ฅํ์ง ์์ต๋๋ค.
|
|
|
|
| 15 |
|
| 16 |
# KoHRM-Text-1.4B
|
| 17 |
|
| 18 |
+
`KoHRM-Text-1.4B` is a scratch-pretrained Korean/English/code/terminal/tool-use model based on the `sapientinc/HRM-Text` PrefixLM training stack.
|
| 19 |
|
| 20 |
+
This is not a continued finetune of `sapientinc/HRM-Text-1B`. It uses a new Korean/terminal-oriented 131K byte-level BPE tokenizer and a new scratch training run.
|
| 21 |
|
| 22 |
+
## Links
|
| 23 |
|
| 24 |
+
| Item | Link |
|
| 25 |
|---|---|
|
| 26 |
+
| HF model | https://huggingface.co/LLM-OS-Models/KoHRM-Text-1.4B |
|
| 27 |
+
| Project code | https://github.com/LLM-OS-Models/KoHRM-text |
|
| 28 |
+
| Upstream HRM-Text code | https://github.com/sapientinc/HRM-Text |
|
| 29 |
+
| HRM-Text paper | https://arxiv.org/html/2605.20613 |
|
| 30 |
+
| Tokenizer | https://huggingface.co/LLM-OS-Models/HRM-Text-Ko-Terminal-Tokenizer-131K |
|
| 31 |
+
| Raw resume checkpoints | https://huggingface.co/LLM-OS-Models/KoHRM-Text-1.4B-raw-checkpoints |
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
## Release Policy
|
| 34 |
|
| 35 |
+
The main model repository is intended to expose the latest model-only artifact:
|
| 36 |
|
| 37 |
+
- `model.safetensors`
|
| 38 |
+
- `config.json`
|
| 39 |
+
- `tokenizer.json`
|
| 40 |
+
- `tokenizer_config.json`
|
| 41 |
+
- `README.md`
|
| 42 |
+
|
| 43 |
+
It is not intended to keep every training checkpoint as visible model files. Intermediate FSDP2 `.distcp` checkpoints are large resume artifacts and are kept separately in `LLM-OS-Models/KoHRM-Text-1.4B-raw-checkpoints` when needed. The main repo may still have normal Hugging Face git history, but the current file tree should be treated as the latest public model export.
|
| 44 |
+
|
| 45 |
+
Current public artifact: `stage1` HRM fast-cap checkpoint at `step_25000`, converted with EMA weights to `safetensors`. Training is still in progress.
|
| 46 |
+
|
| 47 |
+
## Model Details
|
| 48 |
+
|
| 49 |
+
| Field | Value |
|
| 50 |
+
|---|---|
|
| 51 |
+
| Model id | `LLM-OS-Models/KoHRM-Text-1.4B` |
|
| 52 |
+
| Standard name | `KoHRM-Text-1.4B` |
|
| 53 |
+
| Training origin | scratch |
|
| 54 |
+
| Architecture family | HRM-Text PrefixLM |
|
| 55 |
+
| Architecture size | `XL` |
|
| 56 |
+
| Parameters | 1,384,120,320 |
|
| 57 |
+
| Context length | 4,096 tokens |
|
| 58 |
+
| Training dtype | bfloat16 |
|
| 59 |
+
| Tokenizer | byte-level BPE, NFC normalization |
|
| 60 |
+
| Vocabulary size | 131,072 |
|
| 61 |
+
| Objective | PrefixLM response-only loss |
|
| 62 |
+
| Optimizer | Adam-atan2 from upstream HRM-Text |
|
| 63 |
+
| EMA | 0.9999 |
|
| 64 |
+
|
| 65 |
+
The model config uses `model_type: hrm_text` and `architectures: ["HrmTextForCausalLM"]`. At the time of this checkpoint, `HrmTextForCausalLM` is a project-side custom architecture, not a built-in Transformers architecture.
|
| 66 |
+
|
| 67 |
+
## Tokenizer
|
| 68 |
+
|
| 69 |
+
The tokenizer was trained for Korean, English, code, shell/terminal text, and JSON/tool-call formats. It intentionally keeps common chat/tool special tokens as stable single tokens where possible.
|
| 70 |
+
|
| 71 |
+
| Sample bucket | chars/token |
|
| 72 |
|---|---:|
|
| 73 |
+
| Korean general text | 2.60 |
|
| 74 |
+
| Korean legal text | 2.36 |
|
| 75 |
+
| Korean terminal instruction | 2.18 |
|
| 76 |
| shell command | 2.68 |
|
| 77 |
+
| tool-call JSON | 3.32 |
|
| 78 |
| Python code | 3.37 |
|
| 79 |
+
| English | 4.40 |
|
| 80 |
|
| 81 |
+
Important formatting tokens include:
|
| 82 |
+
|
| 83 |
+
- `<|im_start|>`
|
| 84 |
+
- `<|im_end|>`
|
| 85 |
+
- `<|box_end|>`
|
| 86 |
+
- `<|object_ref_start|>` for direct condition
|
| 87 |
+
- `<|object_ref_end|>` for cot condition
|
| 88 |
+
- `<|quad_start|>` for noisy condition
|
| 89 |
+
- `<|quad_end|>` for synth condition
|
| 90 |
|
| 91 |
+
## Usage
|
| 92 |
|
| 93 |
+
### Tokenizer
|
| 94 |
|
| 95 |
+
```python
|
| 96 |
+
from transformers import AutoTokenizer
|
| 97 |
+
|
| 98 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 99 |
+
"LLM-OS-Models/KoHRM-Text-1.4B",
|
| 100 |
+
use_fast=True,
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
prompt = "<|im_start|><|object_ref_start|>ํ๊ตญ์ด๋ก ํ์ฌ ๋๋ ํฐ๋ฆฌ์ ํฐ ํ์ผ์ ์ฐพ๋ ๋ช
๋ น์ ์๋ ค์ฃผ์ธ์.<|im_end|>"
|
| 104 |
+
ids = tokenizer(prompt, add_special_tokens=False)["input_ids"]
|
| 105 |
+
print(len(ids), ids[:20])
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
### Model Weights
|
| 109 |
+
|
| 110 |
+
The repo currently contains a model-only `safetensors` export. Because the architecture is custom (`hrm_text`), direct `AutoModelForCausalLM.from_pretrained(...)` generation requires an HRM-Text-compatible modeling wrapper or remote-code integration. Until that wrapper is added to the model repo, use the project code and raw FSDP2 checkpoint path for internal inference/resume workflows.
|
| 111 |
+
|
| 112 |
+
Raw checkpoint inference pattern:
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
from simple_inference_engine import inference_load_checkpoint, inference_generate
|
| 116 |
+
|
| 117 |
+
ckpt = inference_load_checkpoint(
|
| 118 |
+
ckpt_path="/path/to/KoHRM-Text-1.4B-stage1-hrm-fastcap-gbs180",
|
| 119 |
+
ckpt_epoch=25000,
|
| 120 |
+
ckpt_use_ema=True,
|
| 121 |
+
device="cuda",
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
prompts = iter([
|
| 125 |
+
(0, ("direct", "ํ๊ตญ์ด๋ก `du`์ `df`์ ์ฐจ์ด๋ฅผ ์ค๋ช
ํด์ฃผ์ธ์.")),
|
| 126 |
+
])
|
| 127 |
+
|
| 128 |
+
for _, text in inference_generate(
|
| 129 |
+
ckpt,
|
| 130 |
+
prompts,
|
| 131 |
+
max_tokens=4096,
|
| 132 |
+
max_generation=512,
|
| 133 |
+
batch_size=1,
|
| 134 |
+
temp=0.0,
|
| 135 |
+
):
|
| 136 |
+
print(text)
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
For code and training scripts, see https://github.com/LLM-OS-Models/KoHRM-text.
|
| 140 |
+
|
| 141 |
+
## Training Data
|
| 142 |
+
|
| 143 |
+
All datasets are converted into HRM-Text V1Dataset style records with `instruction`, `response`, and `condition` fields where possible. The training objective is PrefixLM response-only loss, so the model is trained to predict the response span after seeing the instruction/prompt span.
|
| 144 |
+
|
| 145 |
+
Completed and prepared datasets:
|
| 146 |
+
|
| 147 |
+
| Dataset | Tokens | Disk | Use |
|
| 148 |
+
|---|---:|---:|---|
|
| 149 |
+
| `koterm_pretrain_mix_v1` | 711.3M | 2.8G | stage-0/stage0b |
|
| 150 |
+
| HRM cleaned base sample | 250.0M | 994M | included in stage-0 mix |
|
| 151 |
+
| SWE-ZERO + GLM pilot mix | 251.2M | 990M | included in stage-0 mix |
|
| 152 |
+
| Korean legal SFT/task data | 83.1M | 336M | included in stage-0 mix |
|
| 153 |
+
| ToolBench train tool-call data | 127.0M | 500M | included in stage-0 mix |
|
| 154 |
+
| HRM cleaned fast-cap stage-1 | 14.55B | 148G | current stage-1 |
|
| 155 |
+
| Korean statutes/local ordinances raw full | 308.9M | 1.2G | prepared for later stages |
|
| 156 |
+
| Korean administrative rules + precedents raw full | 271.7M | 1.1G | prepared for later stages |
|
| 157 |
+
| Korean Wikipedia raw full | 462.5M | 1.8G | prepared for later stages |
|
| 158 |
+
| HF extra reasoning/agent/mm subset | 112.6M | 444M | prepared, limited weight |
|
| 159 |
+
| Local terminal conversations | 9.39B | 36G | prepared for terminal-heavy later stages |
|
| 160 |
+
| SWE-ZERO prepared | 182.7M | 720M | pretraining and later SFT |
|
| 161 |
+
| GLM reasoning prepared | 68.5M | 282M | pretraining and later SFT |
|
| 162 |
+
|
| 163 |
+
Major source groups:
|
| 164 |
+
|
| 165 |
+
- Upstream HRM-Text cleaned pretraining data from `sapientinc/HRM-Text-data-io-cleaned-20260515`
|
| 166 |
+
- Korean Wikipedia
|
| 167 |
+
- Korean statutes, local ordinances, administrative rules, and precedent corpora
|
| 168 |
+
- ToolBench train trajectories and tool-use instructions
|
| 169 |
+
- Local terminal/code/math conversations
|
| 170 |
+
- SWE-ZERO terminal/code trajectories
|
| 171 |
+
- GLM reasoning samples
|
| 172 |
+
- Small, reviewed subsets of extra reasoning/agent datasets
|
| 173 |
+
|
| 174 |
+
Evaluation-like data is excluded from training where identified, including ToolBench eval, Terminal Bench 2 style data, and benchmark-oriented `chi-bench` data.
|
| 175 |
+
|
| 176 |
+
## Training Run
|
| 177 |
+
|
| 178 |
+
The current public checkpoint was produced through staged pretraining:
|
| 179 |
+
|
| 180 |
+
1. Train `stage-0` on `koterm_pretrain_mix_v1` with 711.3M tokens.
|
| 181 |
+
2. Continue once more on the same available mix as `stage0b`.
|
| 182 |
+
3. Continue to `stage-1` on HRM cleaned fast-cap data with 14.55B tokens.
|
| 183 |
+
4. Convert `stage1 step_25000` EMA weights to `safetensors` and upload to the main model repo.
|
| 184 |
+
|
| 185 |
+
Current long-running stage-1 settings:
|
| 186 |
+
|
| 187 |
+
| Field | Value |
|
| 188 |
+
|---|---|
|
| 189 |
+
| Hardware | 8 x NVIDIA H200 |
|
| 190 |
+
| Data | `koterm_hrm_cleaned_fastcap_stage1_v1` |
|
| 191 |
+
| Tokens in current stage dataset | 14.55B |
|
| 192 |
+
| Global batch | 180,224 tokens |
|
| 193 |
+
| Local token slots/GPU | 22,528 |
|
| 194 |
+
| Context | 4,096 |
|
| 195 |
+
| LR | 2.2e-4 |
|
| 196 |
+
| LR warmup | 2,000 steps |
|
| 197 |
+
| Checkpoint interval | 5,000 steps |
|
| 198 |
+
| Current public export | `step_25000`, EMA, safetensors |
|
| 199 |
+
|
| 200 |
+
The run uses staged continuation. The checkpoint carries model, optimizer, EMA, and recurrent carry state forward. `resume_step_offset` and `total_steps_override` are used so the learning-rate schedule follows the intended longer pretraining run rather than resetting at every data stage.
|
| 201 |
+
|
| 202 |
+
The full HRM 328G cleaned corpus is being retokenized with the new 131K tokenizer. That full no-cap retokenization is intended to support a larger 40B+ token training continuation, instead of stopping at the 14.55B fast-cap stage.
|
| 203 |
+
|
| 204 |
+
## Intended Use
|
| 205 |
|
| 206 |
+
This checkpoint is intended for:
|
| 207 |
|
| 208 |
+
- continued pretraining experiments
|
| 209 |
+
- Korean tokenizer and HRM-Text architecture experiments
|
| 210 |
+
- terminal/tool-call/code pretraining research
|
| 211 |
+
- checkpoint conversion and evaluation work
|
| 212 |
|
| 213 |
+
It is not yet intended as a finished assistant model.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
+
## Limitations
|
| 216 |
|
| 217 |
+
- This is an intermediate checkpoint, not a final aligned instruct model.
|
| 218 |
+
- It has not completed the full planned 40B+ token continuation.
|
| 219 |
+
- It has not completed final SFT or safety tuning.
|
| 220 |
+
- Public benchmark scores for this new checkpoint are not final.
|
| 221 |
+
- Direct Transformers generation requires adding the custom `hrm_text` modeling wrapper or remote-code files.
|
| 222 |
+
- Tool-call JSON validity and terminal action safety must be evaluated before production use.
|
| 223 |
|
| 224 |
+
## Citation
|
| 225 |
|
| 226 |
+
This work builds on the HRM-Text architecture and training stack:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
+
- Paper: https://arxiv.org/html/2605.20613
|
| 229 |
+
- Upstream code: https://github.com/sapientinc/HRM-Text
|
| 230 |
|
|
|
VRAM_OOM_NOTES_2026-05-24.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# KoHRM-Text VRAM / OOM Notes
|
| 2 |
+
|
| 3 |
+
์์ฑ์ผ: 2026-05-24
|
| 4 |
+
|
| 5 |
+
์ด ๋ฌธ์๋ `KoHRM-Text-1.4B` stage-1 ํ์ต ์ค VRAM์ด ์๊ฐ์ด ์ง๋๋ฉฐ ์ฆ๊ฐํ๋ ์ด์ , ์ด์ OOM ์์ธ, ํ์ฌ ์ด์ ๊ธฐ์ค์ ๊ธฐ๋กํฉ๋๋ค.
|
| 6 |
+
|
| 7 |
+
## ํ์ฌ ๊ด์ธก ์ํ
|
| 8 |
+
|
| 9 |
+
ํ์ฌ stage-1 run์ ๋ค์ ์ค์ ์ผ๋ก ์ ์ ํ์ต ์ค์
๋๋ค.
|
| 10 |
+
|
| 11 |
+
| ํญ๋ชฉ | ๊ฐ |
|
| 12 |
+
|---|---:|
|
| 13 |
+
| GPU | 8 x NVIDIA H200 |
|
| 14 |
+
| GPU utilization | 8์ฅ ๋ชจ๋ 99% |
|
| 15 |
+
| global batch | 180,224 tokens |
|
| 16 |
+
| local token slots/GPU | 22,528 |
|
| 17 |
+
| context | 4,096 |
|
| 18 |
+
| VRAM | GPU0 ์ฝ 129.9GB, ๋๋จธ์ง ์ฝ 127.6GB / 143.8GB |
|
| 19 |
+
| speed | ์ฝ 1.02 step/sec |
|
| 20 |
+
| checkpoint interval | 5,000 steps |
|
| 21 |
+
|
| 22 |
+
ํ์ฌ ์ค์ ์ ๋น ๋ฅด์ง๋ง ์ฌ์ VRAM์ด ์์ฃผ ๋์ ํธ์ ์๋๋๋ค. H200 ์ฅ๋น ์ฝ 144GB ์ค 127-130GB๋ฅผ ์ฌ์ฉํ๋ฏ๋ก, NCCL/allocator/compiler/cache/checkpoint ์๊ฐ ํผํฌ๊ฐ ๊ฒน์น๋ฉด OOM ์ํ์ด ๋ค์ ์๊ธธ ์ ์์ต๋๋ค.
|
| 23 |
+
|
| 24 |
+
## ์ ํ์ต ์ค VRAM์ด ์ ์ ์ฌ๋ผ๊ฐ๋
|
| 25 |
+
|
| 26 |
+
VRAM ์ฆ๊ฐ๊ฐ ๊ณง๋ฐ๋ก โ๋ฉ๋ชจ๋ฆฌ ๋์โ๋ผ๋ ๋ป์ ์๋๋๋ค. ๋ํ PyTorch/FSDP/compile ํ์ต์์๋ ๋ค์ ์์ธ์ด ๊ฒน์น๋ฉด์ ์ด๋ฐ๋ณด๋ค ๋ค์์ VRAM์ด ๋ ๋์์ง๋ ํจํด์ด ํํฉ๋๋ค.
|
| 27 |
+
|
| 28 |
+
### 1. torch.compile / CUDA graph / kernel cache
|
| 29 |
+
|
| 30 |
+
HRM-Text ์ฝ๋๋ ์ฌ๋ฌ forward/backward path๋ฅผ compileํฉ๋๋ค. ์ด๋ฐ ๋ช step์์๋ ๋ชจ๋ shape/path๊ฐ ์์ง compile๋์ง ์์๊ณ , ํ์ต์ด ์งํ๋๋ฉฐ ์ถ๊ฐ graph, Triton kernel, CUDA kernel cache๊ฐ ๋ง๋ค์ด์ง๋๋ค.
|
| 31 |
+
|
| 32 |
+
ํนํ HRM ๊ตฌ์กฐ๋ H/L recurrent cycle๊ณผ PrefixLM loss๊ฐ ์์ด ๋จ์ decoder-only Transformer๋ณด๋ค compile path๊ฐ ๋ ๋ณต์กํฉ๋๋ค. ์ด๋ฐ VRAM๋ง ๋ณด๊ณ batch๋ฅผ ํฌ๊ฒ ์ก์ผ๋ฉด ํ์ graph๊ฐ ์์ฑ๋ ๋ ์ถ๊ฐ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ชป ๋ฐ์ OOM์ด ๋ ์ ์์ต๋๋ค.
|
| 33 |
+
|
| 34 |
+
### 2. final logits buffer ํฌ๊ธฐ
|
| 35 |
+
|
| 36 |
+
์ด๋ฒ ๋ชจ๋ธ์ vocab์ด 131,072์
๋๋ค. upstream HRM-Text ๋
ผ๋ฌธ ์ค์ ์ 65,536 vocab๋ณด๋ค ๋ ๋ฐฐ์
๋๋ค.
|
| 37 |
+
|
| 38 |
+
batch token slots๊ฐ ์ปค์ง์๋ก final logits ๋๋ loss ๊ณ์ฐ ์ชฝ ์์ ๋ฒํผ๊ฐ ๋งค์ฐ ์ปค์ง๋๋ค.
|
| 39 |
+
|
| 40 |
+
์๋ฅผ ๋ค์ด local token slots/GPU๊ฐ 32,768์ด๋ฉด `32768 x 131072` bf16 logits ๊ณ์ด ๋ฒํผ๊ฐ ํ์ํ ์ ์์ต๋๋ค. ์ด๋ก ์ ๋จ์ผ bf16 dense buffer๋ง ์ก์๋ ์ฝ 8GB ์ด์์ด๊ณ , ์ค์ backward/temporary/parallel buffer๊น์ง ํฉ์น๋ฉด ํจ์ฌ ์ปค์ง๋๋ค.
|
| 41 |
+
|
| 42 |
+
์ด ๋๋ฌธ์ ์ฒ์์๋ `global_batch_size=262144` ๋๋ `229376`์ด ์ ๊น ๋์๊ฐ๋, ๋ค์์ compile graph์ logits/loss ์์ ๋ฒํผ๊ฐ ๊ฒน์น๋ ์๊ฐ OOM์ด ๋ ์ ์์ต๋๋ค.
|
| 43 |
+
|
| 44 |
+
### 3. FSDP2 / optimizer / EMA ์ํ
|
| 45 |
+
|
| 46 |
+
ํ์ฌ ํ์ต์ model weights๋ง ๋ค๊ณ ์๋ ๊ฒ์ด ์๋๋๋ค.
|
| 47 |
+
|
| 48 |
+
- model parameters
|
| 49 |
+
- gradients
|
| 50 |
+
- optimizer state
|
| 51 |
+
- Adam-atan2 state
|
| 52 |
+
- EMA state
|
| 53 |
+
- FSDP shard/all-gather/reduce-scatter buffers
|
| 54 |
+
- recurrent carry ๊ด๋ จ state
|
| 55 |
+
|
| 56 |
+
์ด ์ํ๋ค์ด step๋ง๋ค ํญ์ ๊ฐ์ ์๊ฐ์ ๊ฐ์ ํฌ๊ธฐ๋ก ๋ณด์ด๋ ๊ฒ์ ์๋๋๋ค. ํน์ backward path, optimizer step, checkpoint save ์์ ์ ํผํฌ๊ฐ ์ฌ๋ผ๊ฐ ์ ์์ต๋๋ค.
|
| 57 |
+
|
| 58 |
+
### 4. NCCL communication buffers
|
| 59 |
+
|
| 60 |
+
8 GPU ๋ถ์ฐ ํ์ต์์๋ NCCL ํต์ ๋ฒํผ๊ฐ ํ์ํฉ๋๋ค. all-gather/reduce-scatter ํ์ด๋ฐ, bucket ํฌ๊ธฐ, compile๋ ๊ทธ๋ํ ์คํ ์์์ ๋ฐ๋ผ GPU๋ณ ํผํฌ๊ฐ ๋ค๋ฅด๊ฒ ๋ณด์ผ ์ ์์ต๋๋ค.
|
| 61 |
+
|
| 62 |
+
GPU0์ด ๋ค๋ฅธ GPU๋ณด๋ค ๋ ๋๊ฒ ๋ณด์ด๋ ๊ฒ๋ ์ผ๋ฐ์ ์ผ๋ก ๊ฐ๋ฅํฉ๋๋ค. rank0๊ฐ ๋ก๊น
, ์ผ๋ถ metadata, checkpoint coordination, dataloader/host interaction์ ๋ ๋งก๋ ๊ฒฝ์ฐ๊ฐ ์๊ธฐ ๋๋ฌธ์
๋๋ค.
|
| 63 |
+
|
| 64 |
+
### 5. CUDA caching allocator
|
| 65 |
+
|
| 66 |
+
`nvidia-smi`์ used memory๋ โํ์ฌ ํ
์๊ฐ ์ค์ ๋ก ์ฐ๋ ๋ฉ๋ชจ๋ฆฌโ๋ง ๋ปํ์ง ์์ต๋๋ค. PyTorch CUDA allocator๊ฐ ํ ๋ฒ ํ๋ณดํ ๋ธ๋ก์ ์ฌ์ฌ์ฉํ๋ ค๊ณ ์บ์์ ์ก๊ณ ์์ผ๋ฉด `nvidia-smi`์๋ ๊ณ์ ์ฌ์ฉ ์ค์ฒ๋ผ ๋ณด์
๋๋ค.
|
| 67 |
+
|
| 68 |
+
๋ฐ๋ผ์ step์ด ์งํ๋ ์๋ก used memory๊ฐ ์ฌ๋ผ๊ฐ๊ณ ์ ๋ด๋ ค๊ฐ์ง ์๋ ๊ฒ์ ์ ์์ผ ์ ์์ต๋๋ค. ์ค์ํ ๊ฒ์ reserved๊ฐ ๊ณ์ ๋ฌดํ ์ฆ๊ฐํ๋์ง, ๋๋ ํน์ step ์ดํ ์์ plateau๋ฅผ ๋ง๋๋์ง์
๋๋ค.
|
| 69 |
+
|
| 70 |
+
### 6. checkpoint ์ ์ฅ ์ ์๊ฐ ํผํฌ
|
| 71 |
+
|
| 72 |
+
FSDP2 checkpoint ์ ์ฅ ์ `.distcp` shard, metadata, state_dict materialization, host/device transfer๊ฐ ๊ฒน์นฉ๋๋ค. ์ ์ฅ ์์ฒด๋ ์ฃผ๋ก CPU/disk ์์
์ด์ง๋ง, ์ ์ฅ ์ง์ /์งํ ๋ชจ๋ธ state ์ ๊ทผ ๋๋ฌธ์ GPU/CPU ๋ฉ๋ชจ๋ฆฌ ํผํฌ๊ฐ ์๊ธธ ์ ์์ต๋๋ค.
|
| 73 |
+
|
| 74 |
+
๊ทธ๋์ ๋๋ฌด ์ฆ์ checkpoint ์ ์ฅ์ ๋ค์ ๋ฌธ์ ๋ฅผ ๋ง๋ญ๋๋ค.
|
| 75 |
+
|
| 76 |
+
- step ์ฒ๋ฆฌ ์ง์ฐ
|
| 77 |
+
- ๋์คํฌ ์ฌ์ฉ๋ ๊ธ์ฆ
|
| 78 |
+
- HF upload ๋ฐ scan ๋น์ฉ ์ฆ๊ฐ
|
| 79 |
+
- ์ ์ฅ ์์ ํผํฌ ๋ฉ๋ชจ๋ฆฌ ์ฆ๊ฐ
|
| 80 |
+
|
| 81 |
+
ํ์ฌ 5,000 step๋ง๋ค ์ฝ 21GB๊ธ FSDP2 checkpoint๊ฐ ์๊น๋๋ค. 500 step๋ง๋ค ์ ์ฅํ๋ฉด stage-1 ๊ธฐ์ค์ผ๋ก ์ฒดํฌํฌ์ธํธ ์์ ์ ์ฅ ๋ถํ๊ฐ 10๋ฐฐ ๋์ด ๊ณผํฉ๋๋ค.
|
| 82 |
+
|
| 83 |
+
## ์ด์ OOM ์์ธ
|
| 84 |
+
|
| 85 |
+
์ด์ OOM์ batch๋ฅผ ํฌ๊ฒ ์ก์์ ๋ ์ด๋ฐ ๊ด์ธก VRAM๋ง ๋ณด๊ณ โ๊ด์ฐฎ๋คโ๊ณ ํ๋จํ ๊ฒ์ด ์์ธ์
๋๋ค.
|
| 86 |
+
|
| 87 |
+
ํต์ฌ์ ๋ค์์
๋๋ค.
|
| 88 |
+
|
| 89 |
+
1. vocab 131K๋ผ logits/loss ๊ด๋ จ ์์ ๋ฒํผ๊ฐ ํฝ๋๋ค.
|
| 90 |
+
2. HRM recurrent compile path๊ฐ ์ด๋ฐ ๋ช step ๋ค ์ถ๊ฐ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์๊ตฌํฉ๋๋ค.
|
| 91 |
+
3. H200 8์ฅ์ด๋ผ compute๋ ์ถฉ๋ถํ์ง๋ง, 1.4B + 131K vocab + EMA + optimizer + FSDP2 ์กฐํฉ์์๋ batch๋ฅผ ๋๋ฌด ํฌ๊ฒ ์ก์ผ๋ฉด ํ๋ฐ ํผํฌ๊ฐ ๊ฑธ๋ฆฝ๋๋ค.
|
| 92 |
+
4. `global_batch_size=262144`, `229376`์ ์ด๋ฐ์๋ ๊ฐ๋ฅํด ๋ณด์์ง๋ง ์์ ๋ง์ง์ด ๋ถ์กฑํ์ต๋๋ค.
|
| 93 |
+
|
| 94 |
+
ํ์ฌ๋ `global_batch_size=180224`๋ก ๋ด๋ ค ์์ ์งํ ์ค์
๋๋ค.
|
| 95 |
+
|
| 96 |
+
## ์ด์ ๊ธฐ์ค
|
| 97 |
+
|
| 98 |
+
ํ์ฌ stage-1์์๋ GPU๋ฅผ ๋๋ฆฌ์ง ์๋ ๊ฒ์ด ์ฐ์ ์ด์ง๋ง, OOM์ผ๋ก run์ด ์ฃฝ์ผ๋ฉด ์ฌ์์/๊ฒ์ฆ/์ฒดํฌํฌ์ธํธ ์ ๋ฆฌ ๋น์ฉ์ด ๋ ํฝ๋๋ค.
|
| 99 |
+
|
| 100 |
+
๊ถ์ฅ ๊ธฐ์ค:
|
| 101 |
+
|
| 102 |
+
| ํญ๋ชฉ | ๊ธฐ์ค |
|
| 103 |
+
|---|---|
|
| 104 |
+
| primary batch | `global_batch_size=180224` |
|
| 105 |
+
| ์ ์ฅ ์ฃผ๊ธฐ | `checkpoint_step_interval=5000` |
|
| 106 |
+
| ๋ก์ปฌ ๋ณด๊ด | ์ต์ 2-3๊ฐ checkpoint๋ง ์ ์ง |
|
| 107 |
+
| HF main repo | ์ต์ safetensors export ์ค์ฌ |
|
| 108 |
+
| HF raw repo | resume๊ฐ ํ์ํ FSDP2 checkpoint๋ง ๋ณ๋ ๋ณด๊ด |
|
| 109 |
+
| OOM ์ฌ๋ฐ ์ | batch๋ฅผ 5-10% ๋ฎ์ถ๊ณ ๊ฐ์ resume checkpoint์์ ์ฌ์์ |
|
| 110 |
+
|
| 111 |
+
## 500 step checkpoint๊ฐ ๊ณผํ ์ด์
|
| 112 |
+
|
| 113 |
+
500 step๋ง๋ค ์ ์ฅํ๋ฉด ๋ค์ ๋ฌธ์ ๊ฐ ์๊น๋๋ค.
|
| 114 |
+
|
| 115 |
+
- ํ์ฌ FSDP2 checkpoint ํ๋๊ฐ ์ฝ 21GB์
๋๋ค.
|
| 116 |
+
- 500 step ๊ฐ๊ฒฉ์ด๋ฉด 10,000 step๋ง๋ค ์ฝ 20๊ฐ, ์ฆ ์ฝ 420GB๊ฐ ์๊น๋๋ค.
|
| 117 |
+
- stage-1 ์ ์ฒด 88,522 step ๊ธฐ์ค์ผ๋ก๋ ๋จ์ ๊ณ์ฐ์ 170๊ฐ ์ด์์ด ์๊ฒจ ์ TB๊ฐ ๋ฉ๋๋ค.
|
| 118 |
+
- ์ ์ฅ ์์ฒด๊ฐ ํ์ต ๋ฃจํ๋ฅผ ๋ฐฉํดํ๊ณ , HF ์
๋ก๋/์ค์บ๋ ์ปค์ง๋๋ค.
|
| 119 |
+
|
| 120 |
+
๋ฐ๋ผ์ ํ์ฌ์ฒ๋ผ 5,000 step ๊ฐ๊ฒฉ์ผ๋ก ์ ์ฅํ๊ณ , ๋ก์ปฌ์ ์ต์ 2-3๊ฐ๋ง ๋จ๊ธฐ๋ ํธ์ด ๋ง์ต๋๋ค.
|
| 121 |
+
|
| 122 |
+
## ๋ค์ batch ์กฐ์ ํ๋จ
|
| 123 |
+
|
| 124 |
+
ํ์ฌ VRAM ์ฌ์ฉ๋์ ๋์ง๋ง ํ์ต ์๋๋ ์์ ์ ์
๋๋ค.
|
| 125 |
+
|
| 126 |
+
๋ค์ stage์์ batch๋ฅผ ์ฌ๋ฆฌ๊ณ ์ถ์ผ๋ฉด ํ ๋ฒ์ ํฌ๊ฒ ์ฌ๋ฆฌ์ง ๋ง๊ณ ๋ค์ ์์๊ฐ ๋ซ์ต๋๋ค.
|
| 127 |
+
|
| 128 |
+
1. `global_batch_size=180224`๋ก ์์ ์๋ฃ ํ์ธ
|
| 129 |
+
2. ๋ค์ dataset stage์์ `196608` ํ
์คํธ
|
| 130 |
+
3. 2-3์ฒ step ์ด์ VRAM plateau ํ์ธ
|
| 131 |
+
4. checkpoint ์ ์ฅ ์์ ๊น์ง ํต๊ณผํ๋ฉด ์ ์ง
|
| 132 |
+
5. OOM ๋๋ ํผํฌ ๋ถ์์ ์ ์ฆ์ `180224` ๋๋ `172032`๋ก ๋ณต๊ท
|
| 133 |
+
|
| 134 |
+
๋
ผ๋ฌธ ์ค์ ๊ณผ ๋น๊ตํ๋ฉด H200 8์ฅ์ ๊ฐํ์ง๋ง, ์ด๋ฒ ๋ชจ๋ธ์ vocab์ด 131K๋ผ upstream๊ณผ ๋ฉ๋ชจ๋ฆฌ ๊ตฌ์กฐ๊ฐ ๋ค๋ฆ
๋๋ค. ๋ฐ๋ผ์ โH200์ด๋๊น ๋ฌด์กฐ๊ฑด H100 16์ฅ batch๋ฅผ ๋๊ธด๋คโ๋ ์์ผ๋ก ์ก์ผ๋ฉด ์์ ์ฑ์ด ๋จ์ด์ง๋๋ค.
|
| 135 |
+
|
| 136 |
+
## ๊ฒฐ๋ก
|
| 137 |
+
|
| 138 |
+
ํ์ฌ VRAM ์์น์ torch compile/cache, 131K vocab logits buffer, FSDP2/optimizer/EMA/NCCL buffer, checkpoint ์๊ฐ ํผํฌ๊ฐ ๊ฒน์น ๊ฒฐ๊ณผ๋ก ๋ณด๋ ๊ฒ์ด ๋ง์ต๋๋ค.
|
| 139 |
+
|
| 140 |
+
ํ์ฌ `global_batch_size=180224`, 5,000 step checkpoint, ์ต์ 2-3๊ฐ ๋ณด๊ด ์ ์ฑ
์ ๋น ๋ฅธ ํ์ต๊ณผ OOM ํํผ ์ฌ์ด์ ํ์ค์ ์ธ ๊ท ํ์
๋๋ค. ํ์ต์ด ์์ ํ ์์ plateau๋ฅผ ๋ณด์ด๋ฉด ๋ค์ stage์์๋ง ์ํญ ์ฆ๋์ ๊ฒํ ํฉ๋๋ค.
|
| 141 |
+
|