[Performance] DreamerV3: freeze the setup heap before the training loop - #4308
[Performance] DreamerV3: freeze the setup heap before the training loop#4308vmoens wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4308
Note: Links to docs will display an error until the docs builds have been completed. ❌ 8 New Failures, 1 PendingAs of commit 7ca98b5 with merge base 14324ea ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
0b0e1f0 to
9be4cce
Compare
Projected end-to-end gain is at most a few percent and remains unmeasured on the GPU node. The benefit should shrink after #4305 reduces unpickling. |
Profiling a 64-environment DreamerV3 Minecraft run on a 4-GPU node with process environment workers attributed 7% of the driver main thread (218 of 3000 py-spy samples at 200 Hz over 15 s) to filelock's sys.addaudithook callback, reached from AsyncBatchedCollector._rollout_frames through multiprocessing.Queue.get and _ForkingPickler.loads, once per transition received from the workers. The hook itself is not the cost: it fires on pickle.find_class, 8 times per consolidated transition regardless of its size, for 1-2 us per unpickle. Since Python 3.12 the cyclic GC is scheduled on the eval breaker and runs at the next check, which during a C-level unpickle is the RESUME of the first Python callback, i.e. the audit hook. The samples are full collections re-traversing the large setup heap, triggered by the unpickler's allocations; without filelock they land on torch's rebuild_storage_fd. Freeze the setup objects once everything is built so later collections only visit what the loop allocates. Locally (3000 unpickles over a 1M-dict live heap) this cuts GC time from 0.21 s to 0.025 s and the per-item loop from 165 us to about 108 us. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
9be4cce to
7ca98b5
Compare
|
Measured on the target hardware (64-environment DreamerV3 Minecraft run, one 4-GPU node, process-slot inference server with a static batch of 64, compiled and CUDA-graph learner step, bf16, train ratio 16), comparing the full stack #4305 + #4306 + #4307 + #4308 (with
The unthrottled collection phase before training reached 1,254 steps/s (298 before), the learner GPU now shows sustained full-utilization bursts instead of about a quarter duty cycle, and the run had no errors over the measured 1.3 hours. The two rates move together because the train ratio couples them, so the stack lifted both the collection ceiling and the learner cadence past the previous limits. This measures the combined effect of the four PRs; per-PR attribution has not been measured. |
Stack: #4305 → #4306 → #4307 → #4308; depends on #4307.
Freeze the DreamerV3 setup heap so cyclic GC stops rescanning it during training.
Reported validation: CPU SOTA smoke and lint pass; local reproduction reduces GC time ~8×. Profiled GPU configuration still needs validation.