Module: spec
CPUCore
Bases: BaseModel
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
The id of the core, e.g. 0 |
frequency |
float
|
The frequency of the core |
max_frequency |
float
|
The maximum frequency of the core |
min_frequency |
float
|
The minimum frequency of the core |
Source code in src/infernet_ml/utils/spec.py
CPUInfo
Bases: BaseModel
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
The model of the CPU, e.g. Intel(R) Core(TM) i7-7700HQ CPU |
architecture |
str
|
The architecture of the CPU, e.g. x86_64 |
byte_order |
str
|
The byte order of the CPU, e.g. Little Endian |
vendor_id |
str
|
The vendor id of the CPU, e.g. GenuineIntel |
num_cores |
int
|
The number of cores in the CPU |
cores |
List[CPUCore]
|
The list of cores in the CPU |
Source code in src/infernet_ml/utils/spec.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
read_from_darwin()
classmethod
Reads the CPU information from a Darwin system
Returns:
Name | Type | Description |
---|---|---|
CPUInfo |
CPUInfo
|
The CPU information |
Source code in src/infernet_ml/utils/spec.py
read_from_linux()
classmethod
Reads the CPU information from a Linux system
Returns:
Name | Type | Description |
---|---|---|
CPUInfo |
CPUInfo
|
The CPU information |
Source code in src/infernet_ml/utils/spec.py
read_from_system()
classmethod
Reads the CPU information from the system. Automatically detects the OS and reads the CPU information accordingly.
Returns:
Name | Type | Description |
---|---|---|
CPUInfo |
CPUInfo
|
The CPU information |
Source code in src/infernet_ml/utils/spec.py
ComputeId
Bases: StrEnum
Enum for the different types of compute capabilities within Ritual's
services.
Attributes:
Name | Type | Description |
---|---|---|
ML |
Machine Learning Compute |
|
ZK |
Zero Knowledge Compute |
|
TEE |
Trusted Execution Environment Compute |
Source code in src/infernet_ml/utils/spec.py
DiskInfo
Bases: BaseModel
Attributes:
Name | Type | Description |
---|---|---|
filesystem |
str
|
The filesystem of the disk, e.g. ext4 |
mount_point |
str
|
The mount point of the disk, e.g. / |
size |
int
|
The size of the disk in bytes |
used |
int
|
The used space on the disk in bytes |
available |
int
|
The available space on the disk in bytes |
Source code in src/infernet_ml/utils/spec.py
read_from_system()
classmethod
Reads the disk information from the system
Returns:
Type | Description |
---|---|
List[DiskInfo]
|
List[DiskInfo]: The disk information |
Source code in src/infernet_ml/utils/spec.py
GPUHardwareCapability
Bases: BaseModel
Source code in src/infernet_ml/utils/spec.py
read_from_system()
classmethod
Reads the GPU hardware capability from the system
Returns:
Type | Description |
---|---|
Optional[GPUHardwareCapability]
|
Optional[GPUHardwareCapability]: The GPU hardware capability |
Source code in src/infernet_ml/utils/spec.py
GPUInfo
Bases: BaseModel
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the GPU, e.g. NVIDIA GeForce GTX 1080 |
memory_total |
int
|
The total memory of the GPU in bytes |
memory_used |
int
|
The used memory of the GPU in bytes |
cuda_device_id |
Optional[int]
|
The CUDA device id of the GPU |
Source code in src/infernet_ml/utils/spec.py
GenericHardwareCapability
Bases: BaseModel
Source code in src/infernet_ml/utils/spec.py
read_from_system()
classmethod
Reads the generic hardware capability from the system
Returns:
Name | Type | Description |
---|---|---|
GenericHardwareCapability |
'GenericHardwareCapability'
|
The generic hardware capability |
Source code in src/infernet_ml/utils/spec.py
HardwareCapabilityId
Bases: StrEnum
Enum for the different types of hardware capabilities within
Ritual's services..
Attributes:
Name | Type | Description |
---|---|---|
Base |
Generic Hardware Capability, contains information about the OS, CPU, and disk |
|
GPU |
Graphics Processing Unit |
|
TEE |
Trusted Execution Environment |
Source code in src/infernet_ml/utils/spec.py
MLComputeCapability
Bases: BaseModel
Class for the machine learning compute capabilities within
Ritual's services.
Attributes:
Name | Type | Description |
---|---|---|
id |
Literal[ML]
|
The type of compute capability |
type |
MLType
|
The type of machine learning model that can be supported |
task |
List[MLTask]
|
The list of machine learning tasks that can be supported |
models |
List[BroadcastedArtifact] | List[CSSModel]
|
The list of models that can be supported |
cached_models |
List[BroadcastedArtifact]
|
The list of cached models that can be supported |
inference_engine |
Optional[str]
|
The inference engine that can be supported |
inference_engine_version |
Optional[str]
|
The inference engine version that can be supported |
Source code in src/infernet_ml/utils/spec.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
css_compute(models=None)
classmethod
Utility function to generate a CSS compute capability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models |
Optional[List[CSSModel]]
|
The list of models that can be supported |
None
|
Returns:
Name | Type | Description |
---|---|---|
MLComputeCapability |
MLComputeCapability
|
The CSS compute capability |
Source code in src/infernet_ml/utils/spec.py
hf_client_compute()
classmethod
Utility function to generate a Huggingface client compute capability.
Source code in src/infernet_ml/utils/spec.py
llama_cpp_compute(models=None)
classmethod
Utility function to generate a llama.cpp compute capability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models |
Optional[List[CachedArtifact]]
|
The list of models that can be supported |
None
|
Returns:
Name | Type | Description |
---|---|---|
MLComputeCapability |
MLComputeCapability
|
The llama.cpp compute capability |
Source code in src/infernet_ml/utils/spec.py
onnx_compute(models=None, cached_models=None)
classmethod
Utility function to generate an ONNX compute capability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models |
Optional[List[BroadcastedArtifact]]
|
The list of models that can be supported |
None
|
cached_models |
Optional[List[BroadcastedArtifact]]
|
The list of cached models |
None
|
Returns:
Name | Type | Description |
---|---|---|
MLComputeCapability |
MLComputeCapability
|
The ONNX compute capability |
Source code in src/infernet_ml/utils/spec.py
tgi_client_compute()
classmethod
Utility function to generate a TGI client compute capability.
torch_compute(models=None, cached_models=None)
classmethod
Utility function to generate a Torch compute capability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models |
Optional[List[BroadcastedArtifact]]
|
The list of models that can be supported |
None
|
cached_models |
Optional[List[BroadcastedArtifact]]
|
The list of cached models |
None
|
Returns:
Name | Type | Description |
---|---|---|
MLComputeCapability |
MLComputeCapability
|
The torch compute capability |
Source code in src/infernet_ml/utils/spec.py
MLTask
Bases: StrEnum
supported. This is provided for utility & should not be used as a strict validation mechanism.
Attributes:
Name | Type | Description |
---|---|---|
TextGeneration |
Text Generation |
|
TextClassification |
Text Classification |
|
TokenClassification |
Token Classification |
|
Summarization |
Summarization |
|
ImageClassification |
Image Classification |
|
ImageSegmentation |
Image Segmentation |
|
ObjectDetection |
Object Detection |
Source code in src/infernet_ml/utils/spec.py
OSInfo
Bases: BaseModel
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the OS, e.g. Ubuntu |
version |
str
|
The version of the OS |
Source code in src/infernet_ml/utils/spec.py
read_from_system()
classmethod
Reads the OS information from the system
Returns:
Name | Type | Description |
---|---|---|
OSInfo |
OSInfo
|
The OS information |
Resource
Bases: BaseModel
Class representation for the resources of a service within Ritual's
services.
Attributes:
Name | Type | Description |
---|---|---|
capabilities |
List[Capability]
|
The list of capabilities of the service |
version |
str
|
The version of this specification |
Source code in src/infernet_ml/utils/spec.py
ServiceResources
Bases: BaseModel
Class representation for the resources of a service within
Ritual's services..
Attributes:
Name | Type | Description |
---|---|---|
service_id |
str
|
The unique identifier for the service |
hardware_capabilities |
List[HardwareCapability]
|
The list of hardware capabilities of the service |
compute_capability |
List[ComputeCapability]
|
The list of compute capabilities of the service |
Source code in src/infernet_ml/utils/spec.py
initialize(service_id, compute_capability)
classmethod
Initializes the service resources. Reads the hardware capabilities from the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_id |
str
|
The unique identifier for the service |
required |
compute_capability |
List[ComputeCapability]
|
The list of compute capabilities of the service |
required |
Returns:
Name | Type | Description |
---|---|---|
ServiceResources |
ServiceResources
|
The service resources |
Source code in src/infernet_ml/utils/spec.py
ZKComputeCapability
Bases: BaseModel
Class for the zero knowledge compute capabilities within
Ritual's services..
Attributes:
Name | Type | Description |
---|---|---|
id |
Literal[ZK]
|
The type of compute capability |
Source code in src/infernet_ml/utils/spec.py
hf_api_query_handler(any_tags=[], all_tags=[], token=None)
Generates a handler for checking if a model is available on HuggingFace. Includes private models if the provided token is valid and has access to them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
any_tags |
List[str]
|
List of tags to filter the models by. At least one of the tags must be present in the model's tags. |
[]
|
all_tags |
List[str]
|
List of tags to filter the models by. All of the tags must be present in the model's tags. |
[]
|
token |
Optional[str]
|
HuggingFace API token. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
handler |
Callable[[str], dict[str, bool]]
|
The handler function to check if a model is supported by the HF API. |
Source code in src/infernet_ml/utils/spec.py
null_query_handler()
Generates a handler for checking if a model is supported by the service. This handler always returns False, and is used for services that do not advertise their supported model(s).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_id |
str
|
The model id to check if it is supported. This is ignored. |
required |
Returns:
Name | Type | Description |
---|---|---|
handler |
Callable[[str], dict[str, bool]]
|
The handler function to check if a model is supported by the service. |
Source code in src/infernet_ml/utils/spec.py
postfix_query_handler(postfix)
Generates a handler for checking if a model has a specific postfix. The onnx & torch service use this to quickly broadcast if a model is supported by the service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
postfix |
str
|
The postfix to check for in the model files |
required |
Returns:
Name | Type | Description |
---|---|---|
handler |
Callable[[str], dict[str, bool]]
|
The handler function to check if a model is supported by the service. |
Source code in src/infernet_ml/utils/spec.py
read_hw_cap_from_system()
Reads the hardware capabilities from the system.
Source code in src/infernet_ml/utils/spec.py
ritual_service_specs(app, resource_generator, model_query_handler)
Generates the service resources endpoint for Ritual's services. This endpoint is used to broadcast the capabilities of the service for routers & indexing services.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app |
Quart
|
The Quart application |
required |
resource_generator |
Callable[[], dict[str, Any]]
|
The function to generate the resources of the service |
required |
model_query_handler |
Callable[[str], dict[str, bool]]
|
The function to generate the model query handler |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in src/infernet_ml/utils/spec.py
simple_query_handler(supported_models)
Generates a handler for checking if a model is supported by the service. This handler checks if the model id is in the list of supported models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
supported_models |
List[str]
|
The list of supported models |
required |
Returns:
Name | Type | Description |
---|---|---|
handler |
Callable[[str], dict[str, bool]]
|
The handler function to check if a model is supported by the service. |