feat(webui): add seed controls for reproducibility#10629
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for configuring random seeds across the training, evaluation, and chat interfaces in the WebUI, as well as in the Hugging Face, SGLang, and vLLM chat engines. The review feedback points out potential crash risks in the WebUI runner when parsing the 'train_seed' and 'eval_seed' textboxes, as calling int() directly on empty or non-numeric inputs will raise a ValueError. It is recommended to safely parse these inputs with a fallback default value.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| learning_rate=float(get("train.learning_rate")), | ||
| num_train_epochs=float(get("train.num_train_epochs")), | ||
| max_samples=int(get("train.max_samples")), | ||
| seed=int(get("train.train_seed")), |
There was a problem hiding this comment.
If the user clears the train_seed textbox or inputs an invalid/non-numeric value, calling int() directly on it will raise a ValueError and crash the WebUI runner thread.
To prevent this, we should safely parse the seed and fall back to the default seed of 42 if the input is empty or invalid.
| seed=int(get("train.train_seed")), | |
| seed=int(get("train.train_seed").strip()) if get("train.train_seed") and get("train.train_seed").strip().isdigit() else 42, |
| max_new_tokens=get("eval.max_new_tokens"), | ||
| top_p=get("eval.top_p"), | ||
| temperature=get("eval.temperature"), | ||
| seed=int(get("eval.eval_seed")), |
There was a problem hiding this comment.
Similarly to train_seed, if the user clears the eval_seed textbox or inputs an invalid/non-numeric value, calling int() directly on it will raise a ValueError and crash the WebUI runner thread.
We should safely parse the seed and fall back to the default seed of 42 if the input is empty or invalid.
| seed=int(get("eval.eval_seed")), | |
| seed=int(get("eval.eval_seed").strip()) if get("eval.eval_seed") and get("eval.eval_seed").strip().isdigit() else 42, |
cd249f9 to
10ce5ff
Compare
|
Addressed the seed parsing review in the latest push. Change made:
Validation rerun:
|
What does this PR do?
Fixes #10581.
Adds explicit seed controls in the WebUI so users can reproduce generation, training, and evaluation/prediction runs without discovering the JSON
extra_argsescape hatch.Changes:
-1preserving the current random behavior.Validation:
uvx ruff check src\llamafactory\webui\components\chatbot.py src\llamafactory\webui\components\train.py src\llamafactory\webui\components\eval.py src\llamafactory\webui\chatter.py src\llamafactory\webui\runner.py src\llamafactory\chat\hf_engine.py src\llamafactory\chat\vllm_engine.py src\llamafactory\chat\sglang_engine.py src\llamafactory\webui\locales.pygit diff --checkpy -m py_compile src\llamafactory\webui\components\chatbot.py src\llamafactory\webui\components\train.py src\llamafactory\webui\components\eval.py src\llamafactory\webui\chatter.py src\llamafactory\webui\runner.py src\llamafactory\chat\hf_engine.py src\llamafactory\chat\vllm_engine.py src\llamafactory\chat\sglang_engine.py src\llamafactory\webui\locales.pyFull runtime generation/training tests were not run locally because this environment does not have the heavyweight ML runtime dependencies installed, and I avoided pulling them for this focused WebUI/argument-wiring change.
Before submitting