Skip to main content

English | 简体中文

laya-cuda

A lightweight inference library for Laya

Latency of one request repeated 200 times:

Model Request laya-cuda P50 / P95 Official SDK P50 / P95 Speedup P50 / P95
laya short, 83 tokens 2.3 / 2.9 ms 19.3 / 20.5 ms 8.3× / 7.2×
laya full context, 512 tokens 5.6 / 6.0 ms 18.9 / 20.0 ms 3.4× / 3.3×
laya-multilingual short, 81 tokens 1.5 / 2.0 ms 16.1 / 17.0 ms 10.6× / 8.4×
laya-multilingual full context, 1,024 tokens 4.9 / 5.4 ms 15.8 / 17.0 ms 3.2× / 3.1×
laya-typed-decisions short, 83 tokens 2.4 / 2.9 ms 19.6 / 20.8 ms 8.3× / 7.1×
laya-typed-decisions full context, 1,024 tokens 9.6 / 9.9 ms 19.8 / 21.3 ms 2.1× / 2.2×

Accuracy on 200 frozen requests (laya-cuda / SDK): laya 52.25% / 52.25%, laya-multilingual 43.25% / 43.25%, laya-typed-decisions 69.25% / 69.75%. Jev, a larger remote model, scores 65.00% on the laya requests at 378 / 466 ms, which includes network latency.

  • Setup: RTX 4090, Windows 11. The short request is a real AG News request with one four-option question; the full-context request asks the same question about real text truncated at the model's limit. Each request ran 200 times per process, in 3 processes per backend with alternating order.
  • What is timed: the full predict call, including tokenization, GPU work and decoding. Jev's time also includes the network.
  • Mixed requests: on 200 different frozen requests (40–900 tokens, 1–5 questions, 4–77 options, each new shape's first request included), laya measures 4.1 / 8.5 ms against 20.1 / 22.1 ms for the SDK: 4.9× / 2.6×. Mixing request sizes raises P95; the latency report explains it.
  • SDK precision: the official SDK runs at its default BF16. On the 2,000-decision fixed set, laya-cuda agrees with the SDK at FP32 more closely than BF16 does.
  • Protocol: benchmarks/; the latency report records the frozen inputs.

Install

pip install laya-cuda   # core: CuPy + CUDA components, no Torch
laya-cuda doctor laya   # check driver, GPU and CUDA components, then time one prediction

Windows or Linux x86-64, Python 3.12–3.14 and an NVIDIA GPU with compute capability 8.0 or newer (Ampere or later, such as RTX 30/40/50, A100, L4 or H100); no CUDA Toolkit is needed. Measured on an RTX 4090. To work on the source, use uv:

git clone https://github.com/Alexw1111/laya-cuda
cd laya-cuda
uv sync
uv run laya-cuda doctor laya

Use

from laya_cuda import Engine

questions = {
    "team": {"type": "choice", "instructions": "Which team should handle this request?",
             "criteria": {"billing": "payments and refunds", "technical": "software errors"}},
    "urgent": {"type": "noul", "instructions": "Does this need urgent attention?"},
}
with Engine("laya") as model:
    print(model.predict("Please refund my duplicate payment.", questions)["answers"])
laya-cuda predict "Please refund my duplicate payment." -q questions.json
laya-cuda predict -i requests.jsonl -q questions.json -o results.jsonl

Answers keep the SDK's structure: probabilities, confidence, action probability and token usage. BatchEngine batches concurrent callers. backend="official" runs the unmodified SDK for comparison and needs the full or reference extra.

Learn more

  • Guide: Engine, BatchEngine, model registry, platform and driver details, development, architecture.
  • Examples: decision workflows, the Jev client and Snake Lab, a live demo where every move is a Laya prediction.
  • Benchmarks: how comparisons, gates and reports work.
  • FP32-reference validation: the full record of the numerical, long-input and accuracy gates.
  • Latency tail: what made P95 twice P50, the fixes, and their check on untuned workloads.
  • Adding a model: the adapter recipe.

The library is about 1,270 lines of Python and CUDA. CuPy owns memory, streams and CUDA Graphs; cuBLAS does the matrix multiplication; a few NVRTC kernels handle the rest, including one fused tensor-core attention kernel.

Acknowledgements

License

Source code and derived request semantics are Apache-2.0; see LICENSE and laya_cuda/NOTICE. Model and dataset licenses apply separately.

Release files for laya-cuda 0.1.1.post1

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

Source distribution (sdist)

Source distribution for laya-cuda 0.1.1.post1
File Size Uploaded
laya_cuda-0.1.1.post1.tar.gz 485.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for laya-cuda 0.1.1.post1
File Interpreter ABI Platform
laya_cuda-0.1.1.post1-py3-none-any.whl Python 3 none any Details

Total release size: 517.2 kB

Release files / laya_cuda-0.1.1.post1.tar.gz

Download URL laya_cuda-0.1.1.post1.tar.gz
Size 485.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7443c7e9c1bef4fd226a246ea4d1614ed344cf1f89715065bd88ad3eb5a470f3
BLAKE2b-256 checksum
How to use checksums
7d93f421869d7ae11ee2f32ec5a8d206d00d906d95746c67f3f2089dec445902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / laya_cuda-0.1.1.post1-py3-none-any.whl

Download URL laya_cuda-0.1.1.post1-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9d99d1afbb1d95cd5806d192212e562109bfa52b07c48a11823536c28b27ce4
BLAKE2b-256 checksum
How to use checksums
59b900a42c68da71c5486fc5a0307e269a9472a9981a283bea481c83fb4f2d86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.1.post1 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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