[tests] refactor caching tests.#13235
Conversation
|
@DN6 LMK your thoughts on removing the caching-related stuff we have in |
|
@DN6 a gentle ping. |
|
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. |
dg845
left a comment
There was a problem hiding this comment.
Thanks for the PR! I think we should consider retaining the original MagCache tests in tests/hooks/test_mag_cache.py in some form, since if I understand correctly those tests are testing if the MagCache implementation is logically correct, while MagCacheTesterMixin is testing whether MagCache works with a given model.
|
@dg845 thanks! I added back the MagCache tests and migrated to LMK your thoughts on "Consider removing caching-related mixins from test_pipelines_common.py" as well. |
|
I also realized that the hook testing wasn't ever a part of our CI. Opened a PR #13848 |
| """ | ||
|
|
||
| @torch.no_grad() | ||
| def _test_cache_inference(self): |
There was a problem hiding this comment.
It looks like FirstBlockCacheTesterMixin._test_cache_inference and TaylorSeerCacheTesterMixin._test_cache_inference are identical except for the cache context. Would it be possible to define a _test_cache_inference_with_context method in CacheTesterMixin that takes in the context name as an argument? Maybe something like
@torch.no_grad()
def _test_cache_inference_with_context(self, context_name: str):
...There was a problem hiding this comment.
Feel free to do that in a follow-up. This PR is reserved for purely migration.
| ) | ||
|
|
||
| @torch.no_grad() | ||
| def _test_reset_stateful_cache(self): |
There was a problem hiding this comment.
Similarly to #13235 (comment), I think we may be able to define a context-aware version in CacheTesterMixin:
@torch.no_grad()
def _test_reset_stateful_cache_with_context(self, context_name: str):
...
with model.cache_context(context_name):
_ = model(**inputs_dict, return_dict=False)[0]
...and then reuse it for both FirstBlockCacheTesterMixin and TaylorSeerCacheTesterMixin.
There was a problem hiding this comment.
Same as above. If the method is fairly general, feel free to open a follow-up PR.
dg845
left a comment
There was a problem hiding this comment.
Thanks! Left some small comments.
|
With respect to the caching mixins in So I think ideally we would have testing on three levels, following MagCache:
In practice, I'm not sure what the right way to separate model tests and pipeline tests is. I think (but am not sure) that model compatibility does not necessarily imply pipeline compatibility, so pipeline-level tests are not necessarily redundant. For example, I think that testing output quality as done by |
|
Fair points esepcially because:
I think a good boundary to consider when having both or just model-level tests is if the underlying feature depends on the specifics coming from pipelines. I think quantization is one of those cases. It doesn't matter if it comes from loading a pipeline or a model. |
What does this PR do?
test_pipelines_common.py.