MCPcopy Create free account
hub / github.com/MoonshotAI/checkpoint-engine / split_checkpoint_files

Function split_checkpoint_files

examples/update.py:51–57  ·  view source on GitHub ↗
(checkpoint_path: str, rank: int, world_size: int)

Source from the content-addressed store, hash-verified

49
50
51def split_checkpoint_files(checkpoint_path: str, rank: int, world_size: int) -> list[str]:
52 checkpoint_files = [
53 os.path.join(checkpoint_path, f)
54 for f in filter(lambda x: x.endswith(".safetensors"), os.listdir(checkpoint_path))
55 ]
56 files_per_rank = (len(checkpoint_files) + world_size - 1) // world_size
57 return checkpoint_files[rank * files_per_rank : (rank + 1) * files_per_rank]
58
59
60def split_tensors(checkpoint_path: str, rank: int, world_size: int) -> dict[str, torch.Tensor]:

Callers 1

update.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected