• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

meta-pytorch / opacus / 18991181496
80%

Build:
DEFAULT BRANCH: main
Ran 01 Nov 2025 04:15AM UTC
Jobs 3
Files 135
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

27 Oct 2025 03:40PM UTC coverage: 78.17% (-2.2%) from 80.408%
18991181496

push

github

meta-codesync[bot]
Evgri243/multi device models (#796)

Summary:
## Types of changes

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Docs change / refactoring / dependency upgrade

## Motivation and Context / Related issue

This PR adds support for multi-device training scenarios where model parameters are distributed across multiple GPU devices (e.g., when assigning different layers directly with `module.to(device[I])` oe using `device_map="auto"` with accelerate).

**Problem solved:**
When training large models that don't fit on a single GPU, parameters and gradients can be spread across multiple devices. The existing Opacus optimizers and gradient clipping modules assumed all tensors were on the same device, causing runtime errors during norm computation and gradient clipping operations.

**Changes:**
1. **Sequential multi-device execution support (https://github.com/meta-pytorch/opacus/issues/9)**: Modified `DPOptimizer` and `AdaClipDPOptimizer` to move tensors to appropriate devices before operations like `torch.stack()` and `torch.einsum()`, preventing device mismatch errors during gradient clipping and accumulation.

2. **Multi-device support in GradSampleModuleFastGradientClipping (https://github.com/meta-pytorch/opacus/issues/10)**: Extended multi-device handling to `GradSampleModuleFastGradientClipping`, `DPPerLayerOptimizer`, and additional edge cases in optimizers that were previously uncovered.

## How Has This Been Tested

- The code was used to train 7B Zetta model with LoRA on 8xH200 GPU node.
- Added test suite in `multidevice_optimizer_test.py` covering:
  - `DPOptimizer`, `AdaClipDPOptimizer`, and `DPPerLayerOptimizer` with multi-device models
  - Both `clip_and_accumulate()` and full `step()` operations
  - Helper function `_clip_and_accumulate_parameter()` with multi-device paramete... (continued)

40 of 252 new or added lines in 5 files covered. (15.87%)

5672 of 7256 relevant lines covered (78.17%)

1.74 hits per line

Uncovered Changes

Lines Coverage ∆ File
151
14.69
opacus/tests/multidevice_optimizer_test.py
56
80.07
-19.93% opacus/tests/grad_sample_module_fast_gradient_clipping_test.py
5
22.58
-1.56% opacus/optimizers/adaclipoptimizer.py
Jobs
ID Job ID Ran Files Coverage
1 run-1 - 18991181496.1 01 Nov 2025 04:22AM UTC 134
77.93
GitHub Action Run
2 run-3 - 18991181496.2 01 Nov 2025 04:15AM UTC 72
47.93
GitHub Action Run
3 run-2 - 18991181496.3 01 Nov 2025 04:21AM UTC 134
77.92
GitHub Action Run
Source Files on build 18991181496
  • Tree
  • List 135
  • Changed 4
  • Source Changed 4
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #18991181496
  • 7dbbb400 on github
  • Prev Build on main (#18790895690)
  • Next Build on main (#19007137572)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc