Repository navigation
Studio: keep the server running when several PDFs are indexed at once - #18017
Conversation
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
…t (fsdp2 red since accelerate 1.16) (#18025) ## Summary `Repo tests (CPU, fsdp2)` fails on main since accelerate 1.16.0 reached PyPI today (seen on #18012 and #18017, both on `20d05c20`): ``` tests/test_fsdp2_wrap_gloo.py::test_activation_checkpointed_blocks_keep_the_last_block_gathered assert r["blocks"] == N_LAYERS E assert 0 == 3 ``` ## Cause With activation checkpointing on, accelerate wraps each decoder block in a `CheckpointWrapper` and then calls `fully_shard`. Up to 1.15 it sharded the block inside the wrapper. 1.16 shards the wrapper instead and skips the block inside ("Shard the wrapper to keep FSDP hooks outside compiled code", `fsdp2_prepare_model`). `after_fsdp2_wrap` finds the blocks with `_decoder_blocks(model)` and keeps the ones that are `FSDPModule`s. On 1.16 the block is no longer one, and the wrapper's class is not a decoder layer class, so it found no blocks. The fused LoRA gate does not depend on that list (it checks that each fused layer's owning unit sits in the layer list, which the wrapper does). What was lost is the per-block tuning: the last block was no longer kept gathered after forward (`set_reshard_after_forward(False)`), so with activation checkpointing every step gathered it again at the start of backward. The test is right. accelerate's change is reasonable, and Unsloth's block lookup assumed the old layout. ## Change - `unsloth/models/fsdp2.py`: new `_block_units`, which returns each decoder block's FSDP unit: the block itself, or the checkpoint wrapper around it when that wrapper is the `FSDPModule` (`_checkpoint_wrapped_module is block`). `after_fsdp2_wrap` uses it for the block list, the block count and the last-block reshard setting. - New `tests/test_fsdp2_block_units.py` (in the `fsdp2` shard): both layouts with stand-in classes, so the 1.16 layout is checked whatever accelerate CI installs, plus a case where neither the block nor the wrapper is sharded. ## Verification - `tests/test_fsdp2_wrap_gloo.py` on accelerate 1.16.0: the checkpointed test fails on main (`0 == 3`) and all 5 pass with this change. On accelerate 1.15.0: 5 passed with this change. - `tests/test_fsdp2_block_units.py`: 3 passed. Without the wrapper lookup, the wrapper case fails. - The whole `fsdp2` shard file set on accelerate 1.16.0: 247 passed, 16 skipped.
|
@codex review |
1 similar comment
|
@codex review |
… extensions [skip ci]
|
Codex Review: Didn't find any major issues. 🎉 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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
Fixes #17981. Indexing two or more damaged PDFs at once (a linked folder, or several files added to a chat) segfaulted the Studio server: "Server stopped unexpectedly", exit code
0xc0000028on Windows. PyMuPDF is not thread-safe, and only web PDF reads took a lock; ingestion parsed on several threads without one.All PyMuPDF use now shares one lock: parsing, page and figure rendering, OCR, the citation highlight lookup and web PDF reads. Four healthy PDFs index as fast as before (290-420 s here, 361-912 s on main). Files in a batch finish closer together, since the highlight lookup waits for PDFs still being parsed.
Six damaged PDFs added to a chat: the server dies mid-indexing on main, all six index with this PR.