File size: 10,958 Bytes
dfb775d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ed5275
dfb775d
 
0ed5275
 
 
 
dfb775d
 
0ed5275
 
 
 
 
 
 
 
 
dfb775d
76258e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dfb775d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ed5275
76258e9
 
dfb775d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# CLI reference

The `mindxtrain` Typer app: 9 verbs (8 top-level + a `dataset` subgroup).
Every verb that consumes a YAML config validates it against the
[10-section schema](yaml_schema.md) before doing anything else.

```
mindxtrain [--version] <verb> [options]
```

All verbs dispatch into real Python in the canonical `mindxtrain.*` modules.
Verbs that require optional dependencies surface a clean
`run `uv sync --extra <group>`` hint and exit `3`.

## Global options

| Flag         | Purpose                              |
|--------------|--------------------------------------|
| `--version`  | Print the version and exit.          |
| `--help`     | Show help for the top-level command. |

## `init` β€” scaffold a YAML

Render a built-in recipe to disk.

```
mindxtrain init [--template <name>] [--out <path>] [--list]
```

| Option                | Default              | Description                                      |
|-----------------------|----------------------|--------------------------------------------------|
| `--template`, `-t`    | `qwen3_8b_sft_lora`  | recipe name; see `--list`                        |
| `--out`, `-o`         | `run.yaml`           | output path                                      |
| `--list`              | _flag_               | print every built-in recipe and exit             |

Available recipes (12 total):

```
instella_3b_lora        qwen3_30b_a3b_lora      qwen3_32b_dpo
qwen3_32b_full_fsdp     qwen3_32b_grpo          qwen3_32b_orpo
qwen3_6_27b_lora        qwen3_6_35b_a3b_lora    qwen3_8b_cpt
qwen3_8b_sft_full       qwen3_8b_sft_lora       qwen3_vl_8b_sft
```

```bash
$ uv run mindxtrain init --template qwen3_8b_sft_lora --out run.yaml
wrote run.yaml (2785 bytes, recipe='qwen3_8b_sft_lora')
```

## `bench` β€” run the 60-second AOT autotune probe

The differentiator. See [autotune.md](autotune.md) for probe taxonomy.

```
mindxtrain bench [--gpu N] [--out <path>] [--dry-run]
```

| Option       | Default                | Description                                                         |
|--------------|------------------------|---------------------------------------------------------------------|
| `--gpu`      | `0`                    | HIP/ROCm device index                                               |
| `--out`, `-o`| `autotune_plan.json`   | output path                                                         |
| `--dry-run`  | _flag_                 | skip GPU probes; emit a synthetic reference plan (CPU-safe)         |

`--dry-run` is the CPU-only path used in tests and CI. A real
`mindxtrain bench --gpu 0` requires `torch` (`--extra ml`) and an MI300X
with ROCm 7.2.1; if torch is unavailable, the attention probe gracefully
falls back to the canonical `ck` default.

## `train` β€” dispatch a training run

```
mindxtrain train <config.yaml> [--plan <plan.json>] [--out <run-dir>]
```

| Option       | Default                | Description                                                  |
|--------------|------------------------|--------------------------------------------------------------|
| `--plan`     | (uses dry-run plan)    | autotune plan JSON from `mindxtrain bench`                   |
| `--out`, `-o`| `./out/runs`           | output root for `<run_id>/` directory                        |

Loads the YAML, dispatches to `train.backend` (`axolotl`, `unsloth`,
`torchtune`, `primus`). The Axolotl path subprocess-wraps
`accelerate launch -m axolotl.cli.train`. Plan-derived env vars
(`PYTORCH_ROCM_ARCH=gfx942`, `HSA_NO_SCRATCH_RECLAIM=1`, etc.) are injected
before launch.

Requires `--extra ml` plus the chosen backend on `PATH`.

Exits `3` with a clean install hint if `accelerate` (or the backend) is missing.

## `dataset prep` β€” run the dataset pipeline

```
mindxtrain dataset prep <config.yaml> [--out <dir>]
```

