[Bugfix] Wait for the linear bias before layerwise online processing (#49805)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-07-25 17:56:32 +00:00
committed by GitHub
co-authored by Claude Opus 5
parent 26d725c334
commit 9321aff536
4 changed files with 67 additions and 10 deletions
@@ -20,20 +20,23 @@ __all__ = [
"get_numel_loaded",
]
# Modules whose tensors are never moved to, or materialized from, the meta device.
SKIP_MODULES: set[str] = {"HadamardTransform"}
SKIP_TENSORS: set[str] = {
# Tensors never loaded by a weight loader, so the layerwise trigger ignores them.
SKIP_LOAD_TENSORS: set[str] = {
"_expert_map",
"expert_mask",
"expert_global_to_physical",
"expert_physical_to_global",
"expert_local_to_global",
"e_score_correction_bias",
# Built after create_weights(), so it is not tracked by the layerwise-reload
# trigger and would be re-materialized into uninitialized memory. Skip it.
"bias",
}
# Tensors which are never moved to, or materialized from, the meta device.
# `bias` is built after create_weights(), so it is never on meta to begin with.
SKIP_TENSORS: set[str] = SKIP_LOAD_TENSORS | {"bias"}
def to_meta_tensor(tensor: torch.Tensor) -> torch.Tensor:
"""Convert a tensor to a meta tensor while preserving class and attributes."""