Skip to content

Wire DDP train-module gradient clipping and remove retired apply_ddp code - #881

Merged
AkshitaB merged 3 commits into
mainfrom
akshitab/ddp-grad-norm-cleanup
Sep 25, 2026
Merged

AkshitaB merged 3 commits into
mainfrom
akshitab/ddp-grad-norm-cleanup

Conversation

@AkshitaB

@AkshitaB AkshitaB commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

OLMoDDPTrainModuleConfig.max_grad_norm was accepted but ignored: clipping used only the optimizer threshold. An explicit train-module value now overrides the optimizer threshold at build time, keeping the configuration field consistent with TransformerTrainModuleConfig. When the field is None, the optimizer threshold is retained. The override uses a copy and does not mutate the supplied optimizer config.

The nine DDP recipes retain their train-module setting of 1.0, matching their previous effective optimizer threshold. Old configs still load; if an explicit train-module value differs from the optimizer value, the train-module value now takes precedence. Clipping still runs inside the DDP optimizer. Remove the unused train-module constructor argument and attribute.

Also replace OLMoDDPModel.apply_ddp()'s assertion and unreachable implementation with NotImplementedError directing callers to apply_dp(). This keeps the rejection active under python -O and removes the unused replicate import. Regular Transformer DDP and clipping behavior are unchanged. Updated the changelog.

Stacked on #879; base is akshitab/remove-model-ladder.

Validation:

  • DDP train-module and config tests: 34 passed, 3 GPU tests skipped. Includes JSON round-trips, explicit/missing clipping thresholds, conflicting values, zero thresholds, nonmutation, and distributed CPU construction.
  • Formatting, Ruff, mypy (538 source files), and git diff --check passed.
  • Earlier apply_ddp validation: 2 model tests passed; explicit rejection checked under normal Python and python -O.

@AkshitaB
AkshitaB added this pull request to stack #880 September 23, 2026 22:40
@AkshitaB AkshitaB changed the title Remove unused DDP train-module gradient clipping option Clean up unused DDP clipping option and retired apply_ddp implementation Sep 23, 2026

@CalebOuellette CalebOuellette left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like TransformerTrainModuleConfig also has max_grad_norm, and that is still in use. So getting a slight drift in API between OLMoDDPTrainModuleConfig and TransformerTrainModuleConfig.

@AkshitaB AkshitaB changed the title Clean up unused DDP clipping option and retired apply_ddp implementation Wire DDP train-module gradient clipping and remove retired apply_ddp code Sep 23, 2026
@AkshitaB

Copy link
Copy Markdown
Contributor Author

It looks like TransformerTrainModuleConfig also has max_grad_norm, and that is still in use. So getting a slight drift in API between OLMoDDPTrainModuleConfig and TransformerTrainModuleConfig.

@CalebOuellette yeah, you're right. We now wire the value from train_module to the optim config.

@AkshitaB
AkshitaB force-pushed the akshitab/ddp-grad-norm-cleanup branch from 11f1174 to 00a7810 Compare September 25, 2026 14:29
Base automatically changed from akshitab/remove-model-ladder to main September 25, 2026 14:43
@AkshitaB
AkshitaB force-pushed the akshitab/ddp-grad-norm-cleanup branch from 00a7810 to c760358 Compare September 25, 2026 14:43
@AkshitaB
AkshitaB merged commit 718d08f into main Sep 25, 2026
25 checks passed
@AkshitaB
AkshitaB deleted the akshitab/ddp-grad-norm-cleanup branch September 25, 2026 18:03
jason718 added a commit that referenced this pull request Sep 26, 2026
Second merge of main into this sync branch, taking main from 0589a03 to
718d08f.

Conflicts:
- nn/attention/__init__.py: take main's removal of FusedAttention (#873).
  Vision's only changes to it were NotImplementedError guards for
  or_mask/and_mask/position_ids; FusedAttentionV2 subclasses Attention and
  already threads position_ids. Keep vision's Dict import.
- nn/transformer/model.py: activation checkpointing preserves RNG state when
  dropout is active (vision, #828) or EMO routing needs segment IDs (main,
  #872), which also resolves main's "preserve RNG state if dropout is active"
  TODO.
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

This PR has been released in v3.0.0.

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.

2 participants