-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[tests] add test for hotswapping + compilation on resolution changes #11825
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
base: main
Are you sure you want to change the base?
Conversation
Cc: @StrongerXi and @anijain2305 as well. |
@@ -1350,7 +1350,6 @@ def test_model_parallelism(self): | |||
new_model = self.model_class.from_pretrained(tmp_dir, device_map="auto", max_memory=max_memory) | |||
# Making sure part of the model will actually end up offloaded | |||
self.assertSetEqual(set(new_model.hf_device_map.values()), {0, 1}) | |||
print(f" new_model.hf_device_map:{new_model.hf_device_map}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated but hopefully okay :-)
if different_resolutions is not None: | ||
for height, width in self.different_shapes_for_compilation: | ||
new_inputs_dict = self.prepare_dummy_input(height=height, width=width) | ||
_ = model(**new_inputs_dict) | ||
else: | ||
output0_after = model(**inputs_dict)["sample"] | ||
assert torch.allclose(output0_before, output0_after, atol=tol, rtol=tol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need assertions when testing for different shapes as that would make the test unnecessarily complicated. We just check for recompilations.
different_shapes_for_compilation = self.different_shapes_for_compilation | ||
if different_shapes_for_compilation is None: | ||
pytest.skip(f"Skipping as `different_shapes_for_compilation` is not set for {self.__class__.__name__}.") | ||
torch.fx.experimental._config.use_duck_shape = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very important!
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
What does this PR do?
As promised :)