Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4800
Note: Links to docs will display an error until the docs builds have been completed.
|
|
Hi @DaDerekkk! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Fixes #4691
Summary
With synchronous collection (
async_collection=False,learner_backend="local"), all six off-policy trainers (SACTrainer,DDPGTrainer,DQNTrainer,TD3Trainer,CQLTrainer, andIQLTrainer) registeredrb_trainer.extendon thepre_epochhook stage instead ofbatch_process.Because
pre_epochruns insideTrainer.optim_steps()andTrainer.train()skipsoptim_stepsuntilcollected_frames >= collector.init_random_frames, this caused two issues (as analyzed by @sramireddy2 in #4691):init_random_frameswarmup were dropped without entering the replay buffer.num_epochs > 1(e.g.,TD3Trainer(num_epochs=N)), every collected batch was written to the replay bufferNtimes.Changes
sac.py,ddpg.py,td3.py,cql.py,iql.py: Registerrb_trainer.extendon"batch_process"instead of"pre_epoch".dqn.py: Validatemixing_strategyand registerself._aggregate_agent_rewardson"batch_process"before registeringrb_trainer.extendon"batch_process", ensuring QMIX/VDN aggregated reward keys are populated prior to replay buffer storage.test/test_trainer.py: AddTestOffPolicyReplayBufferExtension(10 tests) covering warmup storage across all 6 trainers (_optim_count == 0during warmup), no transition duplication forTD3Trainer(num_epochs=3), QMIX/VDN aggregated reward storage withenable_logging=True, and("collector", "mask")+pre_steps_logconsistency.Design & Scope Notes
batch_processtransforms run beforerb_trainer.extendinside__init__; user hooks registered viatrainer.register_op("batch_process", ...)after construction will run after replay insertion.OnPolicyTrainer,GRPOTrainer): Left on"pre_epoch".OfflineToOnlineReplayBufferHook(offline_to_online.py): Left out of scope here since itsextend()returns a key-stripped TensorDict (pre_steps_logexpects keys such as("next", "reward_sum")) andtest/test_offline_to_online.pycurrently asserts_pre_epoch_ops. Happy to follow up separately if desired.Verification
pytest test/test_trainer.py -v -k TestOffPolicyReplayBufferExtension: 10 failed on unmodifiedmain, 10 passed after fix.pytest test/test_trainer.py -q: 253 passed, 37 skipped (optionaltorchsnapshot,hydra,ale_py,gymnasium, CUDA).pytest test/test_offline_to_online.py -q: 68 passed, 2 skipped.flake8 --config=setup.cfgon all 7 modified files: passed.