Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7cd99fc
Fix typo environment variable and unbuffer python outputs
fzyzcjy Jul 28, 2026
c17b023
Add a shell launch script test harness for future protection
fzyzcjy Jul 28, 2026
0e26739
Fix various launch scripts errors about missing line concatenations o…
fzyzcjy Jul 26, 2026
b68927a
Derive the miles checkout location instead of hardcoding it in launch…
fzyzcjy Jul 26, 2026
bc3e351
Snapshot the external commands of every shell launch script
fzyzcjy Jul 28, 2026
7fd6269
Read the slurm allocation when the train config is built
fzyzcjy Jul 28, 2026
de49808
Snapshot the commands and generated configs of every python launch sc…
fzyzcjy Jul 28, 2026
0675ed7
Cover the public surface of command_utils with unit tests
fzyzcjy Jul 28, 2026
e3a1b0b
Rename exec_command by the resource its command needs
fzyzcjy Jul 28, 2026
84de461
Move the shell exec helpers next to their only consumers
fzyzcjy Jul 27, 2026
574415b
Remove non-reproducible file arguments by supporting inline base64 pa…
fzyzcjy Jul 28, 2026
e454b3d
Snapshot the launchers that build their own command line
fzyzcjy Jul 28, 2026
4e3fcfd
Fix p2p profile's rotary_base not reaching the model script it config…
fzyzcjy Jul 28, 2026
f9ce73b
Snapshot test the argv of all model scripts
fzyzcjy Jul 28, 2026
08b5d3b
Expand the model args in python before building the command
fzyzcjy Jul 28, 2026
c77d60a
Replace the model config shell scripts with python
fzyzcjy Jul 28, 2026
573e2e8
Merge origin/main into op8-11 (reconcile)
fzyzcjy Aug 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 3 additions & 8 deletions docker/npu_patch/miles.patch
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ diff --git a/miles/utils/external_utils/command_utils.py b/miles/utils/external_
index d016e01ac..08b4d6eff 100644
--- a/miles/utils/external_utils/command_utils.py
+++ b/miles/utils/external_utils/command_utils.py
@@ -193,6 +193,112 @@ def execute_train(
@@ -193,6 +193,107 @@ def execute_train(
)


Expand Down Expand Up @@ -434,18 +434,13 @@ index d016e01ac..08b4d6eff 100644
+ )
+
+ if get_bool_env_var("SLIME_SCRIPT_ENABLE_RAY_SUBMIT", "1"):
+ cmd_megatron_model_source = (
+ f'source "{repo_base_dir}/scripts/models/{megatron_model_type}.sh" && '
+ if megatron_model_type is not None
+ else ""
+ )
+ model_args = load_model_args(megatron_model_type) if megatron_model_type is not None else ""
+ exec_command_cpu(
+ f"export no_proxy=127.0.0.1 && export PYTHONUNBUFFERED=1 && "
+ f"{cmd_megatron_model_source}"
+ f'ray job submit --address="http://127.0.0.1:8265" '
+ f"--runtime-env-json='{runtime_env_json}' "
+ f"-- python3 {train_script} "
+ f"{'${MODEL_ARGS[@]}' if megatron_model_type is not None else ''} "
+ f"{model_args} "
+ f"{train_args}"
+ )
+
Expand Down
3 changes: 2 additions & 1 deletion docs/advanced/on-policy-distillation.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ hf download --repo-type dataset zhuzilin/dapo-math-17k --local-dir /root/dapo-ma

# 2. Convert student model
cd /root/miles
source scripts/models/qwen3-8B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-8B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen3-8B \
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/openhermes-sft.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ If you don't already have it:
hf download Qwen/Qwen3-4B-Base --local-dir /root/Qwen3-4B-Base

cd /root/miles
source scripts/models/qwen3-4B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-4B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen3-4B-Base \
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/reproducibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ hf download --repo-type dataset openai/gsm8k --local-dir /root/gsm8k
hf download Qwen/Qwen2.5-0.5B-Instruct --local-dir /root/Qwen2.5-0.5B-Instruct

