Dev sonic training performance - #261
Open
PoplarCrystal wants to merge 12 commits into
Open
Conversation
added 12 commits
August 25, 2026 21:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR systematically optimizes the GEAR-SONIC training pipeline by reducing unnecessary CPU/GPU transfers, device synchronizations, repeated computations, and memory operations during rollouts, environment interaction, and PPO updates.
The main changes are:
All major optimizations have configuration switches that can restore the previous behavior when required.
Motivation
The previous training path contained several high-frequency, small CPU/GPU synchronizations and repeated computations. Although each operation was relatively inexpensive in isolation, their cumulative cost became significant with many parallel environments and long training runs.
The main sources of overhead were:
This PR combines, defers, caches, or disables these operations where appropriate while preserving the training semantics.
Changes
1. Configurable Universal Token caches
The Universal Token model now supports:
cache_encoded_outputscontrols CPU debug snapshots of encoded tokens and latents.cache_full_latentcontrols the device-side full-latent cache used by optional smoothness bookkeeping.2. Shared deterministic observation cache
The following option is enabled:
Within one observation-manager
compute()call, policy and critic groups share the results of deterministic, parameter-free terms:The cache is cleared after each
compute()call and therefore never reuses observations across simulation steps.3. Fused AdamW
The optimizer is changed to:
PyTorch's fused AdamW implementation reduces the number of kernel launches during optimizer updates. The previous implementation can be restored with
optim: adamw_torch.4. Deferred episode-statistics transfers
The following option is enabled:
Instead of immediately transferring completed episode rewards and lengths to the CPU at every rollout step, the new path collects them on the GPU and performs a consolidated transfer after the rollout.
5. Fast gradient finite check
The following option is enabled:
The previous implementation inspected every parameter gradient separately for NaN and Inf values. The optimized path reuses the global gradient norm returned by gradient clipping and performs a single finite check. If the norm is not finite, gradients are still cleared and the optimizer update is skipped.
6. Configurable critic evaluation chunk size
The critic evaluation chunk size is now configurable:
Increasing the value from
1024to4096reduces chunking and dispatch overhead. It can still be adjusted for the available GPU memory.7. Optional environment action logging
The following option is added:
Environment actions are copied to the CPU and stored in
extras["env_actions"]only when explicitly requested. Workflows using callbacks such asMultiLatentSaveCallbackcan restore the previous behavior by setting this option totrue.8. Optional adaptive-sampling diagnostics
The following option is added:
Adaptive sampling continues to operate normally, but per-step minimum, maximum, and mean diagnostic statistics are disabled by default. They can be re-enabled when debugging adaptive sampling.
9. Avoid unnecessary reset synchronization
The reset condition now checks whether the relevant action-transform buffers exist before evaluating
reset_mask.any(). This avoids an unnecessary GPU synchronization when the feature is not in use.10. Faster circular-buffer updates
The following option is enabled:
The optimized Isaac Lab
CircularBufferpath:torch.rollto construct the chronological buffer view.The original Isaac Lab implementation can be restored by disabling this option.
11. Batched command-reset metric transfers
The following option is enabled:
Command metrics are stacked before being transferred to the CPU. This replaces multiple scalar transfers with one batched
values.cpu().tolist()operation and reduces device synchronization.12. Configurable PhysX GPU partitions
The environment now supports:
The configured value is propagated to
self.sim.physx.gpu_max_num_partitions. This workload uses one partition to reduce partition-management overhead. Setting it to8restores the original Isaac Lab default behavior.Configuration
The relevant optimized settings are:
Validation
Static validation
git diff --checkpasses.Performance validation
The optimized and baseline runs were compared at approximately the same wall-clock time:
The performance improvement is calculated as:
At the same elapsed time, the optimized run completed an additional:
For this benchmark configuration, training throughput increased from approximately 228.66K timesteps/s to 264.93K timesteps/s, an improvement of approximately 15.9% (1.16x).
This is an observed result for the tested configuration. The exact improvement may vary with the GPU model, number of parallel environments, model configuration, and enabled logging options.
Based on the iteration counts measured at approximately the same elapsed time (48,560 optimized versus 41,937 baseline), completing 100,000 iterations is estimated to decrease from approximately 4.0 days to 3.4 days, saving about 0.54 days (13.0 hours) and reducing the total training time by approximately 13.6%.
This is an observed result for the tested configuration. The exact improvement may vary with the GPU model, number of parallel environments, model configuration, and enabled logging options.
Scope
This PR only optimizes GEAR-SONIC training performance. It does not change:
Some diagnostic data and debug caches are now disabled by default. Workflows that depend on encoded token/latent CPU snapshots, the full-latent cache,
extras["env_actions"], or per-step adaptive-sampling diagnostics must explicitly re-enable the corresponding options.Co-authored-by: songzhan songzhan@baidu.com
Co-authored-by: bizaorong bizaorong@baidu.com