Skip to content

Commit f8b2f5f

Browse files
authored
Update GPU shapes index with additional shapes and CPU parameters (#1257)
1 parent 3a13534 commit f8b2f5f

File tree

6 files changed

+598
-164
lines changed

6 files changed

+598
-164
lines changed

ads/aqua/common/entities.py

Lines changed: 76 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,77 @@ class Config:
4646
arbitrary_types_allowed = True
4747
protected_namespaces = ()
4848

49+
4950
class ComputeRank(Serializable):
5051
"""
51-
Represents the cost and performance ranking for a compute shape.
52+
Represents the cost and performance rankings for a specific compute shape.
53+
These rankings help compare different shapes based on their relative pricing
54+
and computational capabilities.
5255
"""
53-
cost: int = Field(
54-
None, description="The relative rank of the cost of the shape. Range is [10 (cost-effective), 100 (most-expensive)]"
56+
57+
cost: Optional[int] = Field(
58+
None,
59+
description=(
60+
"Relative cost ranking of the compute shape. "
61+
"Value ranges from 10 (most cost-effective) to 100 (most expensive). "
62+
"Lower values indicate cheaper compute options."
63+
),
5564
)
5665

57-
performance: int = Field(
58-
None, description="The relative rank of the performance of the shape. Range is [10 (lower performance), 110 (highest performance)]"
66+
performance: Optional[int] = Field(
67+
None,
68+
description=(
69+
"Relative performance ranking of the compute shape. "
70+
"Value ranges from 10 (lowest performance) to 110 (highest performance). "
71+
"Higher values indicate better compute performance."
72+
),
5973
)
6074

75+
6176
class GPUSpecs(Serializable):
6277
"""
63-
Represents the GPU specifications for a compute instance.
78+
Represents the specifications and capabilities of a GPU-enabled compute shape.
79+
Includes details about GPU and CPU resources, supported quantization formats, and
80+
relative rankings for cost and performance.
6481
"""
6582

66-
gpu_memory_in_gbs: Optional[int] = Field(
67-
default=None, description="The amount of GPU memory available (in GB)."
68-
)
6983
gpu_count: Optional[int] = Field(
70-
default=None, description="The number of GPUs available."
84+
default=None,
85+
description="Number of physical GPUs available on the compute shape.",
7186
)
87+
88+
gpu_memory_in_gbs: Optional[int] = Field(
89+
default=None, description="Total GPU memory available in gigabytes (GB)."
90+
)
91+
7292
gpu_type: Optional[str] = Field(
73-
default=None, description="The type of GPU (e.g., 'V100, A100, H100')."
93+
default=None,
94+
description="Type of GPU and architecture. Example: 'H100', 'GB200'.",
7495
)
96+
7597
quantization: Optional[List[str]] = Field(
76-
default_factory=list, description="The quantization format supported by shape. (ex. bitsandbytes, fp8, etc.)"
98+
default_factory=list,
99+
description=(
100+
"List of supported quantization formats for the GPU. "
101+
"Examples: 'fp16', 'int8', 'bitsandbytes', 'bf16', 'fp4', etc."
102+
),
103+
)
104+
105+
cpu_count: Optional[int] = Field(
106+
default=None, description="Number of CPU cores available on the shape."
77107
)
108+
109+
cpu_memory_in_gbs: Optional[int] = Field(
110+
default=None, description="Total CPU memory available in gigabytes (GB)."
111+
)
112+
78113
ranking: Optional[ComputeRank] = Field(
79-
None, description="The relative rank of the cost and performance of the shape."
114+
default=None,
115+
description=(
116+
"Relative cost and performance rankings of this shape. "
117+
"Cost is ranked from 10 (least expensive) to 100+ (most expensive), "
118+
"and performance from 10 (lowest) to 100+ (highest)."
119+
),
80120
)
81121

82122

@@ -97,50 +137,49 @@ class GPUShapesIndex(Serializable):
97137

98138
class ComputeShapeSummary(Serializable):
99139
"""
100-
Represents the specifications of a compute instance shape,
101-
including CPU, memory, and optional GPU characteristics.
140+
Represents a compute shape's specification including CPU, memory, and (if applicable) GPU configuration.
102141
"""
103142

104143
available: Optional[bool] = Field(
105-
default = False,
106-
description="True if shape is available on user tenancy, "
144+
default=False,
145+
description="True if the shape is available in the user's tenancy/region.",
107146
)
147+
108148
core_count: Optional[int] = Field(
109-
default=None,
110-
description="Total number of CPU cores available for the compute shape.",
149+
default=None, description="Number of vCPUs available for the compute shape."
111150
)
151+
112152
memory_in_gbs: Optional[int] = Field(
113-
default=None,
114-
description="Amount of memory (in GB) available for the compute shape.",
153+
default=None, description="Total CPU memory available for the shape (in GB)."
115154
)
155+
116156
name: Optional[str] = Field(
117-
default=None,
118-
description="Full name of the compute shape, e.g., 'VM.GPU.A10.2'.",
157+
default=None, description="Name of the compute shape, e.g., 'VM.GPU.A10.2'."
119158
)
159+
120160
shape_series: Optional[str] = Field(
121161
default=None,
122-
description="Shape family or series, e.g., 'GPU', 'Standard', etc.",
162+
description="Series or family of the shape, e.g., 'GPU', 'Standard'.",
123163
)
164+
124165
gpu_specs: Optional[GPUSpecs] = Field(
125-
default=None,
126-
description="Optional GPU specifications associated with the shape.",
166+
default=None, description="GPU configuration for the shape, if applicable."
127167
)
128168

129169
@model_validator(mode="after")
130170
@classmethod
131-
def set_gpu_specs(cls, model: "ComputeShapeSummary") -> "ComputeShapeSummary":
171+
def populate_gpu_specs(cls, model: "ComputeShapeSummary") -> "ComputeShapeSummary":
132172
"""
133-
Validates and populates GPU specifications if the shape_series indicates a GPU-based shape.
134-
135-
- If the shape_series contains "GPU", the validator first checks if the shape name exists
136-
in the GPU_SPECS dictionary. If found, it creates a GPUSpecs instance with the corresponding data.
137-
- If the shape is not found in the GPU_SPECS, it attempts to extract the GPU count from the shape name
138-
using a regex pattern (looking for a number following a dot at the end of the name).
173+
Attempts to populate GPU specs if the shape is GPU-based and no GPU specs are explicitly set.
139174
140-
The information about shapes is taken from: https://docs.oracle.com/en-us/iaas/data-science/using/supported-shapes.htm
175+
Logic:
176+
- If `shape_series` includes 'GPU' and `gpu_specs` is None:
177+
- Tries to parse the shape name to extract GPU count (e.g., from 'VM.GPU.A10.2').
178+
- Fallback is based on suffix numeric group (e.g., '.2' → gpu_count=2).
179+
- If extraction fails, logs debug-level error but does not raise.
141180
142181
Returns:
143-
ComputeShapeSummary: The updated instance with gpu_specs populated if applicable.
182+
ComputeShapeSummary: The updated model instance.
144183
"""
145184
try:
146185
if (
@@ -149,16 +188,15 @@ def set_gpu_specs(cls, model: "ComputeShapeSummary") -> "ComputeShapeSummary":
149188
and model.name
150189
and not model.gpu_specs
151190
):
152-
# Try to extract gpu_count from the shape name using a regex (e.g., "VM.GPU3.2" -> gpu_count=2)
153191
match = re.search(r"\.(\d+)$", model.name)
154192
if match:
155193
gpu_count = int(match.group(1))
156194
model.gpu_specs = GPUSpecs(gpu_count=gpu_count)
157195
except Exception as err:
158196
logger.debug(
159-
f"Error occurred in attempt to extract GPU specification for the f{model.name}. "
160-
f"Details: {err}"
197+
f"[populate_gpu_specs] Failed to auto-populate GPU specs for shape '{model.name}': {err}"
161198
)
199+
162200
return model
163201

164202

0 commit comments

Comments
 (0)