Skip to content

Commit 95fb084

Browse files
authored
add work-around for pytorch/ao#1871 (#205)
1 parent 3ce0c58 commit 95fb084

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/olmo_core/float8/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ def convert_to_float8_training(
7474
if not self.enabled:
7575
return
7676

77+
# NOTE: there's a bug with `Float8Linear.from_float()` where it will override `requires_grad=False`
78+
# when `enable_fsdp_float8_all_gather=True`. So we have to reset frozen params after the fact.
79+
# https://github.com/pytorch/ao/issues/1871
80+
frozen_params: Set[str] = set()
81+
for n, p in model.named_parameters():
82+
if not p.requires_grad:
83+
frozen_params.add(n)
84+
7785
self.config.convert_to_float8_training(model, modules_to_ignore=modules_to_ignore)
7886

87+
for n in frozen_params:
88+
p = model.get_parameter(n)
89+
p.requires_grad = False
90+
7991
def precompute_float8_dynamic_scale_for_fsdp(self, model: Union[nn.Module, List[nn.Module]]):
8092
if not self.enabled:
8193
return

0 commit comments

Comments
 (0)