Repository navigation
Studio DiT training: record a failed text-encoder streaming setup as type and message only - #18567
Conversation
…type and message only LAST_ERROR held the exception object, whose traceback kept the placement frame alive: the training pipeline, its candidate encoders and a partially built streamer were never freed after a failed setup. Store "Type: message" instead.
Codex Review Summary: 🔄 RunningThis 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 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 |
1 similar comment
|
@codex review |
|
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". |
#18123 added text-encoder layer streaming for DiT training captioning. When the streaming setup fails,
place_text_encodersundoes any half-streamed encoder and lets the caller move the encoders whole, but first it stores the exception object in the module globaldiffusion_te_stream.LAST_ERROR. The exception's traceback keeps the placement frame alive, and that frame references the training pipeline, the candidate encoders and, when the streamer constructor failed, its partially built state (the host arena). So after one failed setup, the pipeline and those host / GPU buffers stay referenced for the life of the worker, even once training releases its own references. Nothing reads the object itself:LAST_ERRORis only a diagnostic.Change
LAST_ERRORnow holds"Type: message"(a plain string) instead of the exception. The status a reader would need is still there. The traceback, its frames and anything they reference are dropped when the handler returns. Nothing else changes: the fallback, the undo of a half-streamed encoder and the return value stay the same.Tests
test_a_failed_setup_records_the_error_without_keeping_the_pipeline_alivemakes the streamer constructor allocate a buffer and then raise through the realplace_text_encodersentry point. It checks that the error type and message are recorded, then drops the last caller reference to the pipeline, runsgc.collect(), and checks that the pipeline and encoder are freed. On main it fails because the pipeline is still alive throughLAST_ERROR. With this change it passes.tests/test_diffusion_train_te_stream.py: main 13 passed, 2 skipped (CUDA) plus the new test failing. Head: 14 passed, 2 skipped.Not proven here
The test is CPU-only and uses a fake streamer. The real CUDA arena release after a failed setup (memory returned to the allocator / unpinned) was not measured on a GPU. That would need a run that injects a failure into
TextEncoderStreameron a CUDA card and comparestorch.cuda.memory_allocated()and the pinned host total before and aftergc.collect().