Skip to main content

GLRMask

GLRMask is a grammar-constrained decoding library for high-throughput LLM serving. It is optimized for fast mask computation with extremely low tail latency, even for complex grammars.

GLRMask supports general context-free grammars, including ambiguous ones. It accepts JSON Schema, Lark, and GLRMask's native format: GLRM.

Website · GitHub · Paper

Installation

python -m pip install glrmask

Usage

GLRMask has four core types:

  • Grammar: a grammar, written as source text or built from an expression.
  • Module: a grammar plus its extern bindings and any precompiled work. Can be saved and loaded.
  • Constraint: a grammar compiled for a vocabulary, ready to use.
  • ConstraintState: the state of one generated sequence.

Quickstart

import glrmask

vocab = glrmask.Vocab.from_id_to_bytes({0: b"hello", 1: b" ", 2: b"world"})
grammar = glrmask.Grammar.from_lark('start: "hello" " " "world"')
constraint = grammar.compile(vocab)
state = constraint.start()
for token_id, expected in [(0, [True, False, False]),
                           (1, [False, True, False]),
                           (2, [False, False, True])]:
    assert state.mask().tolist() == expected
    assert state.commit_token(token_id)
assert state.is_accepting()

Learn more

Full guide · API reference · Benchmarks

Native bindings are available for C++ and JavaScript/TypeScript on Node.js. The C++ guide and C API and JavaScript and TypeScript guide cover source builds, platform artifacts, ownership, composition, and the complete supported API. The Node.js addon runs the Rust engine directly; browser WebAssembly is a separate target.

License

Licensed under either the MIT License or the Apache License, Version 2.0, at your option.

Metadata

Release files for glrmask 0.5.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 glrmask 0.5.0
File Size Uploaded Provenance Actions
glrmask-0.5.0.tar.gz 4.3 MB With provenance Details for glrmask-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for glrmask 0.5.0
File Actions
glrmask-0.5.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for glrmask-0.5.0-cp39-abi3-win_arm64.whl
glrmask-0.5.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for glrmask-0.5.0-cp39-abi3-win_amd64.whl
glrmask-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for glrmask-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
glrmask-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for glrmask-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
glrmask-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for glrmask-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
glrmask-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for glrmask-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
glrmask-0.5.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for glrmask-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
glrmask-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for glrmask-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 150.2 MB

Release files / glrmask-0.5.0.tar.gz

Download URL glrmask-0.5.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
1ec58dfe995b6b06f95cead55041782d7cb2be12f1326e7e4caae95c8020cbe5
BLAKE2b-256 checksum
How to use checksums
dacd893b5068d205f77786a8a61e047a3a715410dedf599b60e82bdd1c3e1050
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-win_arm64.whl

Download URL glrmask-0.5.0-cp39-abi3-win_arm64.whl
Size 16.0 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
720e3dd01bf601f5e940d4e35f361974997e2d00b6683c0b094232c2402eb55f
BLAKE2b-256 checksum
How to use checksums
0a4ec28c331ec002d2af6b622d831b2b710c53e262897b5922bb41bbbc03f2f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-win_amd64.whl

Download URL glrmask-0.5.0-cp39-abi3-win_amd64.whl
Size 17.3 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6c8a03b8cffce09c38c02d7aeb13aecb4fba77ea101e13d06d1f429513eed48b
BLAKE2b-256 checksum
How to use checksums
01650c9cc5fdd833593ab4c9a6b208b8a38dcceeeecae9d7827c5517a33e0473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL glrmask-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 20.4 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
24691d55e3ca3f7352aa03fd8246a1a70b94f158a3dec5e3ba1776f975627221
BLAKE2b-256 checksum
How to use checksums
401d25776d14c7f4cc594b9b7406f92cf7ea30007e27b002fdf3f75c36b15185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL glrmask-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 19.3 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
0e1166805f6f4bc2eb86200042ef822c3bf2ba4df5ac4d149487e5c2e03d6349
BLAKE2b-256 checksum
How to use checksums
f0ebd2a45ff2b97c4a21b8e74de84367ff31fefa0ab6dcf4917935c9d954dd84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL glrmask-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 19.7 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b04b9eace4156c2c5d074a94e9531509ebda9ff93e6ffa4c35bff61e5bb0e227
BLAKE2b-256 checksum
How to use checksums
ff1aa4ddee304bc5926a892a9255a2f26ea68886bbc9c4dc70daded151486325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL glrmask-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 19.2 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8c03284565e3d33c7aa2bca4d9621e7901acaea83b4f463e2154cc6725f60522
BLAKE2b-256 checksum
How to use checksums
a1071975df3cbc801ae3131faa922622c52f7fea9c62315d7dc6a6a0c026bd05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL glrmask-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Size 16.5 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6c9050b3f706beaa256a7e28c7212245c24bdb0fad6e95f7c08308656c2b8a41
BLAKE2b-256 checksum
How to use checksums
820e8012c3bb67393fb59b8617dda0cab7b6da629205b8b636c6b3220fb6e5a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / glrmask-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL glrmask-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 17.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
58048cfa56c01791d571d59f2416e884e0579e789a6707f42abe4576b6105883
BLAKE2b-256 checksum
How to use checksums
717128f81bc66cad6f4dec7455ec73b0e8bea5e916b3749317dacb0566cb4d47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for glrmask 0.5.0

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.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for glrmask-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

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.

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