Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion galai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

def load_model(
name: str,
cache_dir: str,
dtype: Union[str, torch.dtype] = None,
num_gpus: int = None,
parallelize: bool = False
Expand Down Expand Up @@ -128,6 +129,6 @@ def load_model(
tensor_parallel=parallelize,
)
model._set_tokenizer(hf_model)
model._load_checkpoint(checkpoint_path=hf_model)
model._load_checkpoint(checkpoint_path=hf_model, cache_dir=cache_dir)

return model
3 changes: 2 additions & 1 deletion galai/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
self.max_input_length = 2020
self._master_port = None

def _load_checkpoint(self, checkpoint_path: str):
def _load_checkpoint(self, checkpoint_path: str, cache_dir: str):
"""
Loads the checkpoint for the model

Expand All @@ -108,6 +108,7 @@ def _load_checkpoint(self, checkpoint_path: str):

self.model = OPTForCausalLM.from_pretrained(
checkpoint_path,
cache_dir=cache_dir,
torch_dtype=self.dtype,
low_cpu_mem_usage=True,
device_map=device_map,
Expand Down