forked from areal-project/AReaL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraining_adapter.py
More file actions
86 lines (69 loc) · 2.4 KB
/
Copy pathtraining_adapter.py
File metadata and controls
86 lines (69 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Protocol, runtime_checkable
import torch
@runtime_checkable
class AwexTrainingAdapter(Protocol):
"""Protocol for training-side weight update adapters."""
@property
def parallelism_strategy(self) -> dict:
"""Report parallelism strategy.
Returns dict with world_size, tp_size, pp_size, dp_size, ep_size.
"""
...
def get_weight_metadata(self) -> list:
"""Extract this worker's parameter shard metadata in awex format.
Returns list[ParameterMeta].
"""
...
def get_local_shard_parameters(
self, required_names: list[str] | None = None
) -> dict[str, torch.Tensor]:
"""Return local shard tensors in canonical HF naming."""
...
def init_weight_update_group(
self,
pair_name: str,
master_addr: str,
master_port: int,
transfer_rank: int,
world_size: int,
kv_store_url: str,
infer_world_size: int,
train_world_size: int,
num_engines: int,
) -> None:
"""Pull peer meta from KV store, build local send plan, join NCCL group."""
...
def execute_weight_update(self, version: int) -> None:
"""Execute cached local P2P send plan."""
...
def batch_isend_irecv(self, **kwargs) -> None:
"""Execute awex batch P2P send/recv operations."""
...
def teardown_weight_update_group(self) -> None:
"""Destroy NCCL group and clear cached state."""
...
def init_colocate_weight_update(
self,
pair_name: str,
kv_store_url: str,
transfer_rank: int,
infer_world_size: int,
train_world_size: int,
num_engines: int,
master_port: int,
admin_api_key: str = "areal-admin-key",
timeout_s: float = 120.0,
) -> None:
"""Register device info in KV store for colocated weight transfer."""
...
def execute_colocate_weight_update(self, version: int) -> None:
"""Serialize weights via IPC and put to KV store."""
...
def release_memory(self, tags: list[str] | None = None) -> None:
"""Release GPU memory (optimizer/weights) for colocated mode."""
...
def resume_memory(self, tags: list[str] | None = None) -> None:
"""Resume GPU memory occupation."""
...