Skip to main content

MESA local

Serve MESA models locally.

  • ⬇️ Downloads weights from S3

  • 📦 Unpacks

  • 🚀 Serves via a local OpenAI-compatible server

Prerequisites

Software

  • Python 3.12

Hardware

  • A GPU with >=24GB VRAM (tested on NVIDIA A30).
  • An NVIDIA driver supporting CUDA >=13; hosts limited to CUDA 12.x need the alternative install in CUDA 12.x hosts below.
  • Alternatively, an Apple Silicon Mac on macOS >=15 (tested on M3 Ultra), using the install in Apple Silicon hosts below.

Configuration

Create a file called .env in the directory where you intend to run this package. Populate it with the details you have been provided with in the following format:

MODEL_NAME=
WEIGHTS_ID=
WEIGHTS_KEY=

(Alternative) S3 URI

Download weights directly from an S3 bucket:

MODEL_NAME=
WEIGHTS_URI=
WEIGHTS_REGION=  # optional, defaults to eu-west-2

(Optional) Caching

Download weights and cache to S3 for faster subsequent downloads:

MODEL_NAME=
WEIGHTS_ID=
WEIGHTS_KEY=
WEIGHTS_URI=
WEIGHTS_REGION=  # optional, defaults to eu-west-2

With this configuration:

  • First run: Downloads weights and uploads to S3 cache

  • Subsequent runs: Downloads directly from S3 cache (faster)

vLLM configuration

The package provides a set of vLLM configuration files for running a specific model on a specific GPU. In addition to MODEL_NAME, this can be specified by adding GPU to the .env.

Individual vLLM settings can also be overridden by adding them to the .env file:

Setting Alias Type Default
MODEL MODEL_NAME str mesalocal
GPU str None
MAX_MODEL_LEN MODEL_LENGTH int 41152
ENFORCE_EAGER bool False
ENABLE_CHUNKED_PREFILL bool True
ENABLE_PREFIX_CACHING bool True
GPU_MEMORY_UTILIZATION float 0.9
MAX_NUM_SEQS int 256
MAX_NUM_BATCHED_TOKENS int None
ENABLE_LOG_REQUESTS bool False
UVICORN_LOG_LEVEL str warning
HTTP_TIMEOUT_KEEP_ALIVE int 30

Installation

  1. (Recommended) Create a virtual environment and activate it:

    python -m venv .venv
    source .venv/bin/activate
    
  2. Install this package: pip install londonaicentre-mesa-local.