Streams the HF dataset (`datasets`), runs heuristic + optional MinHash/SemDeDup
filters, tokenizes (`AutoTokenizer`), packs to `data.seq_len`, emits sharded
`.tar` files. Pin the resulting tars via
`mindxtrain.storage.lighthouse` or `mindxtrain.storage.ipfs`.

Requires `--extra ml` (datasets, transformers).

## `eval` β€” run lm-evaluation-harness

```
mindxtrain eval <config.yaml> [--checkpoint <path>]
```

| Option       | Default                                           | Description                |
|--------------|---------------------------------------------------|----------------------------|
| `--checkpoint`, `-c` | `./out/runs/<run_name>/checkpoint`        | path to the checkpoint dir |

Subprocess-wraps `lm_eval --model hf --tasks <comma-sep>`. Tasks come from
`cfg.eval.harness.tasks`. Output JSON written under
`<checkpoint>/eval/lm_eval.json`. Summary printed via
`mindxtrain.eval.harness.parse_summary`.

Requires `--extra eval`.

## `quantize` β€” Quark FP8 / MXFP4

```
mindxtrain quantize <config.yaml> [--checkpoint <path>]
```

Wraps `python -m amd_quark.quantize` with `--scheme fp8_e4m3` (default) or
`--scheme mxfp4` (CDNA 4 / MI350X+). Output is a `quantized/` directory next
to the checkpoint, vLLM-loadable.

