[FEATURE] Add Automatic Mixed Precision option#108
Open
mwulfman wants to merge 1 commit into
Open
Conversation
Owner
|
Thanks for submitting this PR, that looks like a really nice speedup! I wonder if it is possible to simplify the control flow. Instead of using a loss factory and calling autocast in the optimizer, we could put autocast around MimicKit/mimickit/learning/base_agent.py Line 238 in aeb7de9 That way, all of the operations for model updates will be performed in mixed precision. This could help to simplify the code, and avoid the need for loss factories. Also, "amp" conflicts with adversarial motion priors. So instead of using I haven't used mixed precision before. But it seems like |
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.
Proposal
I'm proposing adding an option to enable Automatic Mixed Precision (AMP) in order to improve training throughput with minimal code changes.
Results
To validate the implementation, I benchmarked training before and after enabling AMP with:
python mimickit/run.py \ --mode train \ --num_envs 2048 \ --engine_config data/engines/isaac_lab_engine.yaml \ --env_config data/envs/deepmimic_humanoid_env.yaml \ --agent_config data/agents/deepmimic_humanoid_ppo_agent.yaml \ --visualize false \The only configuration change was enabling in the current branch:
Using the additional logging introduced in #107, I obtained the following results on an NVIDIA GeForce RTX 5070 Ti Laptop GPU.
Before Automatic Mixed Precision:
After Automatic Mixed Precision:
This corresponds to +70% increase in training throughput.
Changes done:
MPOptimizerto support Automatic Mixed Precision (AMP) with both"fp16"and"bf16"modes_update_actorand_update_criticmethods to pass aloss_factorytooptimizer.step, allowing the forward pass and loss computation to run under AMP autocast