Skip to navigation

nemo_automodel.components.models.glm5_next.parallelization

View as MarkdownOpen in Claude

Keep GLM-5.3’s tiny FP32 holders gathered between forward and backward.

Module Contents

Classes

NameDescription
Glm5NextModelParallelizerRetain native FSDP gradient reduction for gathered FP32 holders.

Data

PARALLELIZER

API

class nemo_automodel.components.models.glm5_next.parallelization.Glm5NextModelParallelizer()

Bases: ModelParallelizer

Retain native FSDP gradient reduction for gathered FP32 holders.

nemo_automodel.components.models.glm5_next.parallelization.Glm5NextModelParallelizer._fully_shard_module(
module: torch.nn.Module,
mesh: torch.distributed.device_mesh.DeviceMesh,
mp_policy: torch.distributed.fsdp.MixedPrecisionPolicy,
offload_policy: torch.distributed.fsdp.OffloadPolicy | None = None,
reshard_after_forward: bool | int | None = None,
ignored_params: set[torch.nn.Parameter] | None = None
) -> torch.nn.Module

Apply FSDP, retaining only the small model-owned FP32 holders.

Parameters:

module
nn.Module

Native module to shard. Only the mHC and KDA FP32 parameter holders override the caller’s reshard policy.

mesh
DeviceMesh

Existing FSDP mesh, unchanged for holder parameters.

mp_policy
MixedPrecisionPolicy

Existing compute/reduction precision policy.

offload_policy
OffloadPolicy | NoneDefaults to None

Existing parameter/gradient offload policy.

reshard_after_forward
bool | int | NoneDefaults to None

Caller policy for every non-holder module.

ignored_params
set[nn.Parameter] | NoneDefaults to None

Parameters already owned by another parallelism boundary; their membership is preserved.

Returns: nn.Module

The module wrapped by the native FSDP2 primitive.

nemo_automodel.components.models.glm5_next.parallelization.PARALLELIZER = Glm5NextModelParallelizer()