libinephany 1.1.2__py3-none-any.whl → 1.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libinephany/pydantic_models/schemas/inner_task_profile.py +39 -55
- {libinephany-1.1.2.dist-info → libinephany-1.1.3.dist-info}/METADATA +1 -1
- {libinephany-1.1.2.dist-info → libinephany-1.1.3.dist-info}/RECORD +6 -6
- {libinephany-1.1.2.dist-info → libinephany-1.1.3.dist-info}/WHEEL +0 -0
- {libinephany-1.1.2.dist-info → libinephany-1.1.3.dist-info}/licenses/LICENSE +0 -0
- {libinephany-1.1.2.dist-info → libinephany-1.1.3.dist-info}/top_level.txt +0 -0
@@ -7,8 +7,15 @@
|
|
7
7
|
import math
|
8
8
|
from typing import Any, Callable
|
9
9
|
|
10
|
-
from
|
11
|
-
|
10
|
+
from pydantic import BaseModel
|
11
|
+
|
12
|
+
# ======================================================================================================================
|
13
|
+
#
|
14
|
+
# CONSTANTS
|
15
|
+
#
|
16
|
+
# ======================================================================================================================
|
17
|
+
|
18
|
+
VRAM_USAGES_KEY = "vram_usages"
|
12
19
|
|
13
20
|
# ======================================================================================================================
|
14
21
|
#
|
@@ -20,26 +27,40 @@ from pydantic import BaseModel, field_validator
|
|
20
27
|
class InnerTaskProfile(BaseModel):
|
21
28
|
|
22
29
|
inner_task_name: str
|
30
|
+
|
23
31
|
number_of_agents: int
|
24
32
|
number_of_layers: int
|
33
|
+
number_of_parameters: int
|
34
|
+
|
25
35
|
observation_space_sizes: dict[str, int]
|
26
36
|
action_space_sizes: dict[str, int]
|
27
|
-
number_of_parameters: int
|
28
|
-
vram_usage: float
|
29
|
-
idle_vram_usage: float
|
30
|
-
hparam_overrides: dict[str, dict[str, Any]] | None = None
|
31
37
|
|
32
|
-
|
33
|
-
|
38
|
+
vram_usages: dict[int, tuple[float, float]] | None = None
|
39
|
+
expected_vram_usage: float | None = None
|
40
|
+
expected_idle_vram_usage: float | None = None
|
41
|
+
max_batch_size_override: int | None = None
|
42
|
+
|
43
|
+
@property
|
44
|
+
def vram_usage(self) -> float:
|
45
|
+
"""
|
46
|
+
:return: VRAM usage at the max batch size.
|
47
|
+
"""
|
48
|
+
|
49
|
+
if self.expected_vram_usage is None:
|
50
|
+
return float("nan")
|
51
|
+
|
52
|
+
return self.expected_vram_usage
|
53
|
+
|
54
|
+
@property
|
55
|
+
def idle_vram_usage(self) -> float:
|
34
56
|
"""
|
35
|
-
:
|
36
|
-
:return: Either the given float value or NaN.
|
57
|
+
:return: Idle VRAM usage at the max batch size.
|
37
58
|
"""
|
38
59
|
|
39
|
-
if
|
60
|
+
if self.expected_idle_vram_usage is None:
|
40
61
|
return float("nan")
|
41
62
|
|
42
|
-
return
|
63
|
+
return self.expected_idle_vram_usage
|
43
64
|
|
44
65
|
@property
|
45
66
|
def failed_to_profile(self) -> bool:
|
@@ -49,19 +70,18 @@ class InnerTaskProfile(BaseModel):
|
|
49
70
|
|
50
71
|
return math.isnan(self.vram_usage)
|
51
72
|
|
52
|
-
def
|
73
|
+
def model_dump(self, **kwargs) -> dict[str, Any]:
|
53
74
|
"""
|
54
75
|
:param kwargs: Standard Pydantic model dump kwargs.
|
55
76
|
:return: Dump result of the superclass' method.
|
56
77
|
"""
|
57
78
|
|
58
|
-
|
59
|
-
f"Inner task {self.inner_task_name} consumed {self.vram_usage:.3f} MB of VRAM while training and "
|
60
|
-
f"{self.idle_vram_usage:.3f} MB of VRAM while idle. It has {self.number_of_agents} agents across "
|
61
|
-
f"{self.number_of_layers} inner model layers."
|
62
|
-
)
|
79
|
+
super_dump = super().model_dump(**kwargs)
|
63
80
|
|
64
|
-
|
81
|
+
if self.vram_usages is not None:
|
82
|
+
super_dump[VRAM_USAGES_KEY] = {k: list(v) for k, v in self.vram_usages.items()}
|
83
|
+
|
84
|
+
return super_dump
|
65
85
|
|
66
86
|
|
67
87
|
class InnerTaskProfiles(BaseModel):
|
@@ -235,42 +255,6 @@ class InnerTaskProfiles(BaseModel):
|
|
235
255
|
|
236
256
|
return inner_task_name in self.profiles
|
237
257
|
|
238
|
-
def add_profile(
|
239
|
-
self,
|
240
|
-
inner_task_name: str,
|
241
|
-
number_of_agents: int,
|
242
|
-
number_of_layers: int,
|
243
|
-
observation_space_sizes: dict[str, int],
|
244
|
-
action_space_sizes: dict[str, int],
|
245
|
-
number_of_parameters: int,
|
246
|
-
vram_usage: float,
|
247
|
-
idle_vram_usage: float,
|
248
|
-
hparam_overrides: dict[str, dict[str, Any]] | None = None,
|
249
|
-
) -> None:
|
250
|
-
"""
|
251
|
-
:param inner_task_name: Name of the inner task to add a profile for.
|
252
|
-
:param number_of_agents: Number of agents active in the inner task's environment.
|
253
|
-
:param number_of_layers: Number of layers in the inner model.
|
254
|
-
:param observation_space_sizes: Dictionary mapping agent IDs to their observation space sizes.
|
255
|
-
:param action_space_sizes: Dictionary mapping agent IDs to their action space sizes.
|
256
|
-
:param vram_usage: VRAM required to perform the inner task. Can be NaN if an OOM was encountered.
|
257
|
-
:param idle_vram_usage: VRAM required for the inner task to sit loaded but not actively being trained. Can be
|
258
|
-
NaN if an OOM was encountered.
|
259
|
-
:param hparam_overrides: Hyperparameter overrides for the inner task.
|
260
|
-
"""
|
261
|
-
|
262
|
-
self.profiles[inner_task_name] = InnerTaskProfile(
|
263
|
-
inner_task_name=inner_task_name,
|
264
|
-
number_of_agents=number_of_agents,
|
265
|
-
number_of_layers=number_of_layers,
|
266
|
-
observation_space_sizes=observation_space_sizes,
|
267
|
-
action_space_sizes=action_space_sizes,
|
268
|
-
number_of_parameters=number_of_parameters,
|
269
|
-
vram_usage=vram_usage,
|
270
|
-
idle_vram_usage=idle_vram_usage,
|
271
|
-
hparam_overrides=hparam_overrides,
|
272
|
-
)
|
273
|
-
|
274
258
|
def validate_task_profiles(self, policy_mapping_function: Callable[[str, Any, Any], str]) -> None:
|
275
259
|
"""
|
276
260
|
:param policy_mapping_function: Function which maps agent IDs to policy IDs.
|
@@ -28,7 +28,7 @@ libinephany/pydantic_models/configs/observer_config.py,sha256=v_ChzaVXC_rlZ7eDZP
|
|
28
28
|
libinephany/pydantic_models/configs/outer_model_config.py,sha256=GQ0QBSC2Xht8x8X_TEMfYM2GF_x1kErLuFrA_H6Jhs0,1209
|
29
29
|
libinephany/pydantic_models/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
30
|
libinephany/pydantic_models/schemas/agent_info.py,sha256=me5gDxvZjP9TNK588mpUvxiiJrPDqy3Z7ZHRzryAYTs,2628
|
31
|
-
libinephany/pydantic_models/schemas/inner_task_profile.py,sha256=
|
31
|
+
libinephany/pydantic_models/schemas/inner_task_profile.py,sha256=1Q3cDyyW01NOgalmAWGLc-AaLoLum9nBtcpLsfxo_pw,10628
|
32
32
|
libinephany/pydantic_models/schemas/observation_models.py,sha256=MLhxqDet9Yol1D5mkQGQsQT23sm37AStRLnPc4sgcZc,2110
|
33
33
|
libinephany/pydantic_models/schemas/request_schemas.py,sha256=VED8eAUvBofxeAx9gWU8DyCZOTVD3QsHRq-TO7kyOqk,1260
|
34
34
|
libinephany/pydantic_models/schemas/response_schemas.py,sha256=SKFuasdjX5aH_I0vT3SwnpwhyMf9cNPB1ZpDeAGgoO8,2158
|
@@ -57,8 +57,8 @@ libinephany/utils/typing.py,sha256=rGbaPO3MaUndsWiC_wHzReD_TOLYqb43i01pKN-j7Xs,6
|
|
57
57
|
libinephany/web_apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
58
58
|
libinephany/web_apps/error_logger.py,sha256=QpspO726Uoyyr6lBEEb3Q9XqhVOXUM4AaYE7vbnk31c,18153
|
59
59
|
libinephany/web_apps/web_app_utils.py,sha256=qiq_lasPipgN1RgRudPJc342kYci8O_4RqppxmIX8NY,4095
|
60
|
-
libinephany-1.1.
|
61
|
-
libinephany-1.1.
|
62
|
-
libinephany-1.1.
|
63
|
-
libinephany-1.1.
|
64
|
-
libinephany-1.1.
|
60
|
+
libinephany-1.1.3.dist-info/licenses/LICENSE,sha256=pogfDoMBP07ehIOvWymuWIar8pg2YLUhqOHsJQU3wdc,9250
|
61
|
+
libinephany-1.1.3.dist-info/METADATA,sha256=Z99V_6BvYynyRZkZ2D5Ih6Dk-GWGeNZH0cTiMFEPSvg,8389
|
62
|
+
libinephany-1.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
63
|
+
libinephany-1.1.3.dist-info/top_level.txt,sha256=bYAOXQdJgIoLkO2Ui0kxe7pSYegS_e38u0dMscd7COQ,12
|
64
|
+
libinephany-1.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|