finetune: make training seed explicit - #108
Merged
HenryNdubuaku merged 1 commit intoSep 7, 2026
Merged
Conversation
Signed-off-by: TeaShaman-cyber <pokladsemen@gmail.com>
TeaShaman-cyber
force-pushed
the
fix/finetune-seed
branch
from
September 4, 2026 09:21
6d54a9a to
21b414f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expose a
--seedoption onneedle finetuneand use it consistently for the three stochastic parts of a training run:The realized seed is also stored in the adapter metadata, so downstream evaluation and provenance tooling can identify which training run produced an adapter.
Motivation
On current
main, LoRA initialization and validation splitting are fixed at seed0, while epoch shuffling uses the process-global NumPy RNG. Two otherwise identical fresh processes can therefore train on different epoch orders, and the CLI provides no way to reproduce or intentionally vary that randomness.This patch keeps the existing behavior backward-compatible by defaulting
--seedto0, but makes the full training RNG explicit and reproducible.Verification
tests/test_finetune.py: 5 passed on a real JAX/Flax/Optax runtime.needle finetune --helpexposes--seed SEED.python -m py_compile needle/cli.py needle/model/finetune.pypasses.git diff --checkpasses.This is intentionally scoped to reproducibility only; it does not change the loss, optimizer, QAT behavior, or build/export semantics.
— Semyon Poklad & Шут (Jester)