cd /root/miles
source scripts/models/qwen2.5-0.5B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen2.5-0.5B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen2.5-0.5B-Instruct \
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/search-r1.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ python $WORK_DIR/scripts/data_process/qa_search_train_merge.py \
```bash
hf download Qwen/Qwen2.5-3B --local-dir /root/Qwen2.5-3B
cd /root/miles
source scripts/models/qwen2.5-3B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen2.5-3B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen2.5-3B \
Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ map the HuggingFace weights into a sharded `torch_dist` checkpoint.

```bash
cd /root/miles
source scripts/models/qwen3-4B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-4B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"

PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/deepseek/deepseek-v4-flash.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ python tools/fp8_cast_bf16.py \
--input-fp8-hf-path /root/models/DeepSeek-V4-Flash-FP8 \
--output-bf16-hf-path /root/models/DeepSeek-V4-Flash-FP8-bf16/

source scripts/models/deepseek-v4-flash.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py deepseek-v4-flash)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun \
--nproc-per-node 4 --nnodes 8 \
--master-addr ${MASTER_ADDR} --master-port 12345 \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/deepseek/deepseek.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Then convert BF16 HF → Megatron `torch_dist`. Run on **4 separate nodes** (`NO

```bash
cd miles/
source scripts/models/deepseek-v3.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py deepseek-v3)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM/ torchrun \
--nproc-per-node 8 \
--master-addr ${MASTER_ADDR} --master-port 12345 \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/glm/glm4-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ The bash launcher does **not** convert for you — produce `$BASE_DIR/GLM-4.5-35

```bash
cd /root/miles
source scripts/models/glm4.5-355B-A32B.sh
MODEL_ARGS_LINE="$(python3 scripts/model_args.py glm4.5-355B-A32B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/glm/glm4-7-flash.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The bash launcher hardcodes `BASE_DIR=/root/shared`. The Python launcher downloa

```bash
cd /root/miles
source scripts/models/glm4.7-flash.sh
MODEL_ARGS_LINE="$(python3 scripts/model_args.py glm4.7-flash)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/glm/glm4.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/glm4-9B.sh
MODEL_ARGS_LINE="$(python3 scripts/model_args.py glm4-9B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/GLM-Z1-9B-0414 \
Expand Down
4 changes: 2 additions & 2 deletions docs/models/kimi/kimi-k2.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Kimi K2.5 / K2.6
description: Launch recipe for Kimi-K2.5, running full-parameter GRPO on 32 × 8 H200 with an INT4 actor and a BF16 reference.
---
The reference launcher is [`scripts/run-kimi-k25.sh`](https://github.com/radixark/miles/blob/main/scripts/run-kimi-k25.sh), which sources the shared model definition in `scripts/models/kimi-k2-thinking.sh`.
The reference launcher is [`scripts/run-kimi-k25.sh`](https://github.com/radixark/miles/blob/main/scripts/run-kimi-k25.sh), which loads the shared model definition from `scripts/models/kimi-k2-thinking.py`.

## 1. Model Introduction

Expand Down Expand Up @@ -79,7 +79,7 @@ ray start --address=${MASTER_ADDR}:6379 --num-gpus 8 --node-ip-address ${WORKER_

## 4. Script breakdown

The launcher groups its flags into the arrays that are passed to `train.py`. The model shape comes from `MODEL_ARGS`, which is sourced from `scripts/models/kimi-k2-thinking.sh`. That definition sets the MLA latent ranks (`q_lora_rank=1536`, `kv_lora_rank=512`, `qk_head_dim=128`, `qk_pos_emb_head_dim=64`, `v_head_dim=128`), the MoE routing (384 experts, top-8, sigmoid pre-softmax scoring, FP32 router, `--moe-router-topk-scaling-factor 2.827`), and RoPE (`--rotary-base 50000`, `--rotary-scaling-factor 64.0`). The K2.5 recipe then layers the following on top:
The launcher groups its flags into the arrays that are passed to `train.py`. The model shape comes from `MODEL_ARGS`, which is loaded from `scripts/models/kimi-k2-thinking.py`. That definition sets the MLA latent ranks (`q_lora_rank=1536`, `kv_lora_rank=512`, `qk_head_dim=128`, `qk_pos_emb_head_dim=64`, `v_head_dim=128`), the MoE routing (384 experts, top-8, sigmoid pre-softmax scoring, FP32 router, `--moe-router-topk-scaling-factor 2.827`), and RoPE (`--rotary-base 50000`, `--rotary-scaling-factor 64.0`). The K2.5 recipe then layers the following on top:

- **`CKPT_ARGS`** wires up the dual checkpoint (INT4 actor via `--hf-checkpoint`, BF16 reference via `--ref-load`) together with `--megatron-to-hf-mode bridge` and `--model-name kimi_k25`.
- **`ROLLOUT_ARGS`** and **`EVAL_ARGS`** configure GRPO sampling and periodic AIME evaluation (covered in §5.2).
Expand Down
3 changes: 2 additions & 1 deletion docs/models/kimi/kimi-k2.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Convert across 4 nodes (mirror the DeepSeek-V3 procedure):

```bash
cd /root/miles
source scripts/models/kimi-k2.sh # or kimi-k2-thinking.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py kimi-k2)" || exit 1 # or kimi-k2-thinking
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM/ torchrun \
--nproc-per-node 8 \
--master-addr ${MASTER_ADDR} --master-port 12345 \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/kimi/moonlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/moonlight.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py moonlight)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/mimo/mimo.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/mimo-7B-rl.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py mimo-7B-rl)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/MiMo-7B-RL \
Expand Down
2 changes: 1 addition & 1 deletion docs/models/nemotron/nemotron-3-nano-moe.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ memory pressure rises.

