MiniMind
MiniMind 部署:从 checkpoint、GPU 训练到 OpenAI 兼容服务
覆盖 Python/PyTorch 环境、单卡或多卡训练、checkpoint 管理、API 服务和评估。

你将学会
- Design a pinned MiniMind deployment
- Choose single- or multi-GPU topology
- Serve and recover a verified checkpoint
开始前需要
- Basic Git and command-line usage
- Comfort reading a project README
You can explain the project, run its documented first step, and decide what to verify before adopting it.
先看结论
- Pin environment, data, seed, hardware, tokenizer, and checkpoint before scaling.
- Separate single-process smoke tests from DDP/DeepSpeed production jobs.
- Serve read-only verified checkpoints on localhost first and preserve rollback evidence.
Pin the experiment before scaling
MiniMind 部署应先固定 Python/PyTorch、数据、seed、GPU 与 checkpoint,再区分 Streamlit 推理、单进程训练、DDP/DeepSpeed 和 OpenAI-compatible 服务。将模型目录设为只读、服务绑定 localhost,并保留训练配置、评估集和恢复记录,避免把特定 SFT 测量当作通用承诺。
The README's headline of two hours and three yuan qualifies a specific one-epoch SFT measurement on one NVIDIA 3090. Treat it as a reference point, not a universal deployment budget for every dataset, stage, or accelerator.
Choose the training topology
Use one process for a smoke test, then move to DDP or DeepSpeed only when data, checkpoint, and evaluation paths are stable. Record batch size, sequence length, gradient accumulation, precision, worker count, and checkpoint cadence. A multi-GPU run with different effective batch or data order is a different experiment.
Keep data and checkpoints on explicit volumes with enough space for resume and rollback. Verify that interrupted jobs leave a complete checkpoint and that a resumed run records the exact step and optimizer state.
Serve a verified checkpoint
The repository documents a lightweight `scripts/serve_openai_api.py` service and a Streamlit `web_demo.py`. Bind the API to localhost during evaluation, expose a read-only model directory, and test a basic request before streaming, `reasoning_content`, or `tool_calls` extensions.
Record model revision, tokenizer, decoding settings, request ID, latency, token counts, and errors without persisting prompts unless policy allows it. An OpenAI-compatible schema is an integration convenience, not a guarantee of frontier quality or safe tool execution.
Operate and recover
Monitor GPU memory, disk, checkpoint age, request latency, error rates, and evaluation drift. Keep a known-good checkpoint and environment lockfile, rehearse rollback, and document whether a model is for education, research, or a constrained internal service. Validate licensing and data provenance before serving beyond a private lab.
如何选择
| 比较维度 | 方案 A | 方案 B |
|---|---|---|
| Best when | You need predictable behavior and easy auditing | You need adaptive optimization and have reliable telemetry |
| Main risk | May leave performance on the table | Can become difficult to explain or debug |
实施步骤
- 1
Create a pinned Python/PyTorch environment and record the fixture.
- 2
Run one-process inference/training, then scale with explicit DDP/DeepSpeed settings.
- 3
Serve a verified checkpoint locally and test basic plus optional response fields.
- 4
Monitor resources, evaluate drift, and rehearse checkpoint/environment rollback.
可复制示例
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
torchrun --nproc_per_node 1 train_full_sft.py
cd scripts && python serve_openai_api.py常见问题
Can the README's two-hour figure size a production job?
No. It describes a specific SFT measurement on one 3090; measure your data, stage, hardware, and review workload.
Should the API bind to all interfaces by default?
Start on localhost with a read-only model directory, then add authentication and network controls before any wider exposure.
资料来源
- MiniMind README (captured 2026-08-31)来源核查 2026-08-31
- MiniMind repository来源核查 2026-08-31