CombinedOptimizer (TorchRec)

This API is an open-source API of the TorchRec and is not an external API of the Rec SDK Torch. This section describes the parameter ranges supported by the TorchRec APIs called when the Rec SDK Torch is used.

Function

Combine multiple optimizers into one.

Prototype

1
2
class CombinedOptimizer:
    def __init__(**kwargs)

Parameters

Parameter

Type

Mandatory/Optional

Description

optims

  • List[KeyedOptimizer]
  • List[Tuple[str, KeyedOptimizer]]

Mandatory

List of optimizers to be combined. The list can be empty.

Ensure that the input value comes from CombinedOptimizer (TorchRec) or DistributedModelParallel (TorchRec).

Return Value

  • Success: The optimizer after combination is returned.
  • Failure: An exception is thrown.

Example

1
2
from torchrec.optim.keyed import CombinedOptimizer
optimizer = CombinedOptimizer([ddp_model.fused_optimizer])

See Also

For details about the API call sequence and example, see Porting and Training.