Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions torchao/float8/fsdp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,15 @@ def __repr__(self):
return f"WeightWithDynamicFloat8CastTensor(tensor={self._tensor}, linear_mm_config={self._linear_mm_config}, dtype={self._dtype})"

def fsdp_pre_all_gather(self, mesh):
if self._precomputed_scale is not None:
# Snapshot once: `_precomputed_scale` may be re-assigned by
# `precompute_float8_dynamic_scale_for_fsdp` between iterations, and
# under free-threaded CPython we must not read the attribute twice in
# the if/use pair.
precomputed_scale = self._precomputed_scale
if precomputed_scale is not None:
float8_training_tensor = hp_tensor_and_scale_to_float8(
self._tensor,
self._precomputed_scale,
precomputed_scale,
self._dtype,
self._linear_mm_config,
GemmInputRole.WEIGHT,
Expand Down
Loading