Skip to content

Commit

Permalink
LoRA test: check that all the tensors are materialized. (Lightning-AI…
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei-Aksionov authored May 7, 2024
1 parent c0d1dd0 commit e126433
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,13 @@ def test_lora_model_fsdp_init():
model = fabric.setup(model)
y = model(x)
assert y.shape == torch.Size([2, 8, 512])

# verify that all the parameters, buffers and other attributes aren't on `meta` device
for m in model.modules():
for p_name, parameter in m.named_parameters():
assert not parameter.is_meta, f"Parameter `{p_name}` isn't materialized."
for b_name, buffer in m._buffers.items():
assert not buffer.is_meta, f"Buffer `{b_name}` isn't materialized."
for attr_name, attr_value in m.__dict__.items():
if isinstance(attr_value, torch.Tensor):
assert not attr_value.is_meta, f"Attribute `{attr_name}` isn't materialized."

0 comments on commit e126433

Please sign in to comment.