|
Download r18_t4/PATCH_NOTES.md from tchbcb/samai-2b: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/tchbcb/samai-2b/resolve/main/r18_t4/PATCH_NOTES.md
- Command line
-
hf download hf://tchbcb/samai-2b/r18_t4/PATCH_NOTES.md
-
curl -L -o PATCH_NOTES.md https://huggingface.co/tchbcb/samai-2b/resolve/main/r18_t4/PATCH_NOTES.md
1.71 kB
r18 T4 训练补丁说明 (PATCH_NOTES)
原始 r18_train_t4.py 存在 6 个 bug, 修复后才跑通 (修复人: Super Z, 2026-09-15):
- env: peft 0.19.1 版本门 vs 镜像自带 torchao 0.10.0 →
pip uninstall torchao - optimizer:
trainable.append((name, p.numel()))存 int → AdamW TypeError; 改为存 Parameter - r17 LoRA 静默丢失: adapter 键自带
base_model.model.前缀, 脚本又拼一层 → 64 张量全未加载; 改为归一化映射 (剥前缀 + 去.default) - r17 router/mtp 静默丢失: extras 在
get_peft_model之后 load → peft 前缀污染 unexpected=26; 移到 peft 包装前加载 (loaded=26 unexpected=0) - 架构: modeling_samai_pnet.py 两处
create_causal_mask(inputs_embeds=...)与 transformers 5.0.0 不符 (正确参数名input_embeds, 且cache_position必填); 两处修复 + cache_position=None 时物化 - fp16 NaN: T4 无 bf16, 纯 fp16 AdamW 首步即 NaN → 可训练参数升 fp32 主权重 + autocast(fp16) + GradScaler + NaN 批次跳过
配方对齐: epochs 1→2 (对齐 DSW r18_train.sh); 新增双参数组 lr=1.5e-4 (heads) / lr_lora=4e-5 (LoRA) — 原 CFG 的 lr_lora 从未生效。
实测: T4 单卡 peak 9.8GB, ~1.0-1.2s/step, 2 epochs (11258 步) 约 3.5h。
产物:
- ckpt_final/ — r18 增量 (adapter + ponder_head + router), 基于 r17
- r18_train_t4.py — 修复后训练脚本 (含 .bak2 原版备份于运行机)
- modeling_samai_pnet.py — transformers 5.0 兼容版
- r18_train.log — 完整训练日志
- r18_t4_probe.json — T4 侧 r17 vs r18 对比评估
- r18_eval_chain_dsw.py — DSW 官方评估链 (r17 版适配), 需要 zh_cot.eval.jsonl + eval_2b_r5b.json + tb2