Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoRA test: check that all the tensors are materialized. #1395

Merged
merged 1 commit into from
May 7, 2024
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
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."
Andrei-Aksionov marked this conversation as resolved.
Show resolved Hide resolved