Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a refactored modeling_act for cpu and memory optimization #569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eDeveloperOZ
Copy link

Performance Optimization: Replace .to() Operations with Buffer Management

What this does

This PR optimizes tensor operations in the ACT Policy implementation by replacing unnecessary .to() device transfers with proper buffer management. The changes focus on improving memory efficiency and reducing CPU overhead while maintaining training performance.

Label: ⚡️ Performance

Key changes:

  1. Added registered buffers for frequently used tensors
  2. Pre-computed tensors during initialization
  3. Implemented buffer templates for repeated operations
  4. Optimized memory allocations using expansion instead of creation

How it was tested

The changes were thoroughly tested through:

  1. Full training runs comparing baseline vs optimized implementation
  2. Performance metrics monitoring showing:
  • ~50% reduction in CPU utilization (from ~2% to ~1%)
  • More stable memory usage pattern around 2000MB
  • Maintained training convergence and loss curves
  • Consistent or improved data loading times

All standard tests pass without modification as functionality remains unchanged.

Performance Results

Key metrics show significant improvements:

# CPU Usage
# Before: ~2% average utilization
# After:  ~1% average utilization

# Memory Pattern
# Before: Variable usage with frequent fluctuations
# After:  Stable ~2000MB with smoother allocation pattern

# Training Performance
# - Loss curves maintain expected convergence
# - Data loading times: No degradation
# - Update times: Consistent with baseline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant