Repository navigation
Studio: recheck follow-ups for DDP low-precision agreement, oversized graph release and quantize OOM - #19011
Conversation
…cross ranks, not only the label A layer whose fp8 / W8A8 conversion fails on one rank stays bf16 there while the rank still reports fp8, so two ranks could pass check_effective_precision with different frozen bases. Each rank now also sends a digest and count of its converted (name, format) set, and every rank refuses when they differ.
…able card rocm_windows_discrete negated device_is_integrated, which answers False for an unreadable device property, so an APU whose classification failed lost budgeted checkpointing and the dequant cache like a known discrete Radeon. A tri-state device_integrated_status now keeps 'unknown' apart, and only a positive discrete reading turns the budgets off. device_is_integrated is unchanged.
… request flag graph_release_fits cleared allow_oversized for its un-overridden check, but image_activation_verdict still read UNSLOTH_DIFFUSION_ALLOW_OVERSIZED_GENERATE, so with the env override set the release returned 0 without reading the pool and the request took the oversized path. The check now ignores both overrides.
…not a kept layer convert_frozen_int8 / convert_frozen_fp8 caught torch.cuda.OutOfMemoryError (a RuntimeError) as a per-layer skip, so an allocation failure inside the second layer left a partly converted base that still reported W8A8 / fp8. The OOM now propagates: W8A8 refuses a partial base as before, and the fp8 fallback refuses one instead of recording the converted layers as a bf16 base.
…the card being checked The guard credited every live graph pool on the card, then reset only the image pipeline's handles. The whole-step pool is process-wide, so while a co-resident video pipeline still recorded into it the reset freed nothing and the image graphs were lost for no gain. releasable_pool_bytes now counts only the whole-step pools no other live wrapper records into and the block-graph pools these handles own, read on the named card. A layer split's block card was refused by its own idle block-graph pool with no release at all, since only the primary card ran the release. That card now drops the graphs and re-reads when their pool there closes the gap.
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 240b0793d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| shared = { | ||
| id(state) | ||
| for h in handles | ||
| if callable(getattr(h, "_all_shared", None)) | ||
| for state in h._all_shared() |
There was a problem hiding this comment.
Include nested block fallback handles in releasable pools
When a whole-step graph fails or drops a key and engages its per-block fallback, _engage_fallback() stores the resulting BlockGraphSet in fallback_handle, while the pipeline retains only the outer GraphedForward. This comprehension therefore misses all of that fallback's block pools because the outer handle has no _all_shared(). Unlike this accounting, GraphedForward.reset() recursively resets the fallback, so those pools really are releasable. A subsequent request whose memory shortfall could be covered by dropping these idle graphs now receives zero credit and is refused unnecessarily. Expand the handles to include their nested fallbacks before collecting shared states.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed: releasable_pool_bytes now walks each handle's fallback_handle, so a whole-step graph's per-block fallback pools are credited (reset() frees them). Test test_releasable_bytes_include_a_whole_step_graphs_block_fallback fails without the change.
…n the guard release reset() also frees the BlockGraphSet a whole-step graph keeps on fallback_handle, so releasable_pool_bytes walks into it. [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd53caead7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| (mine if id(w) in own else others).update(tokens) | ||
| pools = mine - others |
There was a problem hiding this comment.
Exclude other GPUs from shared-pool ownership checks
When image and video pipelines are loaded on different GPUs, their whole-step wrappers can reuse the process-wide _POOL_BOX token. This loop adds the other GPU's token to others, making mine - others empty even though CUDA graph pool allocations are device-local: a recording on cuda:1 does not retain cuda:0's pool. Consequently, _release_graphs_for_guard credits zero bytes and refuses requests that would fit after releasing the image pipeline's idle graphs. Filter competing recordings by the device being checked before subtracting their pool tokens.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed: releasable_pool_bytes skips other wrappers captured on a different card when it collects competing pool owners (graph pools are per device); an unknown capture device still counts. Test test_releasable_bytes_ignore_a_recording_on_another_card fails without the change.
…pool alive Graph pools are per device, so releasable_pool_bytes only counts other wrappers captured on the card being checked as competing owners. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
…train # Conflicts: # studio/backend/tests/test_diffusion_ddp_effective_precision.py [skip ci]
Summary
Follow-up fixes from a recheck of the merged Studio training and memory PRs #18967, #18978 and #18980. Each commit fixes one root cause and adds a test that fails on the merge base (
02bed8883e) and passes here. #18964 and #18983 were rechecked as well and need no change.Changes
check_effective_precisiongathered one precision code per rank. The fp8 and W8A8 converters keep a layer that fails to convert in bf16 and still report success, so two ranks could both reportfp8while training different frozen bases. In a real two-process Gloo run with one rank-local constructor failure, rank 0 converted 2 of 2 layers, rank 1 converted 1 of 2, and both passed. Each rank now also sends a digest and count of its sorted(name, format)set fromlowp_layers_digest, and every rank refuses when they differ. A count alone would miss equal counts at different layers. Callers that pass nolayerskeep the old one-int64 exchange.rocm_windows_discrete()negateddevice_is_integrated(), which answers False when the device property cannot be read. An APU whose classification failed therefore lost budgeted checkpointing and the dequant cache, like a known discrete Radeon. The newdevice_integrated_status()returns True, False or None (unknown), and only a positive discrete reading turns the budgets off.device_is_integrated()behaves as before.graph_release_fitsclearedallow_oversizedfor its un-overridden check, butimage_activation_verdictstill readUNSLOTH_DIFFUSION_ALLOW_OVERSIZED_GENERATE. With the env override set, the release returned 0 without reading the pool, and the request took the oversized path even when dropping the graphs would have let it run normally. On the recorded L4 6-image case,allow_oversized=Truereleased 3.3 GiB while the env override released 0. The check now ignores both overrides (env_override=False).releasable_pool_bytes(handles, device)counts only whole-step pools that no other live wrapper records into, plus the block-graph pools these handles own, on the named card. A layer split's block card could also be refused because of its own idle block-graph pool, with no release, because only the primary card ran one. That card now drops the graphs and re-reads when their pool there closes the gap.UNSLOTH_DIFFUSION_GUARD_RELEASE_GRAPHS=0still turns both off.convert_frozen_int8andconvert_frozen_fp8caughttorch.cuda.OutOfMemoryError(aRuntimeError) in their per-layerexcept (RuntimeError, ValueError). An allocation failure inside the second layer's quantization therefore produced[FrozenInt8Linear, Linear]andTrue. That run recorded the samebase_int8_kernel='w8a8'resume identity as a full conversion. The OOM now propagates. W8A8 refuses a partly converted base through the check Studio diffusion training: recheck fixes for fp8 probe order, fp16 W8A8 preflight, atomic W8A8 conversion, int8 kernel in resume identity, torch 2.4 op #18980 added. fp8 had the same hole, and an exception escaping after some layers converted left them inside a base the caller recorded as bf16. The fp8 path now refuses a partial base the same way. The host-first nf4 reload (Fp8FallbackDoesNotFit) still runs first. Deliberate per-layer skips (alignment, a non-OOM error) are unchanged.Not changed
_resolve_base_precisionwould refuse it. That function only runs on the bf16 route. The fp16 route (fp16_amp) setsbase_precisiondirectly and never calls it, so the preflight and the trainer agree.is_autocast_enabled(device)and torch 2.4 compiled-backward cache misses are both below the supported torch floor. The 2.4 case only affects performance, and its gradients are bit-identical. Torch 2.10 through 2.15 engage the cache.Testing
rocm_windows_discrete()was True (budgets off), now False.test_diffusion_ddp_effective_precision,test_diffusion_gc_budget_rocm_windows,test_diffusion_guard_graph_release,test_diffusion_frozen_int8,test_diffusion_layer_split_lifecycle): 85 passed.test_integrated_gpu_no_host_pinsource scans andtest_capture_then_replay_uses_one_graph_and_copies_statics, which cannot importtorch_config_guardin its subprocess).test_diffusion_dit_trainer,test_diffusion_training,test_rocm_windows_vram_7072on head: 340 passed.Not covered