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 driver; no CUDA Toolkit is needed. 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.0

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.0
File Size Uploaded
laya_cuda-0.1.0.tar.gz 484.4 kB Details

Built distribution (wheel)

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

Total release size: 515.9 kB

Release files / laya_cuda-0.1.0.tar.gz

Download URL laya_cuda-0.1.0.tar.gz
Size 484.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3762450ead20599c9e6754811262f0b0c6b43132cd4e193d00a00f5726643cf9
BLAKE2b-256 checksum
How to use checksums
580f589d34bbc16ed17e4f13895e1396081ceb90c2cb36bad9509839f026a7d7
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.0-py3-none-any.whl

Download URL laya_cuda-0.1.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b065b4066b21aa187825849e05473f098f60ebed28375c855386209c456d5832
BLAKE2b-256 checksum
How to use checksums
e2340f7b1cc5766f93d73db208b014c84b6999fb32c4deea74de14cd04103871
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

0.1.1

2 release files

This release

0.1.0 This release

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