Requires the `amd-quark` package β€” typically only available inside the
`rocm/primus:v26.2` container or per
[Quark docs](https://quark.docs.amd.com/).

## `serve` β€” launch vLLM / SGLang (default `--to vllm`)

```
mindxtrain serve <config.yaml> [--to vllm|sglang] [--checkpoint <path>] [--tag NAME] [--merge]
                 [--host 127.0.0.1] [--port N] [--dtype auto] [--server-bin PATH]
                 [--server-arg ARG ...] [--ready-timeout 600] [--cpu-kvcache-gib 4]
                 [--register-as-fallback] [--dry-run | --stop]
```

Launches `vllm serve` / `python -m sglang.launch_server` detached (log, pid and `launch.json` under
`out/runs/<run>/serve/<to>/`), serving a LoRA natively over the base (`--merge` merges it first),
waits until `/v1/models` lists the tag (and vLLM's `/health` is 200), and with
`--register-as-fallback` swaps mindX's fallback model to it. `--dry-run` prints the exact argv and
runs nothing; `--stop` sends SIGTERM to the recorded server's process group and verifies it is
gone. On a GPU-less host the CPU backends are used (bfloat16, `VLLM_CPU_KVCACHE_SPACE`,
SGLang `--device cpu`); a quantized checkpoint or `tensor_parallel > 1` is refused there. Exit
codes: 1 checkpoint missing Β· 2 refused (server missing, GPU needed, already running) Β· 3 merge
failed / exited early / error Β· 4 not ready in time (left running). Full page: [serve.md](serve.md).

### `serve --to ollama` / `--to bankml`

```
mindxtrain serve <config.yaml> --to bankml [--tag NAME] [--checkpoint DIR] [--bankml-bin PATH] [--bankml-convert] [--register-as-fallback]
```

`--to ollama` merges the LoRA and runs `ollama create`. `--to bankml` does the same through
[bankml](https://github.com/cryptoAGI/bankml) (`bankml create`, 0.3.5+) and refuses what bankml does
not reproduce β€” see [bankml.md](bankml.md). Exit codes for `--to bankml`: 1 checkpoint missing Β·
2 refused (quantized config, architecture, Modelfile subset, bankml missing or too old) Β·
3 merge or create failed.

## `imprint-bankml` β€” receipt-auditable imprint probes

```
mindxtrain imprint-bankml <config.yaml> --before TAG --after TAG [--n 5] [--seed 0] [--num-predict 48] [--system TEXT] [--base-url URL]
```

Greedy, seeded, unpenalised probes through `bankml serve --native`, scored with `score_imprint`;
every utterance carries bankml's receipt. **Not comparable** with `imprint` (repetition penalty
1.3). Exit 3 on a bankml refusal or error, 4 when no imprint is detected.

## `publish` β€” push to HF + Lighthouse + register

```
mindxtrain publish <config.yaml> --manifest <manifest.json> [--skip-hf] [--skip-pin]
```

1. `mindxtrain.storage.hf_hub.publish_to_hf` β€” uploads the checkpoint dir to
   HuggingFace Hub (uses `HF_TOKEN`). `--skip-hf` to bypass.
2. `mindxtrain.storage.lighthouse.publish_to_lighthouse` β€” pins to
   Lighthouse via direct httpx POST (uses `LIGHTHOUSE_API_KEY`). Falls back
   to a stub `cid://stub-...` derived from the checkpoint's BLAKE3 if the
   key is unset. `--skip-pin` to bypass entirely.
3. `mindxtrain.deploy.api_client.register_with_mindx` β€” POSTs the run-id /
   HF URL / CID to `MINDXTRAIN_API_BASE_URL/v1/agents`. Skipped gracefully
   if the endpoint isn't reachable.
4. The manifest JSON file is updated in-place with the resulting `hf_repo_id`
   and `lighthouse_cid` fields.

## `receipt` β€” verify a provenance manifest

```
mindxtrain receipt <manifest.json> [--config <run.yaml>]
```

Loads the manifest and prints the run-id + BLAKE3 fields. With `--config`,
also re-hashes the on-disk artifacts (`config_yaml`, `dataset`, `checkpoint`,
`eval_json`) and emits a per-field pass/fail dict β€” exits `0` if every hash
verifies, `2` if any drift is detected.

```bash
$ uv run mindxtrain receipt out/runs/<run_id>/manifest.json --config run.yaml
{
  "config_yaml": true,
  "dataset": true,
  "checkpoint": true,
  "eval_json": true
}
```

## Exit-code summary

| Code | Meaning                                                         |
|------|-----------------------------------------------------------------|
| 0    | Success.                                                        |
| 1    | Bad input β€” missing file, hash mismatch, schema error.          |
| 2    | Verify failed β€” at least one BLAKE3 field doesn't match disk.   |
| 3    | Optional dep missing β€” install with `uv sync --extra <group>`.  |

## Where the verbs live

| Verb              | Module                                                                                |
|-------------------|---------------------------------------------------------------------------------------|
| `init`            | `mindxtrain.cli.main.init` + `mindxtrain.config.loader.render_recipe`                 |
| `bench`           | `mindxtrain.cli.main.bench` + `mindxtrain.autotune.benchmark.run_autotune`            |
| `train`           | `mindxtrain.cli.main.train` + `mindxtrain.train.dispatch.dispatch_training`           |
| `dataset prep`    | `mindxtrain.cli.main.dataset_prep` + `mindxtrain.data.{curate,filter,tokenize,pack}`  |
| `eval`            | `mindxtrain.cli.main.eval_` + `mindxtrain.eval.harness.run_lm_eval`                   |
| `quantize`        | `mindxtrain.cli.main.quantize` + `mindxtrain.deploy.quark.quark_fp8`                  |
| `serve --to vllm\|sglang` | `mindxtrain.cli.main._serve_openai_server` + `mindxtrain.deploy.openai_server_push.launch_openai_server` |
| `serve --to bankml` | `mindxtrain.cli.main._serve_bankml` + `mindxtrain.deploy.bankml_push.push_to_bankml` |
| `imprint-bankml`  | `mindxtrain.cli.main.imprint_bankml` + `mindxtrain.eval.imprint_bankml.imprint_via_bankml` |
| `publish`         | `mindxtrain.cli.main.publish` + `mindxtrain.storage.{hf_hub,lighthouse}` + `mindxtrain.deploy.api_client` |
| `receipt`         | `mindxtrain.cli.main.receipt` + `mindxtrain.provenance.verify.verify_receipt`         |