457 Commits
Author SHA1 Message Date
jingyaogong 96de8920ad Merge pull request #960 from kustcl/fix/warmup-one-based-steps
[fix] align warmup learning rates with one-based training steps
2026-11-26 16:55:11 +08:00
kustcl 3b254d0adf fix: align warmup with one-based training steps 2026-11-26 16:33:13 +08:00
jingyaogong 858008eb98 [update] readme 2026-11-23 12:00:56 +08:00
jingyaogong 3d85c71e5c [update] sponsorship 2026-11-22 22:31:34 +08:00
jingyaogong 53975ab446 [fix] CPU/Windows compatibility (ref #925) 2026-11-22 22:16:39 +08:00
jingyaogong b16d0b1dc9 [feat] add warmup ratio 2026-11-22 21:24:31 +08:00
jingyaogong 45dfba0ae7 Merge pull request #866 from Linxiushen/feat-get-lr-optional-warmup-narrow
[feat] get_lr 增加可选 warmup_frac 参数(默认关闭,行为逐值不变)
2026-11-22 21:16:50 +08:00
林SO 693de30bc7 Merge upstream master and preserve the optional learning-rate warmup 2026-11-22 20:54:09 +08:00
jingyaogong 2df48b0aa5 [fix] normalize tool calls 2026-11-22 20:27:32 +08:00
jingyaogong 5bd54f38ca Merge pull request #952 from dajiaohuang/fix-agent-tool-error-reporting
[fix] train_agent: 区分「未知工具」与「工具执行失败」,不再把执行异常报成 tool not found
2026-11-22 19:52:48 +08:00
dajiaohuang b9cfefc111 [fix] train_agent: distinguish unknown tools from tool execution failures
rollout_single() built the model-visible observation as

    result_str = json.dumps(result) if result else '{"error": "tool not found"}'

so every falsy return from execute_tool() -- which included every exception
raised by a tool body -- was reported to the policy model as "tool not found".

CHECK_ARGS already guarantees the tool name and argument shape before execution,
so a raise here is a real execution failure (division by zero, math domain
error, non-numeric value), not a lookup miss, and the model was never shown the
actual reason. execute_tool() now returns the error object itself, matching the
observation format the repo already ships in scripts/eval_toolcall.py
({"error": "未知工具: ..."} / {"error": "工具执行失败: ..."}), and rollout_single()
serialises the returned payload verbatim.

Falsy-valued payloads from a tool (e.g. {"value": 0}) are no longer replaced by
the error string either.

Verified on the unmodified base 3eee569 and on this branch with the same
16-check script: 4 checks fail before, all pass after. Successful calls,
the six-tool registry, the falsy-payload path and calculate_rewards() output
are unchanged (reward +0.467 both before and after).
2026-11-22 14:57:20 +08:00
jingyaogong 3eee5690f6 [update] cover rare characters 2026-11-21 17:10:33 +08:00
jingyaogong b3ab09f12e Merge pull request #950 from JasonOA888/fix/rep-penalty-cjk
[fix] rep_penalty 对中日韩文本逐字切分,修复中文复读不被惩罚 (#810)
2026-11-21 17:05:21 +08:00
jingyaogong fea44439a8 Merge pull request #949 from qq2514568380/fix/pyarrow-numpy-947
Keep PyArrow compatible with pinned NumPy 1.26
2026-11-21 17:04:44 +08:00
jingyaogong 9e96117064 Merge branch 'master' into fix/pyarrow-numpy-947 2026-11-21 17:04:26 +08:00
jingyaogong 2896bbc438 Merge pull request #948 from JasonOA888/fix/pin-pyarrow-numpy1
[fix] requirements.txt 锁定 pyarrow==25.0.1,修复 numpy==1.26.4 下 import datasets 报错
2026-11-21 17:03:16 +08:00
Jason Li 5abac152d9 [fix] rep_penalty: split CJK per character so Chinese repetition is penalized (#810) 2026-11-20 13:37:48 +00:00
sen 85253756a1 fix: constrain PyArrow for NumPy 1 compatibility 2026-11-20 00:57:00 -08:00
Jason Li 8b7130d731 [fix] pin pyarrow==25.0.1 so datasets imports with numpy==1.26.4 (#947) 2026-11-20 08:09:08 +00:00
jingyaogong cc9629e5f4 [update] fix decoding, drop tests 2026-11-18 23:08:56 +08:00
jingyaogong 9f05da1c3d Merge pull request #919 from Afloat16/fix/lora-merge-fp32
[fix] accumulate LoRA deltas before rounding merged weights
2026-11-18 22:57:11 +08:00
jingyaogong eaa4b87f67 Merge pull request #912 from Afloat16/fix/generation-greedy-temperature
[fix] ignore sampling temperature for greedy generation
2026-11-18 22:56:56 +08:00
jingyaogong 5d8981e82f Merge pull request #909 from Afloat16/fix/distillation-empty-supervision
[fix] keep empty supervised distillation batches finite
2026-11-18 22:55:57 +08:00
jingyaogong 2bbf372bfe Merge pull request #907 from Afloat16/fix/attention-bool-mask
[fix] accept boolean padding masks in manual attention
2026-11-18 22:55:42 +08:00
jingyaogong 2794acc34b Merge pull request #905 from Afloat16/fix/api-inference-event-loop
[fix] keep synchronous inference off the API event loop
2026-11-18 22:55:19 +08:00
Afloat 2de4dcb45e [fix] keep synchronous inference off the API event loop 2026-11-18 17:50:06 +08:00
Afloat 767dd65859 [fix] accept boolean padding masks in manual attention 2026-11-18 17:40:59 +08:00
Afloat 5f69faf966 [fix] ignore sampling temperature for greedy generation 2026-11-18 17:40:54 +08:00
Afloat 5240cc8133 [fix] accumulate LoRA deltas before rounding merged weights 2026-11-18 17:40:45 +08:00
Afloat 141c830464 [fix] keep empty supervised distillation batches finite 2026-11-18 17:40:43 +08:00
jingyaogong 2de2308d71 [update] trim merged pr leftovers 2026-11-18 14:08:54 +08:00
jingyaogong 6ae4806873 Merge pull request #899 from uphome/fix/lora-alpha-scaling
[fix] LoRA: add alpha/rank scaling with backward-compatible persistence
2026-11-18 14:04:16 +08:00
jingyaogong 12b5e03e30 Merge pull request #904 from FeiyangP/fix/agent-reward-numeric-gt
train_agent: match numeric gt by value, not by substring
2026-11-18 13:51:23 +08:00
FeiyangP e888e12dab train_agent: match numeric gt by value, not by substring
validate_gt_in_text accepted a ground truth when it appeared anywhere in the
answer as a substring, so a numeric gt of 9 matched "19", 100 matched
"1000" and 5 matched "2.5": a wrong answer got the full GT reward and the
policy could exploit it. A numeric gt now only matches a number of equal
value. The number scan also used \w as its boundary, which treats Chinese
characters as word characters, so "答案是59。" yielded no number at all;
the boundary now only looks at ASCII letters, digits, '_' and decimals.
2026-11-18 02:52:57 +00:00
uphomer 9012e5e0ef [fix] LoRA: add alpha/rank scaling with backward-compatible persistence
当前 LoRA 前向为 B(A(x)),没有标准 LoRA 的 alpha/r 缩放(等价 alpha=r)。
#894 合入 --lora_rank 后 rank 可配,但有效更新尺度仍与 rank 耦合
(实测同 lr 下初始 ||dL/dB||: rank 4/8/16/32 = 0.0274/0.0374/0.0557/0.0846,约 sqrt(r)),
rank 消融与超参迁移受影响。

修复:
- LoRA(..., lora_alpha=None):scaling = (rank if lora_alpha is None else lora_alpha) / rank
- forward 乘 scaling;scaling 注册为 buffer 随 state_dict 持久化
- save_lora:权重存 half、buffer 存 float32
- load_lora:strict=False,旧 checkpoint 缺 scaling 时默认 1
- merge_lora:合并时乘 scaling
- train_lora.py:新增 --lora_alpha(默认 None = rank)

验证:
- 默认 alpha=None:scaling=1,输出与旧实现逐位一致
- alpha=2r:低秩分支输出 2x
- save/load:scaling 保留;float32 原值逐位一致;half 保存(原有行为)最大差异 1.6e-5
- 旧 checkpoint(无 scaling):可加载,scaling=1
- merge 一致性(alpha=2r):max diff 1.3e-4(half 精度)
- 完整模型:rank=8 时 LoRA 0.197M,16 个 scaling buffer
- 真实 train_lora 冒烟(rank=8, alpha=16):约 2780 步 loss 有限
2026-11-03 20:19:45 +08:00
jingyaogong 233d00fa06 [update] trim merged pr leftovers 2026-10-27 14:57:05 +08:00
jingyaogong d80c692543 Merge pull request #883 from cyanseek/codex/stream-tool-content
[fix] Keep streamed tool calls out of response content
2026-10-27 14:52:51 +08:00
jingyaogong 7a4766887b Merge pull request #886 from Yi-111-a/docs/grpo-policy-loss-interpretation
docs: 说明 GRPO 的 Policy Loss 该怎么读(修 #884 的表述)
2026-10-27 14:50:51 +08:00
jingyaogong 0938214b59 Merge pull request #894 from BBqBuleberry/feat/lora-rank-arg
feat(lora): make LoRA rank configurable in train_lora.py and eval_llm.py
2026-10-27 14:49:45 +08:00
jingyaogong 6bc64cd866 Merge pull request #882 from Yi-111-a/fix/train-agent-malformed-tool-call
[fix] keep malformed tool calls from crashing agent RL training
2026-10-27 14:48:48 +08:00
jingyaogong 999dfde609 Merge pull request #889 from fjvbn2003/fix-load-from-model-dir
[fix] decide native-vs-transformers loading by directory name, not substring
2026-10-27 14:47:59 +08:00
jingyaogong 7ea219febb Merge pull request #896 from Vincent-Huang-2000/fix/resume-ckpt-fp32
[fix] keep resume checkpoint weights in fp32
2026-10-27 14:25:04 +08:00
Vincent 043b22a073 [fix] keep resume checkpoint weights in fp32
lm_checkpoint 写续训文件 (*_resume.pth) 时,model 权重被存成了 fp16。
续训时 load_state_dict 会把 fp16 数值拷回 fp32 参数,既不报错、dtype
也不变,但 fp32 主权重已被舍入到 fp16 可表示的值上:上次重启以来
小于半个 fp16 ulp 的累计更新会被抹掉。

来历:
- e848487 ([feat] pause-training) 最初的实现中,推理权重只在 torch.save
  时调用 .half(),resume_data['model'] 存的是原始 fp32 state_dict。
- 5e1447b ([fix] cuda memory #559) 为解决 rank0 显存持续增长,把
  state_dict 整体覆盖为 v.half().cpu();resume_data['model'] 复用了这个
  变量,于是也变成了 fp16。

影响范围:
- 所有通过 lm_checkpoint 保存的训练脚本:pretrain / full_sft / lora /
  dpo / distillation / grpo / ppo (actor) / agent。PPO 的 critic 走
  kwargs 分支,本来就是 fp32。
- 只在 --from_resume 1 重启时生效;训练途中的保存不影响内存中正在
  训练的权重。
- 预训练、SFT 学习率较大,一次续训的舍入误差对矩阵权重约相当于不到
  1 步的更新,可以忽略。
- DPO (lr 4e-8)、GRPO/PPO/Agent (lr 3e-7) 中,|w|≈0.02 的权重分别约需
  190 / 25 步满幅度同向更新才能越过半个 ulp,续训会把这些阶段的大量
  进展打回阶段起点;RMSNorm 权重 (≈1.0) 需要的步数还要多约 60 倍。
- 问题是静默的:bf16 autocast 前向使用的权重本就比 fp16 更粗,续训前后
  loss 曲线连续,看不出异常。

修复:
- 先把 state_dict 拷到 CPU 并保持 fp32,作为 resume_data['model']。
- 推理权重 (*.pth) 由这份 CPU 副本 .half() 后保存,转换在 CPU 上完成。
- 仍然先 .cpu(),GPU 上不产生额外副本,#559 的显存问题不会复发。

兼容性:
- 各脚本加载端都是 model.load_state_dict(ckp_data['model']),新旧 resume
  文件都能加载,新旧代码也可以互相读取对方写的文件。
- 已有的 fp16 resume 文件精度已经丢失:从它续训的那一次仍会舍入,之后
  保存的都是 fp32。
- resume 文件约增大 128MB (64M 参数 × 2 字节)。
2026-10-27 16:08:23 +13:00
BBqBuleberry 695aa1fdb6 feat(lora): make LoRA rank configurable in train_lora.py and eval_llm.py 2026-10-25 23:22:52 +08:00
YoungjuKim cd36b4a013 [fix] decide native-vs-transformers loading by directory name, not substring
"model" in args.load_from matched any path containing "model" (for
example a Hugging Face cache path or /data/models/...), so the scripts
loaded ./out/*.pth instead of the transformers checkpoint the user
passed. Compare the last path component with "model" instead.

Signed-off-by: YoungjuKim <fjvbn2003@gmail.com>
2026-10-17 03:53:56 +09:00
Yi-111-a 7bde9752c1 docs: clarify how to read the GRPO policy loss curve
The GRPO section described Policy Loss as 'decreases steadily overall' next to the
reward trend, which reads like a supervised loss where a lower value means a
better model. GRPO's policy term is a TRPO-like surrogate whose advantage term is
renormalized within each group every iteration, so its absolute level mainly
tracks how far the policy has drifted from the sampling distribution.

Keep the reward observation and the single-network vs. PPO comparison, and state
that convergence should be judged from reward and generation quality instead.
Same change in README.md and README_en.md.

Refs #884
2026-10-09 23:12:13 +08:00
cyanseek 86aad50621 [fix] Keep streamed tool calls out of response content 2026-10-02 19:54:21 +08:00
Yi-111-a dcbd31bf3d [fix] keep malformed tool calls from crashing agent RL training 2026-10-01 11:30:27 +08:00
jingyaogong f659b55761 [fix] residual step order 2026-09-23 00:07:30 +08:00
jingyaogong 6fff76fe04 Merge pull request #868 from DaoyuanLi2816/fix/final-accumulation-checkpoint
[fix] save final checkpoints after the residual accumulation step
2026-09-22 23:39:01 +08:00