CUDA 12.x hosts

  1. Install uv.

  2. Create a uv-managed environment and install the CUDA 12.9 build (last supported by the current vLLM version) in place of the default above:

    uv venv --python 3.12 .venv && source .venv/bin/activate
    uv pip install --torch-backend=cu129 \
        "vllm @ https://github.com/vllm-project/vllm/releases/download/v0.32.0/vllm-0.32.0+cu129-cp38-abi3-manylinux_2_28_x86_64.whl" \
        londonaicentre-mesa-local
    
  3. (Optional) Forward compatibility is required if the current CUDA version is below 12.9; a driver already at 12.9 runs these wheels directly and can skip this step. Where needed, unpack cuda-compat-12-9 (no root needed; download the .deb from NVIDIA's CUDA repo, copying it onto the host first if egress is restricted), prepend it to the library path in the shell that will run mesalocal, and verify (expect True 12.9):

    dpkg-deb -x cuda-compat-12-9_575.57.08-0ubuntu1_amd64.deb ~/cuda-compat
    export LD_LIBRARY_PATH=$HOME/cuda-compat/usr/local/cuda-12.9/compat:$LD_LIBRARY_PATH
    python -c "import torch; print(torch.cuda.is_available(), torch.version.cuda)"
    

Apple Silicon hosts

  1. Install uv.

  2. Create a uv-managed environment and install the macOS build of vLLM with its vllm-metal plugin in place of the default above:

    uv venv --python 3.12 .venv && source .venv/bin/activate
    uv pip install \
        "vllm @ https://github.com/vllm-project/vllm/releases/download/v0.32.0/vllm-0.32.0+cpu-cp38-abi3-macosx_11_0_arm64.whl" \
        "vllm-metal @ https://github.com/vllm-project/vllm-metal/releases/download/v0.32.0/vllm_metal-0.32.0-cp312-cp312-macosx_15_0_arm64.whl" \
        londonaicentre-mesa-local
    
  3. Add GPU_MEMORY_UTILIZATION to the .env, as the default claims 90% of the memory shared with macOS (e.g. 0.1 on a 512GB Mac).

mesalocal refuses to start if vLLM falls back to its CPU platform rather than using vllm-metal.

Hosts without a CUDA compiler (nvcc)

vLLM JIT-compiles some FlashInfer and DeepGEMM kernels at runtime, which requires nvcc on the host. Where nvcc cannot be installed, disable those kernels so vLLM uses its built-in, non-JIT paths instead:

export VLLM_USE_FLASHINFER_SAMPLER=0
export VLLM_USE_DEEP_GEMM=0

Usage

CLI (primary)

  1. Note command line arguments:

    Argument Description
    -v, --verbose Enable debug output (optional)
  2. Start the server as follows: mesalocal [args].

Library (secondary)

  1. Import and use the logic of this package as a library:
import asyncio
from mesadeploycore.weights import Weights
from mesalocal.inferrer import VLLM
vllm_config: VLLMConfig = VLLMConfig() # VLLMConfig(model_name="foo", gpu="bar") to use a vLLM config without a .env file
weights: Weights = Weights(vllm_config.model)
if weights.unpack():
    vllm: VLLM = VLLM(weights.get_model_folder(), vllm_config)
    async def run():
        async for output in vllm.generate(prompt):
            print(output.outputs[0].text)
    asyncio.run(run())

Clients

OpenAI (example with Oncollama)

  1. Interact with the server using the OpenAI client in python:

    from openai import OpenAI
    from oncoschema.prompt_builder import PromptBuilder # pip install londonaicentre-oncoschema
    
    client = OpenAI(
        base_url="http://localhost:5000/v1",
        api_key="blank" 
    )
    
    response = client.chat.completions.create(
        model="oncollama3betav01",
        messages=[
            {"role": "system", "content": PromptBuilder().build_main_prompt()},
            {"role": "user", "content": "Diagnosis 01/01/26..."}
        ]
    )
    
    print(response.choices[0].message.content)
    

License

This project uses a proprietary license (see LICENSE).

Metadata

Release files for londonaicentre-mesa-local 2.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for londonaicentre-mesa-local 2.12.1
File Size Uploaded Provenance Actions
londonaicentre_mesa_local-2.12.1.tar.gz 20.9 kB Without provenance Details for londonaicentre_mesa_local-2.12.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for londonaicentre-mesa-local 2.12.1
File Interpreter ABI Platform Actions
londonaicentre_mesa_local-2.12.1-py3-none-any.whl Python 3 none any Details for londonaicentre_mesa_local-2.12.1-py3-none-any.whl

Total release size: 43.1 kB

Release files / londonaicentre_mesa_local-2.12.1.tar.gz

Download URL londonaicentre_mesa_local-2.12.1.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c88db9f2de02d3703fc2a73aa7ff24a438166f6f449720c4d8d56127b0b2c950
BLAKE2b-256 checksum
How to use checksums
9518cbcc314e0cf8d62cced6f92a4d542e14c75cc9eb0b78862bb62cdb8abdfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / londonaicentre_mesa_local-2.12.1-py3-none-any.whl

Download URL londonaicentre_mesa_local-2.12.1-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a3f7d6b84a09d64080815750b36a975a7fbe3a3dc35036a705302ebee00947b
BLAKE2b-256 checksum
How to use checksums
1577c6c758fde436a20647f1bb0ce1d6844e74b31e8e154c0294e83a8953c006
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for londonaicentre-mesa-local 2.12.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.12.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page