Commit Graph

32 Commits (c54a88887bcabcee0be99c29946fa620308a81ee)

Author SHA1 Message Date
Justin Güse c54a88887b
Merge 6b2f4c939a into 7a9137d2e9 2026-09-15 16:19:57 +08:00
tkgcc 0f6803e551 [fix] replace tool eval() with an AST math evaluator
execute_tool() relied on signal.SIGALRM, which does not exist on Windows.
The AttributeError was swallowed by a bare except, so every tool call
silently returned None and the model always observed
{"error": "tool not found"} (issue #846).

calculate_math also ran eval() on model-generated text. Two of the three
call sites (scripts/eval_toolcall.py, scripts/web_demo.py) passed no
globals at all, leaving full builtins reachable from sampled output.

safe_math_eval() in trainer_utils.py parses the expression with ast and
walks it, allowing only arithmetic operators and a math whitelist, with
caps on expression length and exponent size. It cannot loop forever, so
the signal-based timeout is no longer needed and is removed. Both sqrt(x)
and math.sqrt(x) spellings keep working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 07:53:33 +08:00
Justin Guese 6b2f4c939a [update] MoE 分发:每层主机同步从 3E 次降到 1 次
专家循环里 mask.any() / nonzero() / 布尔索引每个专家各触发一次 device→host
同步,实测每层正好 3E 次(默认 4 专家 × 8 层 = 每次前向 96 次)。同步会清空
CUDA 流,而这些开销全部花在路由的簿记上。

改为先按专家把 token 排成连续段,用 searchsorted 取边界、一次 tolist() 读回
主机,每个专家取一段连续切片。专家循环保留,整层只剩 1 次同步,与专家数无关。
纯 PyTorch,无新依赖,对硬件和 dtype 没有要求。

stable=True 保证段内 token 顺序不变,因此前向与全部参数梯度在所有 k 下与原
写法逐位相同;输入梯度在 k<=2 时逐位相同,k>=3 时因浮点加法不满足结合律
差约 1 ulp(相对 1e-7)。原掩码写法作为参考实现保留在 scripts/test_moe_sorted.py,
每次跑测试都会执行并断言一致。

state_dict、aux_loss、router 与模块结构均未改动,旧 checkpoint 仍可 strict 加载。
2026-09-03 15:05:25 +07:00
jingyaogong 512eed0b65 [fix] robustness 2026-06-28 18:03:34 +08:00
jingyaogong 5704766352 [update] tie embedding 2026-04-19 21:57:28 +08:00
jingyaogong 5351424bf0 [fix] lora moe 2026-04-09 16:36:48 +08:00
jingyaogong b7e0ae21d6 [update] default model 2026-03-31 13:40:16 +08:00
jingyaogong 6b0b0c5e2f [update] fp16 inference 2026-03-27 16:29:46 +08:00
jingyaogong 101d7df2da [update] minimind-3 2026-03-25 23:57:45 +08:00
jingyaogong 04616c41a5 [update] safe half 2026-01-30 20:29:31 +08:00
jingyaogong 07364c3fbe [update] rename train tokenizer 2026-01-06 01:17:33 +08:00
jingyaogong a8455ca8a3 [fix] messages num 2026-01-04 11:03:16 +08:00
jingyaogong eead9538b2 [feat] update config 2025-12-31 10:29:13 +08:00
jingyaogong 936d105e9b [feat] compatible tokenizer 2025-12-31 10:26:46 +08:00
jingyaogong 81e869fc3e [fix] harmonize template 2025-11-06 13:14:08 +08:00
jingyaogong 509d8dacf1 [feat] clear cache 2025-11-06 13:12:28 +08:00
jingyaogong 8a0b04ed82 [fix] harmonize template 2025-11-02 23:18:11 +08:00
jingyaogong 08ce3da228 [feat] update args 2025-10-30 10:48:31 +08:00
jingyaogong bf123b585d [feat] add args 2025-10-30 10:05:12 +08:00
jingyaogong 28cc44579a [feat] convert2llama 2025-10-23 20:22:42 +08:00
jingyaogong 7d877db79b [feat] minimind-2510 2025-10-21 21:19:47 +08:00
jingyaogong 2e118e9d3d update convert script 2025-04-27 15:44:40 +08:00
jingyaogong a62faf34bd 250426 2025-04-26 10:05:47 +08:00
jingyaogong 7da201a944 update chat-openai-api 2025-04-18 12:43:57 +08:00
jingyaogong 4a758564e4 fix top_p float bug 2025-04-09 16:52:20 +08:00
jingyaogong 08e9a22a25 update web_demo 2025-04-04 11:25:40 +08:00
gongjy c1a77f5c0f update web_demo 2025-02-14 19:38:55 +08:00
gongjy d519d2a233 update web_demo 2025-02-14 19:37:27 +08:00
gongjy b5d10d9a7d fix bugs 2025-02-13 20:56:14 +08:00
gongjy c9ca0f57dc update config 2025-02-10 00:14:11 +08:00
gongjy 29d6cd9cd2 update scripts file 2025-02-09 23:52:50 +08:00
gongjy 58e3af0359 add minimind2 2025-02-09 23:49:47 +08:00