Skip to content

Add cautious weight decay transformation#1611

Open
tinker495 wants to merge 1 commit intogoogle-deepmind:mainfrom
tinker495:feature/add-cwd
Open

Add cautious weight decay transformation#1611
tinker495 wants to merge 1 commit intogoogle-deepmind:mainfrom
tinker495:feature/add-cwd

Conversation

@tinker495
Copy link
Contributor

Summary

  • Add add_cautious_weight_decay to optax.contrib, implementing Cautious Weight Decay (Chen et al., 2025)
  • Unlike standard weight decay, decay is applied only when sign(update) == sign(param), preventing decay from conflicting with the gradient direction
  • Supports scalar weight decay, callable schedules, and parameter masking

Changes

File Description
optax/contrib/_cwd.py New add_cautious_weight_decay transformation
optax/contrib/_cwd_test.py Unit tests (alignment, mask, schedule)
optax/contrib/__init__.py Export add_cautious_weight_decay
optax/contrib/_common_test.py Integration with shared contrib test suite

Test plan

  • pytest optax/contrib/_cwd_test.py — dedicated unit tests
  • pytest optax/contrib/_common_test.py — shared contrib tests with CWD as wrapper
  • ruff lint check passes

@google-cla
Copy link

google-cla bot commented Feb 28, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Implement `add_cautious_weight_decay`, which applies weight decay only
when the sign of the update and parameter are aligned (Chen et al., 2025).

Reference: https://arxiv.org/abs/2510.12402
@rdyro
Copy link
Collaborator

rdyro commented Mar 5, 2026

Hey, we really appreciate the contribution! This is a lot of code which might be difficult to maintain with our small team of maintainers and so this might take us a while to merge.

I'll try to get to this as soon as possible, thanks!

(As I wrote in your other PR)

@vroulet vroulet self-assigned this Mar 5, 2026
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.

3 participants