Repository navigation
Studio /v1 images: pin the load's LoRA set so a reload cannot swap it mid-request - #18135
Merged
Merged
Conversation
…esolved from /v1/images/generations resolves an omitted loras to the load's adapters, then pins only repo / base / family. A same-model reload with other adapters keeps that identity, so a reload committing between the status read and the generation slot was admitted with the old load's set: - a plain load resolved to none, then rebaked with a LoRA: the engine reads the missing selection as none and renders the new bake with its weight at 0; - a load baked with one LoRA, rebaked with another: the stale id is refused as a 400 although the request never named an adapter. #17993 closed this on /images/generate with expected_load_loras. /v1 now passes the same pin (only when loras is omitted and the engine reports its load's adapters), on the single call and the batched call, and keys batches on it, so a refused request retries once from fresh state with the new set.
Codex Review Summary: ✅ CompletedThis 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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
that referenced
this pull request
Nov 17, 2026
…ine as benign (red since #18135) (#18145) `tests/studio/test_backend_ci_parallel_isolation.py::test_every_tight_elapsed_bound_is_isolated` fails on main since #18135 (workflow-trigger lint and the CPU `studio` shard, seen on the staging run of #18139): ``` E assert not {'test_openai_images_load_swap.py': ['test_openai_images_load_swap.py:199 one duration against another']} ``` ## Cause #18135 added `test_a_batch_waiting_through_a_reload_carries_the_pin`, which waits for two image requests to join one batch: ```python deadline = asyncio.get_running_loop().time() + 5 while sum(len(b.members) for b in batching._OPEN.values()) < 2: assert asyncio.get_running_loop().time() < deadline, "the batch never formed" await asyncio.sleep(0.01) ``` That is a poll deadline: descheduling only delays the poll and cannot make the condition false. The lint flags every clock comparison in backend tests run under `-n 4` until it is recorded, and this one was not. ## Fix Add `("test_openai_images_load_swap.py", "test_a_batch_waiting_through_a_reload_carries_the_pin")` to `BENIGN_TIMING` with a one-line reason. The lint keys on the outermost enclosing function, so the test name covers the nested `run()`. ## Verification - main: `test_every_tight_elapsed_bound_is_isolated` fails with the message above. - this branch: `tests/studio/test_backend_ci_parallel_isolation.py` 43 passed.
danielhanchen
added a commit
that referenced
this pull request
Nov 17, 2026
… with its output (rest-2 timeouts) (#18180) `tests/test_ddp_find_unused_default.py::test_trainable_embeddings_train_under_ddp_reentrant_checkpointing` hits pytest-timeout in the CPU `rest-2` shard on unrelated PRs (#18135, #18165, #18171 today): ``` tests/test_ddp_find_unused_default.py:285: in test_trainable_embeddings_train_under_ddp_reentrant_checkpointing proc = subprocess.run( E Failed: Timeout (>330.0s) from pytest-timeout. ``` The test takes about 11 s locally and hung only on some workers, with no child output in the log. ## Cause The test copies `os.environ` into both children: the single-process reference and the `torchrun` pair. The worker decides it is distributed from `WORLD_SIZE`. Several tests write rank variables (`RANK`, `WORLD_SIZE`, `MASTER_PORT`, ...) into the pytest process environment, so on a worker that ran one of them first, the single-process reference sees `WORLD_SIZE=2`, calls `init_process_group("gloo")` and waits for a second rank that never comes. It never returns, and the child's `timeout = 600` is longer than pytest-timeout's 330 s, so CI only showed a bare timeout. Reproduced on main by running the file with `WORLD_SIZE=2 RANK=0 MASTER_ADDR=127.0.0.1 MASTER_PORT=29555` in the environment: it hangs until killed. ## Fix - `_rank_env(tmp_path)` builds the child environment without `RANK`, `WORLD_SIZE`, `LOCAL_RANK`, `LOCAL_WORLD_SIZE`, `GROUP_RANK`, `ROLE_RANK`, `MASTER_ADDR`, `MASTER_PORT` (torchrun sets its own) and the `UNSLOTH_DDP_FIND_UNUSED_PARAMETERS_AUTO` override the test already dropped. - `_run_child` runs each child under a timeout below pytest-timeout (150 s each for the two-step test, 300 s for the single torchrun in the VLM test) and, if one still hangs, fails with the tail of its output instead of a bare timeout. - Both DDP tests in the file use them. ## Verification - `tests/test_ddp_find_unused_default.py`: 63 passed. - Same file with `WORLD_SIZE=2 RANK=0 MASTER_ADDR=127.0.0.1 MASTER_PORT=29555` exported: 63 passed (main: hangs).
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
/v1/images/generationscan render with a stale adapter set when the model is reloaded mid-request. Withlorasomitted, the route resolves the request to the load's adapters, but it pins only repo, base and family. Reloading the same model with other adapters keeps that identity, so a reload that lands between the status read and the generation slot is let through. There are two outcomes:#17993 fixed the same race on the native route.
/v1now passes the sameexpected_load_loraspin, on both single and batched calls. It does so only whenlorasis omitted and the engine reports its load's adapters. Batches are keyed on it.Testing
tests/test_openai_images_load_swap.py, 6 tests in which a load thread commits a rebake between the status read and the slot. On main 4 fail and 2 pass; on this branch all 6 pass.DiffusionBackend.generateslot check. On main it reaches the render withloras=None, which would zero the new bake.test_openai_images_baked_loras.pytakesexpected_load_loras, as the real diffusers engine does./v1and native route suites pass. Across 14 wider route files, main and this branch fail the same test IDs; they need zstd, sqlite_vec and the MiniMax download plan.Not covered
No GPU run drove a real reload into a live
/v1request. The race is route-level, and the test exercises the real engine's slot check.