Optimizer config and MRS wrapper for shampoo v3 in MVAI#4168
Open
Shagun-G wants to merge 1 commit intometa-pytorch:mainfrom
Open
Optimizer config and MRS wrapper for shampoo v3 in MVAI#4168Shagun-G wants to merge 1 commit intometa-pytorch:mainfrom
Shagun-G wants to merge 1 commit intometa-pytorch:mainfrom
Conversation
Summary: ## Summary `[mvai][shampoo][v3] Optimizer config and MRS wrapper for shampoo v3 in MVAI` This diff introduces the initial scaffolding for Shampoo V3 support in MVAI: - **`ShampooV3Config`** (`fbcode/minimal_viable_ai/core/model_family_api/optimizer_configs.py`): a thin pass-through dataclass that holds the V3 backend's own dataclasses (preconditioner, grafting, iterate-averaging, distributed, weight-decay-type, PT2 compile, and runtime configs) directly, instead of re-hoisting individual fields like `ShampooV2Config` does. Includes an inline migration guide documenting the field-by-field translation from `ShampooV2Config` → `ShampooV3Config` (removed knobs, replacements, and net-new V3 options). - **`V3MRSDistributedShampoo`** (`fbcode/torchrec/fb/optim/shampoo_wrapper.py`): an MRS wrapper subclass that adds the `mrs_class_exception_decorator` and Clippy update-direction shrinkage on top of the V3 `DistributedShampoo`. Asserts that legacy V2-only knobs (`exponent_multiplier`, `inv_root_override`) remain at defaults so V2 call sites don't silently break when migrating. - **Optimizer plumbing** (`fbcode/minimal_viable_ai/core/model_family_api/optimizer.py`) to wire `ShampooV3Config` through the MFA optimizer factory into `V3MRSDistributedShampoo`. - **Unit tests** (`fbcode/minimal_viable_ai/core/model_family_api/tests/optimizer_test.py`) covering the new config and wrapper paths. - Minor touch in `fbcode/torchrec/distributed/embedding_types.py` to expose what V3 needs. ### Changes still needed 1. Incorporate `ClassicalMomentumConfig` in the wrapper (currently the iterate-averaging path is plumbed generically; need to ensure the classical-momentum config is accepted, validated, and forwarded to the V3 backend). 2. Re-link the wrapper and config to the new **V3 folder** instead of `hpc.optimizers.distributed_shampoo.dev`, and update the `ShampooV3Config` docstring / migration guide imports to reference the V3 module paths. Reviewed By: renyiryry Differential Revision: D102011378
Contributor
|
@Shagun-G has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102011378. |
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.
Summary:
Summary
[mvai][shampoo][v3] Optimizer config and MRS wrapper for shampoo v3 in MVAIThis diff introduces the initial scaffolding for Shampoo V3 support in MVAI:
ShampooV3Config(fbcode/minimal_viable_ai/core/model_family_api/optimizer_configs.py): a thin pass-through dataclass that holds the V3 backend's own dataclasses (preconditioner, grafting, iterate-averaging, distributed, weight-decay-type, PT2 compile, and runtime configs) directly, instead of re-hoisting individual fields likeShampooV2Configdoes. Includes an inline migration guide documenting the field-by-field translation fromShampooV2Config→ShampooV3Config(removed knobs, replacements, and net-new V3 options).V3MRSDistributedShampoo(fbcode/torchrec/fb/optim/shampoo_wrapper.py): an MRS wrapper subclass that adds themrs_class_exception_decoratorand Clippy update-direction shrinkage on top of the V3DistributedShampoo. Asserts that legacy V2-only knobs (exponent_multiplier,inv_root_override) remain at defaults so V2 call sites don't silently break when migrating.fbcode/minimal_viable_ai/core/model_family_api/optimizer.py) to wireShampooV3Configthrough the MFA optimizer factory intoV3MRSDistributedShampoo.fbcode/minimal_viable_ai/core/model_family_api/tests/optimizer_test.py) covering the new config and wrapper paths.fbcode/torchrec/distributed/embedding_types.pyto expose what V3 needs.Changes still needed
ClassicalMomentumConfigin the wrapper (currently the iterate-averaging path is plumbed generically; need to ensure the classical-momentum config is accepted, validated, and forwarded to the V3 backend).hpc.optimizers.distributed_shampoo.dev, and update theShampooV3Configdocstring / migration guide imports to reference the V3 module paths.Reviewed By: renyiryry
Differential Revision: D102011378