Repository navigation
Studio: reject a training random_seed outside the numpy range up front - #15176
Merged
danielhanchen merged 3 commits intoOct 26, 2026
Merged
Conversation
random_seed accepted any int, but it reaches transformers.set_seed, which numpy limits to [0, 2**32 - 1]. A value like -1 passed validation, loaded the model and only then failed in set_seed. Bound the field so the request is rejected with a 400 before any model work starts.
danielhanchen
added a commit
that referenced
this pull request
Oct 25, 2026
…15182) ## Summary `tests/utils/test_single_row_cached_attention.py` errors on all 64 cases on main since #15171 (K/V straight into the cache slot, opt-in CUDA-graph decode). That fails the `Core (HF=...)` legs on unrelated PRs, for example #15176 and #15178: ``` AssertionError: Qwen3Attention_fast_forward_inference now reads ['_decode_attention_core', '_decode_graphs']; give the harness a CPU stand-in for each ``` The harness lifts `LlamaAttention_fast_forward_inference` and `Qwen3Attention_fast_forward_inference` out of their files with `ast`, and refuses to run if they read a global it does not provide. #15171 moved the cache and scratch buffer setup into `unsloth/models/_decode_graphs.py` (`alloc_decode_buffers`, `resize_decode_buffers`) and added the captured-step branch that calls `_decode_attention_core`. The product is fine. The guard did what it is meant to do and asked for stand-ins. ## Change - `_decode_graphs`: the real module, loaded by file path. Its top level is torch and the standard library only. `ENABLED` is forced to `False`, because graph replay is CUDA-only. The test keeps running the real `alloc_decode_buffers` / `resize_decode_buffers` instead of a copy. - `_decode_attention_core`: a stand-in that raises if called. It is only reached from a captured decode step, which this CPU harness never enters, so reaching it would mean graph mode leaked in. ## Verification - On main: `64 errors`. With this change: `64 passed`. It also passes with `UNSLOTH_DECODE_CUDA_GRAPHS=1` set. - Sabotage 1: writing the wrong V rows in `_decode_graphs.alloc_decode_buffers` gives 56 failures. The real helper is what the test exercises. - Sabotage 2: skipping qwen3's 2D padding mask conversion in the decode function gives 8 failures. The masking checks the file was written for still bite.
[skip ci]
Member
|
@codex review |
1 similar comment
Member
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
A Studio training request with
random_seedoutside[0, 2**32 - 1](for example-1) passes validation, loads the model, and only then fails withValueError: Seed must be between 0 and 2**32 - 1.Cause:
TrainingStartRequest.random_seedaccepted any int, but it reachestransformers.set_seed, which numpy bounds. The diffusion training seed already has this bound.Fix:
ge = 0, le = 2**32 - 1on the field, so the request gets a 400 up front. The OpenAI fine-tuningseeduses the same model, so it is bounded too.Test:
pytest studio/backend/tests/test_studio_train_validation.pyfails before for-1and2**32, passes after (57 passed with the OpenAI fine-tuning and LoRA seed tests).