mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Megacache integration (#163533)
This diff adds megacache integration for DynamoCache. Because DynamoCache requires lazy serialization, i.e. it can only be serialized once all relevant backends have been compiled and we're ready for a save, we actually do the DynamoCache saving only on a call to `torch.compiler.save_cache_artifacts`. Differential Revision: [D82735763](https://our.internmc.facebook.com/intern/diff/D82735763/) Pull Request resolved: https://github.com/pytorch/pytorch/pull/163533 Approved by: https://github.com/oulgen, https://github.com/zhxchen17
This commit is contained in:
committed by
PyTorch MergeBot
parent
53f9ae0e50
commit
b54e466fd0
@ -501,7 +501,12 @@ def save_cache_artifacts() -> Optional[tuple[bytes, "CacheInfo"]]:
|
||||
- Execute torch.compile
|
||||
- Call torch.compiler.save_cache_artifacts()
|
||||
"""
|
||||
from ._cache import CacheArtifactManager, CacheInfo
|
||||
from ._cache import CacheArtifactManager
|
||||
|
||||
if torch._dynamo.config.caching_precompile:
|
||||
from torch._dynamo.precompile_context import PrecompileContext
|
||||
|
||||
PrecompileContext.save_to_dynamo_cache()
|
||||
|
||||
return CacheArtifactManager.serialize()
|
||||
|
||||
|
@ -130,6 +130,10 @@ class CacheInfo:
|
||||
def pgo_artifacts(self) -> list[str]: # type: ignore[empty-body]
|
||||
...
|
||||
|
||||
@property
|
||||
def precompile_artifacts(self) -> list[str]: # type: ignore[empty-body]
|
||||
...
|
||||
|
||||
def add(self, artifact: CacheArtifact) -> None:
|
||||
self.artifacts[artifact.type()].append(artifact.key)
|
||||
|
||||
@ -307,6 +311,7 @@ class CacheArtifactManager:
|
||||
cache artifacts are registered in the cache registry. This is done by
|
||||
simply importing all the cache artifacts already wrapped with register call.
|
||||
"""
|
||||
from torch._dynamo.package import PrecompileCacheArtifact # noqa: F401
|
||||
from torch._dynamo.pgo import PGOCacheArtifact # noqa: F401
|
||||
from torch._functorch._aot_autograd.autograd_cache import ( # noqa: F401
|
||||
AOTAutogradCacheArtifact,
|
||||
|
Reference in New Issue
Block a user