File size: 9,172 Bytes
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 | # Architecture
`mindxtrain` is a single-package training framework producing checkpoints with
verifiable provenance, served through an OpenAI-compatible API. The repository
is organized per `docs/blueprints/mindxtrain2.md` Β§Part 4.
```
mindxtrain/
βββ cli/ entry point (typer): init|bench|train|eval|quantize|serve|publish|receipt
βββ config/ Pydantic schema + JSON / YAML loaders
βββ data/ curate -> dedupe -> filter -> tokenize -> pack -> synth -> verify
βββ models/ ModelRegistry + ChatTemplate + per-base presets
βββ train/ sft, dpo, grpo, rlhf, tool_use, distributed, callbacks, recipes/*.yaml
βββ eval/ lighteval, inspect_ai, bfcl, persona/agenda regression, tau_bench, card
βββ autotune/ 60-second AOT MI300X probe (the differentiator)
βββ operator/ FastAPI app, Coach UI, ml-intern patterns (tool_router, agent_loop, β¦)
βββ storage/ StorageProvider interface + local_fs / hf_hub / lighthouse / ipfs
βββ provenance/ TrainingRun manifest, BLAKE3, ERC-8004, Algorand, x402
βββ deploy/ content-addressed registry, hot_swap, ab_test, vllm/sglang launchers, quark
βββ budget/ psutil-derived ResourceBudget + per-provider pricing
```
## The five conceptual layers
The codebase is concentric β each inner layer is consumed by the next, never
the reverse.
```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. CLI layer (typer) β
β init | bench | train | dataset prep | eval | quantize β
β serve | publish | receipt β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. Autotune layer (60s AOT probe β DIFFERENTIATOR) β
β attention_probe (CK vs Triton) β gemm_probe β rccl β
β β β
β AutotunePlan (JSON, AOT β JIT autotune is forbidden) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. Dataset layer β
β HF datasets streaming β MinHash + SemDeDup β packing β
β β FSDP sharding β Lighthouse-pinned CIDs β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4. Training layer (backend dispatch) β
β axolotl β unsloth β torchtune β primus β
β LoRA β QLoRA β full SFT β DPO β ORPO β GRPO β GSPO β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5. Artifact + Integration layer β
β Quark FP8 / MXFP4 β lm-eval-harness β
β β HF Hub push β Lighthouse pin β
β β mindX register β AgenticPlace listing β
β β BANKON ENS subname β x402 Algorand metering β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
The CLI never reaches into the training backend; it consumes the autotune plan
and a Pydantic-validated config and dispatches downward through
`mindxtrain/train/dispatch.py`. The training backend never reaches up to the
CLI; it returns a checkpoint directory that the artifact layer consumes.
## Autotune is the spine
The single architectural choice that distinguishes mindxtrain from Axolotl,
LLaMA-Factory, Unsloth, torchtune and Primus is the autotune layer. It runs a
**60-second MI300X micro-benchmark** (CK-vs-Triton SDPA, hipBLASLt heuristic
check, RCCL bus-bandwidth probe) and emits a static `AutotunePlan` JSON
consumed at training start.
**AOT-only β JIT autotune is forbidden in production.** The plan is fixed at
training start; no Triton / Inductor / MIOpen JIT autotune runs in the live
training loop. This is reproducible, latency-stable, and the point of the
entire framework.
See [autotune.md](autotune.md) for the full probe taxonomy and the
`AutotunePlan` schema.
## MI300X-specific invariants (non-negotiable)
These are encoded in the schema and the recipe library; violating them is a
deployment bug.
1. **FSDP topology must be 1- or 8-GPU** (`hardware.gpus: Literal[1, 8]`). The
2- and 4-GPU groups have asymmetric xGMI bandwidth on MI300X β kills
throughput silently. Enforced by the schema; tested in
`tests/test_config_schema.py`.
2. **`PYTORCH_ROCM_ARCH=gfx942`** must be set; AOTriton compiles for the GPU
arch and `gfx942` is MI300X. Default in every recipe's `train.env`.
3. **`HSA_NO_SCRATCH_RECLAIM=1`** + **`HIP_FORCE_DEV_KERNARG=1`** +
**`GPU_MAX_HW_QUEUES=1`** β the three runtime knobs that make Primus-Turbo
MI300X paths stable. Default in every recipe's `train.env`.
4. **Numpy must be pinned `<2.0`** against `torch==2.9.1+rocm7.2.1.lw`. Pinned
in the project `pyproject.toml`.
5. **Container is `rocm/primus:v26.2`**; SHA256 digest snapshot lives in
`ops/containerfiles/digest.lock`.
## End-to-end data flow
```
examples/demo_qwen3_8b_sft.yaml
β
ββ[parse, validate]ββΊ XTrainConfig (Pydantic v2)
β
ββ[mindxtrain bench]ββΊ AutotunePlan {ck/triton, gemm, rccl, β¦}
β β
β βΌ
ββ[mindxtrain train]βββΊ dispatch_training(cfg, plan, out_dir)
β β
β βΌ (Axolotl YAML, env vars set)
β checkpoint_dir/ + train.log
β β
ββ[mindxtrain eval]ββββββΊ eval.json (lm-eval-harness)
β β
ββ[mindxtrain quantize]ββΊ checkpoint_dir/quantized/ (Quark FP8 PTPC)
β β
ββ[mindxtrain publish]βββΊ Manifest with BLAKE3 of YAML+dataset+
checkpoint+eval, plus HF/Lighthouse/
INFT/ASA pointers
β
βΌ
mindxtrain.operator.app serves the FP8
weights on /v1/chat/completions
```
`mindxtrain receipt` re-hashes the artifacts and verifies the BLAKE3 fields
against the manifest. That round-trip is the cypherpunk2048 reproducibility
guarantee.
## Model strategy (per mindxtrain2.md Β§Part 6)
mindxtrain targets a **family**, not a single flagship: edge β mid β
flagship β specialist. Per the rigorous comparison in
[`blueprints/mindXtrain2.md`](blueprints/mindXtrain2.md) Β§Part 6:
- **Primary base = Qwen3.5** (Apache-2.0, contiguous family from 0.6 B β
235 B β Qwen3.5-122B-A10B; mature PEFT/Axolotl/Unsloth recipes; BFCL
leadership in the Qwen lineage).
- **Specialist track = GLM-5.1** (MIT-licensed weights; SOTA SWE-Bench Pro
58.4; long-horizon agentic reasoning with 200 K-context DSA). Used where
8-hour autonomous SWE sessions matter; otherwise overkill.
- DeepSeek V3.2 / Mistral Large 3 / Phi-4-mini / Gemma 4 are watchlist or
jurisdictional secondary tracks.
The five `mindxtrain.models.{glm51,qwen35,deepseek_v32,mistral3,phi4_mini}.py`
preset modules auto-register on import so `mindxtrain init` and the
`ModelRegistry` know all five from day one.
## Actualization status
The framework ships with **38 modules actualized** as real Python on a
CPU-only laptop, **6 optional-dep groups** (`ml`, `eval`, `data`, `serve`,
`chain`, `obs`) for the heavyweight paths, and **5 cloud-provider stubs**
preserved in `budget/providers/*` for future work. Per-module map at
[actualization_status.md](actualization_status.md).
Verification gate that should always pass on the base install:
```bash
uv run pytest -q # β 564 passed
uv run ruff check . # clean
```
## What lives outside the Python tree
- `contracts/` β Foundry workspace for `mindxtrain_registry.sol` (write-once
anchor) and `x402_receiver.sol` (immutable facilitator). No proxies, no
admin keys, no setters.
- `examples/` β `demo_qwen3_8b_sft.yaml` (the hero config).
- `Containerfile`, `compose.yaml` β top-level Podman / podman-compose entries.
- `ops/` β per-role container files, compose stacks, k8s manifests, vmm and
Gensyn definitions.
- `docs/blueprints/` β the source design briefs the project was built against.
|