fine-tuning
Route supervised fine-tuning, DeepSpeed, LoRA, data preprocessing, and post-training loading for Baichuan2-7B-Base.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- fine-tuning
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Route supervised fine-tuning, DeepSpeed, LoRA, data preprocessing, and post-training loading for Baichuan2-7B-Base.
- disable-model-invocation
- true
02 资源文件 7
- 参考文档references/data-format.md4.4 KB
- 参考文档references/deepspeed-config.md4.4 KB
- 参考文档references/installation.md3.4 KB
- 参考文档references/troubleshooting.md5.3 KB
- 参考文档references/workflows.md6.1 KB
- 脚本scripts/train_supervised.py13.1 KB
- 脚本scripts/validate_training_data.py12.2 KB
03 SKILL.md 正文
Baichuan2 Fine-Tuning
Use this sub-skill when the task is to prepare, explain, validate, or launch supervised fine-tuning for Baichuan2-7B-Base. It covers the training data format, the bundled supervised trainer, DeepSpeed ZeRO-3 launch structure, multi-machine hostfiles, LoRA toggling, and how to load the saved fine-tuned result.
Do not use this sub-skill for inference demos, chat APIs, quantized loading, or CPU deployment. Route those tasks to the appropriate inference or deployment guidance instead.
Read first
- For an end-to-end run plan, read
references/workflows.md. - For JSON training data requirements and label construction, read
references/data-format.md. - For ZeRO-3 and
ds_configinterpretation, readreferences/deepspeed-config.md. - For dependency expectations and environment checks, read
references/installation.md. - For failure diagnosis, read
references/troubleshooting.md.
Bundled helpers
scripts/validate_training_data.py: validates Belle-style multi-turn JSON, can write a tiny fixture, and can optionally estimate token truncation with a Baichuan tokenizer.scripts/train_supervised.py: self-contained supervised trainer adapted for Baichuan2-7B-Base with schema validation, dry-run mode, DeepSpeed config generation, and LoRA options.
Routing checklist
- Confirm the user is fine-tuning a Base checkpoint, normally
baichuan-inc/Baichuan2-7B-Base, not asking for inference or quantized deployment. - Validate the JSON data before launching any distributed job.
- Decide full-parameter versus LoRA fine-tuning. Use LoRA when VRAM or wall-clock budget is limited, and keep
target_modules=W_packunless the model architecture has been intentionally changed. - Create or verify a DeepSpeed ZeRO-3 config and match it with the Hugging Face
TrainingArgumentsflags. - For one machine, use an empty or omitted hostfile. For multiple machines, prepare a DeepSpeed hostfile with one
hostname slots=Nline per node. - After training, load a full fine-tuned output with
AutoModelForCausalLM.from_pretrained(...); load LoRA adapter output withpeft.AutoPeftModelForCausalLM.from_pretrained(...).
Safe default posture
Before launching training, prefer:
python scripts/validate_training_data.py \
--data_path /path/to/train.json \
--model_max_length 512
python scripts/train_supervised.py \
--dry_run True \
--data_path /path/to/train.json \
--model_name_or_path baichuan-inc/Baichuan2-7B-Base \
--output_dir /path/to/output \
--model_max_length 512
Only move from dry-run validation to DeepSpeed training when dependencies, CUDA visibility, hostfile formatting, and data schema all pass.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).