### 5.5 Notable quirks

From `scripts/models/nemotron-3-nano-30b-a3b.sh` and `scripts/run-nemotron-3-nano-30b-a3b.sh`:
From `scripts/models/nemotron-3-nano-30b-a3b.py` and `scripts/run-nemotron-3-nano-30b-a3b.sh`:

- **No `--spec`**: AutoBridge + the NemotronH shim synthesize the Megatron MoE spec from HF config.
- 128 experts, `--moe-router-topk 6`, shared expert (3712-dim).
Expand Down
2 changes: 1 addition & 1 deletion docs/models/nemotron/nemotron-3-nano.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ memory pressure rises.

### 5.5 Notable quirks

From `scripts/models/nemotron-3-nano-4b.sh` and `scripts/run-nemotron-3-nano-4b.sh`:
From `scripts/models/nemotron-3-nano-4b.py` and `scripts/run-nemotron-3-nano-4b.sh`:

- **No `--spec`**: the AutoBridge synthesizes the Megatron spec from HF config.
- `--position-embedding-type none` (no RoPE).
Expand Down
5 changes: 3 additions & 2 deletions docs/models/qwen/qwen3-5-moe.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/qwen3.5-35B-A3B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3.5-35B-A3B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down Expand Up @@ -98,7 +99,7 @@ CPU Adam is enabled (`--optimizer-cpu-offload --overlap-cpu-optimizer-d2h-h2d --
### 5.5 Notable quirks

- The Megatron side uses `--moe-token-dispatcher-type flex`; DeepEP isn't enabled here, unlike Qwen3-Next.
- The model config (`scripts/models/qwen3.5-35B-A3B.sh`) reuses the Qwen3.5 spec: `--attention-output-gate`, `--rotary-base 10000000`, `--rotary-percent 0.25`, `A_log` kept in FP32 via the bridge. See [Backends Beyond Megatron](/advanced/architecture-support).
- The model config (`scripts/models/qwen3.5-35B-A3B.py`) reuses the Qwen3.5 spec: `--attention-output-gate`, `--rotary-base 10000000`, `--rotary-percent 0.25`, `A_log` kept in FP32 via the bridge. See [Backends Beyond Megatron](/advanced/architecture-support).

## 6. Pairs Well With

Expand Down
5 changes: 3 additions & 2 deletions docs/models/qwen/qwen3-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/qwen3.5-4B.sh # or qwen3.5-9B.sh / qwen3.5-27B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3.5-4B)" || exit 1 # or qwen3.5-9B / qwen3.5-27B
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen3.5-4B \
Expand Down Expand Up @@ -92,7 +93,7 @@ Only the 27 B script enables CPU Adam (`--optimizer-cpu-offload --overlap-cpu-op

### 5.5 Notable quirks

From `scripts/models/qwen3.5-4B.sh` (and analogous configs for 9 B / 27 B):
From `scripts/models/qwen3.5-4B.py` (and analogous configs for 9 B / 27 B):

- `--spec miles_plugins.models.qwen3_5 get_qwen3_5_spec` — attention-output gate, `A_log` parameter handling.
- `--rotary-base 10000000`, `--rotary-percent 0.25`.
Expand Down
5 changes: 3 additions & 2 deletions docs/models/qwen/qwen3-6-moe.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ hf download Qwen/Qwen3.6-35B-A3B --local-dir /root/models/Qwen3.6-35B-A3B

```bash
cd /root/miles
source scripts/models/qwen3.6-35B-A3B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3.6-35B-A3B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down Expand Up @@ -136,7 +137,7 @@ CPU Adam is enabled (`--optimizer-cpu-offload --overlap-cpu-optimizer-d2h-h2d --

### 5.5 Notable quirks

From `scripts/models/qwen3.6-35B-A3B.sh` and `scripts/run_qwen3_6_35b_a3b_mtp.py`:
From `scripts/models/qwen3.6-35B-A3B.py` and `scripts/run_qwen3_6_35b_a3b_mtp.py`:

- `--spec miles_plugins.models.qwen3_5 get_qwen3_5_spec` — Qwen3.6 reuses the Qwen3.5 spec.
- 256 experts, `--moe-router-topk 8`, `--moe-router-score-function softmax`.
Expand Down
5 changes: 3 additions & 2 deletions docs/models/qwen/qwen3-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/qwen3.6-27B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3.6-27B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen3.6-27B \
Expand Down Expand Up @@ -109,7 +110,7 @@ CPU Adam is enabled (`--optimizer-cpu-offload --overlap-cpu-optimizer-d2h-h2d --

### 5.5 Notable quirks

From `scripts/models/qwen3.6-27B.sh`:
From `scripts/models/qwen3.6-27B.py`:

- `--spec miles_plugins.models.qwen3_5 get_qwen3_5_spec` — Qwen3.6 reuses the Qwen3.5 spec (gated attention, FP32 `A_log`).
- `--rotary-base 10000000`, `--rotary-percent 0.25`.
Expand Down
3 changes: 2 additions & 1 deletion docs/models/qwen/qwen3-moe.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ hf download Qwen/Qwen3-235B-A22B-FP8 --local-dir $BASE_FOLDER/Qwen3-235B-A22B-FP
### 3.3 HF → Megatron `torch_dist` conversion

```bash
source scripts/models/qwen3-30B-A3B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-30B-A3B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down
3 changes: 2 additions & 1 deletion docs/models/qwen/qwen3-next.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir $BASE_FOLDER/

```bash
cd /root/miles
source scripts/models/qwen3-next-80B-A3B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-next-80B-A3B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM torchrun --nproc-per-node 8 \
tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
Expand Down
7 changes: 4 additions & 3 deletions docs/models/qwen/qwen3.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ hf download --repo-type dataset zhuzilin/aime-2024 --local-dir /root/aime-20

```bash
cd /root/miles
source scripts/models/qwen3-4B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-4B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
PYTHONPATH=/root/Megatron-LM python tools/convert_hf_to_torch_dist.py \
${MODEL_ARGS[@]} \
--hf-checkpoint /root/Qwen3-4B \
Expand All @@ -57,9 +58,9 @@ cd /root/miles
bash scripts/run-qwen3-4B.sh
```

Other variants follow the same pattern — replace the script name (`run-qwen3-32B.sh`, etc.) and the `qwen3-XB.sh` model config.
Other variants follow the same pattern — replace the script name (`run-qwen3-32B.sh`, etc.) and the `qwen3-XB.py` model config.

The Qwen3-4B-Instruct-2507 config (`scripts/models/qwen3-4B-Instruct-2507.sh`) just sets `MODEL_ARGS_ROTARY_BASE=5000000` and re-sources `qwen3-4B.sh` — source it when converting / launching the Instruct-2507 checkpoint.
The Qwen3-4B-Instruct-2507 config (`scripts/models/qwen3-4B-Instruct-2507.py`) just calls `qwen3-4B` with `rotary_base=5000000` (`MODEL_ARGS_ROTARY_BASE` still works as an environment override) — load it when converting / launching the Instruct-2507 checkpoint.

## 5. Recipe Configuration

Expand Down
2 changes: 1 addition & 1 deletion docs/models/thinkingmachines/inkling-small.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ python scripts/run_inkling.py train \
--sglang-context-length 4096 --rollout-max-response-len 2048
```

The model definition lives in `scripts/models/inkling-small.sh` (`MODEL_ARGS_NUM_LAYERS` overrides the layer count for sliced smoke/parity checkpoints). HF → `torch_dist` conversion uses the same tool as Inkling with this recipe file — a single 8-GPU node (TP8 EP8) converts it in one pass.
The model definition lives in `scripts/models/inkling-small.py` (`MODEL_ARGS_NUM_LAYERS` overrides the layer count for sliced smoke/parity checkpoints). HF → `torch_dist` conversion uses the same tool as Inkling with this recipe file — a single 8-GPU node (TP8 EP8) converts it in one pass.

## 4. Validated parallelism

Expand Down
5 changes: 3 additions & 2 deletions docs/models/thinkingmachines/inkling.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ Pass `--hf-checkpoint <path>` to the launcher when the weights are already on a

### 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.sh`:
Inkling ships in BF16, so conversion is a single distributed `torch_dist` shard (no precision cast). The model definition comes from `scripts/models/inkling.py`:

```bash
cd /root/miles
source scripts/models/inkling.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py inkling)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
CONVERT_KEEP_PP1=1 PYTHONPATH=/root/Megatron-LM torchrun \
--nproc-per-node 4 --nnodes 4 \
--master-addr ${MASTER_ADDR} --master-port 12345 \
Expand Down
3 changes: 2 additions & 1 deletion docs/platforms/amd.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ ROCm converter is in development.

```bash
cd /root/miles
source scripts/models/qwen3-4B.sh
MODEL_ARGS_LINE="$(python3 miles/utils/external_utils/model_args_utils.py qwen3-4B)" || exit 1
read -ra MODEL_ARGS <<< "${MODEL_ARGS_LINE}"
MEGATRON_LM_PATH=$(pip list | grep megatron-core | awk '{print $NF}')

PYTHONPATH=${MEGATRON_LM_PATH} python tools/convert_hf_to_torch_dist.py \
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/argument-groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ when you need the full default and type for an individual flag.

| Group | Owns | Typical source |
|---|---|---|
| [`MODEL_ARGS`](#model-args) | Architecture constants and plugin specs | `scripts/models/<family>.sh` |
| [`MODEL_ARGS`](#model-args) | Architecture constants and plugin specs | `scripts/models/<family>.py` |
| [`CKPT_ARGS`](#ckpt-args) | Actor, reference, HF tokenizer/config, save paths | Launch script |
| [`ROLLOUT_ARGS`](#rollout-args) | Prompt data, sampling, reward, train/eval batch flow | Launch script |
| [`EVAL_ARGS`](#eval-args) | Evaluation datasets and eval-only sampling overrides | Launch script |
Expand All @@ -24,7 +24,7 @@ when you need the full default and type for an individual flag.
## MODEL_ARGS - architecture constants

`MODEL_ARGS` tells Megatron what model it is instantiating. Megatron cannot infer all
architecture details from a HuggingFace checkpoint, so each recipe sources a matching
architecture details from a HuggingFace checkpoint, so each recipe loads a matching
file from `scripts/models/`.

Common entries:
Expand Down
Loading
Loading