[BUG] LoRA WebUI 的 seed 没有传入 `generate()`,导致推理结果无法可靠复现

#390 · open · 3 comments

View on GitHub ↗

anubisred253

LoRA WebUI 提供了推理 seed 输入框,但当前代码只在 lora_ft_webui.py 中执行了 torch.manual_seed(seed) 和 np.random.seed(seed),随后调用 current_model.generate() 时没有把 seed 参数传进去。 底层 VoxCPM.generate() / _generate() 本身支持 seed 参数。如果 LoRA WebUI 不显式传入 seed,底层会按 seed=None 处理,并自行生成新的随机 seed。因此用户在 LoRA WebUI 里固定 seed 后,推理结果可能仍然无法可靠复现。 这个问题会影响 LoRA checkpoint 的 A/B 测试。比如用户想固定参考音频、参考文本、目标文本、CFG、steps 和 seed,只切换不同 LoRA checkpoint 来比较效果时,结果可能并不是严格可比的。 环境: - 系统:Windows - 模型:本地 VoxCPM2 - 启动入口:lora_ft_webui.py - 仓库 commit:f5a1c6a6b901bc732e20f0d59a369f6829ad717a 相关代码: 在 lora_ft_webui.py 中,seed 被读取并设置: if seed != -1: torch.manual_seed(seed) np.random.seed(seed) 但后面调用 current_model.generate() 时没有传入 seed 参数。 期望行为: LoRA WebUI 中设置的 seed 应该传入 current_model.generate(),这样用户才能在固定 seed 的情况下稳定复现结果,并可靠比较不同 LoRA checkpoint 的差异。 建议修复: 在 lora_ft_webui.py 中调用 current_model.generate() 时增加 seed 参数,例如: generation_seed = None if seed in (None, "", -1) else int(seed) 然后在 current_model.generate(...) 中加入: seed=generation_seed 另外也可以考虑像主 WebUI 一样显示 last_successful_seed,方便用户记录实际成功生成时使用的 seed。

Comments

modelpath-dev

I'll work on this. Could you assign it to me? I'll reproduce from the report, fix the failure path, and add a test so it stays fixed.

modelpath-dev

I am starting to work on this issue now. I will make sure to pass the seed parameter to `current_model.generate()` as suggested. This should help in reliably reproducing the results. Let me know if there are any other specific requirements.

modelpath-dev

I have started implementing the changes. I will ensure the seed is passed correctly to `current_model.generate()`. This should help with consistent result reproduction. If there are any other suggestions or requirements, please let me know.