基于 Tmux 的无头 LoRA 微调托管与多路指标遥测
Agent 辅助工程检查
前置要求
第 67 天微调行前检查通过,Linux 进程后台脱机管理基础。
学习目标
在独立的持久化 tmux 会话中启动无头适配器微调,将训练进度多路重定向至结构化遥测流,恪守等待挂机不计入研习时长的原则。
操作指引
1. 在仓库根目录用 tmux new-session -d -s lora_train 启动 projects/lora/train.py(CPU smoke 模式;真实模型运行时将 --smoke 换成 --model
2. 指标多路复用:用 tee 将标准输出写入 lora_training.log;train.py 自身会在每个优化步向
3. 监测物理显存:利用 nvidia-smi 观察显存开销,见证其保持平稳无碎片波动的低显存特性。
4. 坚守学习时长认知:将 GPU 跑计算的机械时间同主动分析指标的有效研习分钟严加区分。
自主演练与记录
启动后台脱机训练。通过 ps 和 tail -f 确认训练在终端登出后平稳推进,并实时录入步级损失数据。
核验 telemetry.jsonl 包含 step, train_loss, lr 等字段。
# 启动命令(在仓库根目录运行):
tmux new-session -d -s lora_train '.venv/bin/python projects/lora/train.py --smoke --data-path data/instruction_sample.jsonl --work-dir runs/lora-detached --max-iters 2000 2>&1 | tee -a lora_training.log'
# 跟踪逐步日志:
tail -f runs/lora-detached/telemetry.jsonl
# 每行示例:{"step": 1, "train_loss": 4.08, "lr": 0.0002, "elapsed_seconds": 0.01, "mode": "smoke"}
成功部署可抵御终端异常断开的持久化 LoRA 微调管道与实时遥测系统。
权威源资源与权利证明
Stanford Alpaca: An Instruction-following LLaMA Model
对应章节 / 时间戳: Training recipe
验证版本与日期: Stanford CRFM Release (Verified: 2026-10-30)
Original open recipe demonstrating lightweight instruction fine-tuning of open models, establishing prompt/response templates, batch scheduling, and learning rate ranges.
Supervised fine-tuning, instruction formatting, and LoRA fundamentals.
Complete instruction templates, JSONL formatting scripts, and learning rate schedules are self-contained in curriculum materials.
对比候选资源与选型分析 (2)
Multi-turn ShareGPT tuning recipe; Alpaca provides simpler, single-turn clarity ideal for foundational instruction tuning study.
Commercially permissive crowdsourced dataset; Alpaca established the academic instruction tuning standard.
LoRA: Low-Rank Adaptation of Large Language Models
对应章节 / 时间戳: N/A
验证版本与日期: ICLR 2022 / arXiv:2106.09685v2 (Verified: 2026-10-30)
Primary literature introducing Low-Rank Adaptation, establishing parameter decomposition W = W0 + (alpha/r)*BA, initialization strategies, and zero inference latency merging.
Matrix factorization, rank, linear layers, and transformer attention.
Complete matrix derivations, tensor dimensions, and pure PyTorch LoRALinear modules are implemented directly in lesson code.
对比候选资源与选型分析 (2)
Introduces bottleneck adapter layers in series, which introduces unavoidable inference latency overhead; LoRA's parallel formulation merges with zero latency.
Prepends virtual prompt tokens; reduces available context length, unlike LoRA which preserves full sequence capacity.