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

Function join

examples/update.py:131–159  ·  view source on GitHub ↗
(
    ps: ParameterServer,
    checkpoint_name: str,
    load_metas_file: str | None,
    metas_url: str | None,
    req_func: Callable[[list[tuple[str, str]]], None],
    inference_parallel_size: int,
    endpoint: str,
    uds: str | None = None,
)

Source from the content-addressed store, hash-verified

129
130
131def join(
132 ps: ParameterServer,
133 checkpoint_name: str,
134 load_metas_file: str | None,
135 metas_url: str | None,
136 req_func: Callable[[list[tuple[str, str]]], None],
137 inference_parallel_size: int,
138 endpoint: str,
139 uds: str | None = None,
140):
141 if load_metas_file:
142 with open(load_metas_file, "rb") as f:
143 metas = _METAS_ADAPTER.validate_json(f.read())
144 elif metas_url:
145 resp = httpx.get(metas_url, timeout=300.0)
146 resp.raise_for_status()
147 metas = _METAS_ADAPTER.validate_json(resp.content)
148 else:
149 raise ValueError("either load_metas_file or metas_url is required")
150 ps.init_process_group()
151 check_vllm_ready(endpoint, inference_parallel_size, uds)
152 dist.barrier()
153 with timer("Gather metas before join"):
154 ps.gather_metas(checkpoint_name)
155 ps.load_metas(metas)
156 with timer(
157 f"Update weights with setting ranks as range(0, {inference_parallel_size}) by using p2p"
158 ):
159 ps.update(checkpoint_name, req_func, ranks=list(range(inference_parallel_size)))
160
161
162if __name__ == "__main__":

Callers 1

update.pyFile · 0.85

Calls 7

check_vllm_readyFunction · 0.85
timerFunction · 0.85
gather_metasMethod · 0.80
load_metasMethod · 0.80
updateMethod · 0.80
init_process_groupMethod · 0.45
barrierMethod · 0.45

Tested by

no test coverage detected