Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does a few things.
make_bulk_array
that combines the lists ofDeviceArray
s into bulkDeviceArray
s. E.g.,obs
is a list containingargs.num_steps * args.async_update
instances ofDeviceArray
s, andmake_bulk_array
combines them into a singleDeviceArray
. This makes data transfer from the actor's device to the learner's device faster — instead of makingMemcpyP2P
ofargs.num_steps * args.async_update
times, we do it just one time. Related Why does device-to-device transfer (`DevicePut`) block computation in another thread? google/jax#14693envs = make_env(args.env_id, args.seed, args.local_num_envs, args.async_batch_size)()
toenvs = make_env(args.env_id, args.seed + jax.process_index(), args.local_num_envs, args.async_batch_size)()
. While this change does not matter whenargs.async_batch_size != args.local_num_envs
, when they are equal, the seeds are essentially the same across replicated processes and are respected by envpool, which is bad: we will be dealing with the same data in different processes.Both changes do not impact sample efficiency performance, so benchmark rerun is unnecessary.