@@ -46,37 +46,77 @@ class Config:
46
46
arbitrary_types_allowed = True
47
47
protected_namespaces = ()
48
48
49
+
49
50
class ComputeRank (Serializable ):
50
51
"""
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.
52
55
"""
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
+ ),
55
64
)
56
65
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
+ ),
59
73
)
60
74
75
+
61
76
class GPUSpecs (Serializable ):
62
77
"""
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.
64
81
"""
65
82
66
- gpu_memory_in_gbs : Optional [int ] = Field (
67
- default = None , description = "The amount of GPU memory available (in GB)."
68
- )
69
83
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." ,
71
86
)
87
+
88
+ gpu_memory_in_gbs : Optional [int ] = Field (
89
+ default = None , description = "Total GPU memory available in gigabytes (GB)."
90
+ )
91
+
72
92
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'." ,
74
95
)
96
+
75
97
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."
77
107
)
108
+
109
+ cpu_memory_in_gbs : Optional [int ] = Field (
110
+ default = None , description = "Total CPU memory available in gigabytes (GB)."
111
+ )
112
+
78
113
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
+ ),
80
120
)
81
121
82
122
@@ -97,50 +137,49 @@ class GPUShapesIndex(Serializable):
97
137
98
138
class ComputeShapeSummary (Serializable ):
99
139
"""
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.
102
141
"""
103
142
104
143
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." ,
107
146
)
147
+
108
148
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."
111
150
)
151
+
112
152
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)."
115
154
)
155
+
116
156
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'."
119
158
)
159
+
120
160
shape_series : Optional [str ] = Field (
121
161
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'." ,
123
163
)
164
+
124
165
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."
127
167
)
128
168
129
169
@model_validator (mode = "after" )
130
170
@classmethod
131
- def set_gpu_specs (cls , model : "ComputeShapeSummary" ) -> "ComputeShapeSummary" :
171
+ def populate_gpu_specs (cls , model : "ComputeShapeSummary" ) -> "ComputeShapeSummary" :
132
172
"""
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.
139
174
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.
141
180
142
181
Returns:
143
- ComputeShapeSummary: The updated instance with gpu_specs populated if applicable .
182
+ ComputeShapeSummary: The updated model instance .
144
183
"""
145
184
try :
146
185
if (
@@ -149,16 +188,15 @@ def set_gpu_specs(cls, model: "ComputeShapeSummary") -> "ComputeShapeSummary":
149
188
and model .name
150
189
and not model .gpu_specs
151
190
):
152
- # Try to extract gpu_count from the shape name using a regex (e.g., "VM.GPU3.2" -> gpu_count=2)
153
191
match = re .search (r"\.(\d+)$" , model .name )
154
192
if match :
155
193
gpu_count = int (match .group (1 ))
156
194
model .gpu_specs = GPUSpecs (gpu_count = gpu_count )
157
195
except Exception as err :
158
196
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 } "
161
198
)
199
+
162
200
return model
163
201
164
202
0 commit comments