Skip to main content

No project description provided

Project description

centml-python-client

Installation

First, ensure you meet the requirements for Hidet, namely:

  • CUDA Toolkit 11.6+
  • Python 3.8+

To install without cloning, run the following command:

pip install git+https://github.com/CentML/centml-python-client.git@main

Alternatively to build from source, clone this repo then inside the project's base directory, run the following command:

pip install . 

Un-installation

To uninstall centml, simply do:

pip uninstall centml

CLI

Once installed, use the centml CLI tool with the following command:

centml 

If you want tab completion, run

source scripts/completions/completion.<shell language>

Shell language can be: bash, zsh, fish (Hint: add source /path/to/completions/completion.<shell language> to your ~/.bashrc, ~/.zshrc or ~/.config/fish/completions/centml.fish)

Compilation

centml-python-client's compiler feature allows you to compile your ML model remotely using the hidet backend.
Thus, use the compilation feature, make sure to run:

pip install hidet

To run the server locally, you can use the following CLI command:

centml server

By default, the server will run at the URL http://0.0.0.0:8090.
You can change this by setting the environment variable CENTML_SERVER_URL

Then, within your python script include the following:

import torch
# This will import the "centml" torch.compile backend
import centml.compiler  

# Define these yourself
model = ...
inputs = ...

# Pass the "centml" backend
compiled_model = torch.compile(model, backend="centml")
# Since torch.compile is JIT, compilation is only triggered when you first call the model
output = compiled_model(inputs)

Note that the centml backend compiler is non-blocking. This means it that until the server returns the compiled model, your python script will use the uncompiled model to generate the output.

Again, make sure your script's environment sets CENTML_SERVER_URL to communicate with the desired server.

To see logs, add this to your script before triggering compilation:

logging.basicConfig(level=logging.INFO)

Tests

To run tests, first install required packages:

pip install -r requirements-dev.txt
cd tests

When running on a local machine, it is recommended to run tests with the following command. This skips tests that require a GPU.

pytest --sanity

To run all the tests, use:

pytest

Common Issues

  • SSL certificate on MacOS

    Sometimes, you will see issues when using command like centml cluster [CMD], where the output might look like:

    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/retry.py", line 519, in increment
    
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    
    urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.centml.com', port=443):
    
    Max retries exceeded with url: /deployments
    
    (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))
    

    Solution: To fix this issue, navigate to your python installation directory and run the Install Certificates.command file located there.

    For example, if you are using python3.10, the file path would be: /Applications/Python 3.10/Install Certificates.command

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

centml-0.4.11.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

centml-0.4.11-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file centml-0.4.11.tar.gz.

File metadata

  • Download URL: centml-0.4.11.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for centml-0.4.11.tar.gz
Algorithm Hash digest
SHA256 0d57e1a2c361187a9470693e34db0baf92650ad8b440f1b30971d7b405fb97eb
MD5 550a0ff3d40017aea4ddce2b38b310c1
BLAKE2b-256 93e778cf68ca6db57887f50f2566e708dbd0ae96e5ab724e87ba82232fe63727

See more details on using hashes here.

Provenance

The following attestation bundles were made for centml-0.4.11.tar.gz:

Publisher: publish.yml on CentML/centml-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file centml-0.4.11-py3-none-any.whl.

File metadata

  • Download URL: centml-0.4.11-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for centml-0.4.11-py3-none-any.whl
Algorithm Hash digest
SHA256 0a2ffe320fb545df25872fc1699218d2a04fe14890a1d599dd0466516cccb29f
MD5 12f6395d3070060e84da6a4b7802c966
BLAKE2b-256 4ffcef7e727e1fa6ac37ffd82e02ca7ac4b08f5b9a87126bc2c1b2f4db0f2724

See more details on using hashes here.

Provenance

The following attestation bundles were made for centml-0.4.11-py3-none-any.whl:

Publisher: publish.yml on CentML/centml-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page