[Core] Implement sharded state loader (#4690)

Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
This commit is contained in:
Aurick Qiao
2024-05-15 22:11:54 -07:00
committed by GitHub
co-authored by Woosuk Kwon
parent 52f8107cf2
commit 30e754390c
7 changed files with 351 additions and 0 deletions
+12
View File
@@ -119,6 +119,18 @@ class Worker(WorkerBase):
def load_model(self):
self.model_runner.load_model()
def save_sharded_state(
self,
path: str,
pattern: Optional[str] = None,
max_size: Optional[int] = None,
) -> None:
self.model_runner.save_sharded_state(
path,
pattern=pattern,
max_size=max_size,
)
@torch.inference_mode()
def determine_num_available_blocks(self) -> Tuple[int, int]:
"""Profiles the peak memory usage of the model to determine how many