Skip to content

client

yasp client library.

Provides the client API to schedule and retrieve model compilations on the yasp platform.

Classes:

Client

Client(api_token: str, api_host: str | None = None)

Client class to launch and query compilations on the platform.

This class is the gateway to launch new compilations and retreive exising ones.

Attributes:

Parameters:

  • api_host (str | None, default: None ) –

    The hostname or URL of the compilation API.

  • api_token (str) –

    The authentication token for the API.

Raises:

  • ValueError

    If api_host or api_token are None or empty.

Compilation

Compilation(task_id: str, request_handler: RequestHandler)

Represents a compilation task on the embedded-router service.

Provides access to task metadata, status, and results through the activity service.

Parameters:

  • task_id (str) –

    The unique identifier of the compilation task

  • request_handler (RequestHandler) –

    Handler for making API requests

Methods:

  • cancel

    Cancel the compilation task.

Attributes:

  • id (str) –

    Get the task/compilation ID.

  • status (str) –

    Get the current status of the compilation.

id property

id: str

Get the task/compilation ID.

status property

status: str

Get the current status of the compilation.

Fetches the latest task status from the activity service.

Returns:

  • str

    Current task status

cancel

cancel() -> None

Cancel the compilation task.

Sends a cancellation request to the embedded-router service.

CompilationManager

CompilationManager(request_handler: RequestHandler)

Manager for creating and retrieving compilation tasks.

This manager handles communication with the embedded-router service for creating new compilations and accessing existing ones.

Parameters:

  • request_handler (RequestHandler) –

    Handler for making API requests

Methods:

  • get

    Retrieve an existing compilation by ID.

  • new

    Create a new compilation task.

get

get(compilation_id: str) -> Compilation

Retrieve an existing compilation by ID.

Parameters:

  • compilation_id (str) –

    The unique compilation identifier

Returns:

  • Compilation

    Compilation object for the specified task

Raises:

  • RuntimeError

    If the compilation cannot be retrieved

new

new(arch_spec: str, precision: str = 'fp32', alias: Optional[str] = None) -> Compilation

Create a new compilation task.

Submits a compilation request to the embedded-router service.

Parameters:

  • arch_spec (str) –

    Target hardware architecture (e.g., "nvidia-h100")

  • precision (str, default: 'fp32' ) –

    Numerical precision for compilation (default: "fp32")

  • alias (Optional[str], default: None ) –

    Optional worker alias for development deployments

Returns:

  • Compilation

    Compilation object representing the created task

Raises:

  • RuntimeError

    If the compilation creation fails

CompilationMode

Bases: StringEnum

Enumeration of supported compilation modes.

Defines the different modes in which a model can be compiled, including inference and training modes.

Attributes:

  • INFERENCE

    Inference mode for model deployment and prediction.

  • TRAINING

    Training mode for model optimization during training.

CompilationSourceTypes

Bases: StringEnum

Enumeration of supported compilation source types.

Defines the different types of sources that can be used for model compilation, including source code and YASP internal representation.

Attributes:

  • SOURCE_CODE

    Source code compilation type.

  • YASP_IR

    YASP intermediate representation compilation type.

Configuration

Bases: DataClass

Model compilation configuration.

Represents the complete configuration for model compilation, including target platform, source type, optimization settings, and compilation mode.

Attributes:

  • compilation_source_type (Optional[CompilationSourceTypes]) –

    Optional type of compilation source.

  • compilation_source_data (Optional[CompilationSourceCodeData]) –

    Optional source code compilation data.

  • optimize_backward_pass (Optional[bool]) –

    Whether to optimize backward pass (default: True).

  • compilation_target (Optional[Dict[str, Any]]) –

    Optional target hardware platform.

  • mode (CompilationMode) –

    Compilation mode (required).

Methods:

  • process_type

    Process data types for serialization.

  • to_dict

    Convert model to dictionary for API responses.

  • validate

    Validates compilation configuration parameters.

process_type

process_type(data: Dict[str, Any]) -> Dict[str, Any]

Process data types for serialization.

Parameters:

  • data (Dict[str, Any]) –

    Dictionary of model data.

Returns:

  • Dict[str, Any]

    Dictionary with properly serialized values.

to_dict

to_dict() -> Dict[str, Any]

Convert model to dictionary for API responses.

Recursively converts nested DataClass instances to dictionaries.

Returns:

  • Dict[str, Any]

    Dictionary representation of model with all nested objects serialized.

validate staticmethod

validate(config: DataClass, strict: bool = False)

Validates compilation configuration parameters.

Parameters:

  • config (DataClass) –

    Configuration object to validate.

  • strict (bool, default: False ) –

    Whether to perform strict validation (default: False).

Raises:

  • ValueError

    If required configuration fields are missing or invalid.