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_ebnf('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.4.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.4.0
File Size Uploaded Provenance Actions
glrmask-0.4.0.tar.gz 4.3 MB With provenance Details for glrmask-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for glrmask 0.4.0
File Actions
glrmask-0.4.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for glrmask-0.4.0-cp39-abi3-win_arm64.whl
glrmask-0.4.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for glrmask-0.4.0-cp39-abi3-win_amd64.whl
glrmask-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for glrmask-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl
glrmask-0.4.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for glrmask-0.4.0-cp39-abi3-musllinux_1_2_aarch64.whl
glrmask-0.4.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.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
glrmask-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for glrmask-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
glrmask-0.4.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for glrmask-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
glrmask-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for glrmask-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 150.4 MB

Release files / glrmask-0.4.0.tar.gz

Download URL glrmask-0.4.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
30a32cba95b9fb4e66c1d865b90a3d34b698286dd7e0fcc5decfbe216059ea44
BLAKE2b-256 checksum
How to use checksums
5bfb5559c7d656e4338c76d1762ec428e006fb881b27e52eccb707a202be134a
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.0-cp39-abi3-win_arm64.whl
Size 16.0 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
76e2416fac0c68f594968af31193032ba11b1d535644c6fb17a543e21cada43a
BLAKE2b-256 checksum
How to use checksums
fd82a988a12c74f136de26846040c5903fa83d3ec2c764f5b9573a8e55313774
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.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
c75c387fd376f58062578aceb68654ce4867398834445cbb37d3f8ff033ad15a
BLAKE2b-256 checksum
How to use checksums
6ed4a47775c930601e6df485532abe912aee2332d1c18b49dc698d936a9606d0
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.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
2fca6e40368ada6254000faff6c028ca2cbbe99396285119d0b1c9a263807f17
BLAKE2b-256 checksum
How to use checksums
45df510ec5cd619ad1d1735897755136ca44fbceeff2219ad0d7e173eb7fa93d
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.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
7ec507bf756513550c1734b47ca1c527a18484a89a448ade8ab5d59a44f703b9
BLAKE2b-256 checksum
How to use checksums
109a65dd18b70e94080b62cda01fefae8a9c6689a7f7989780f9dfd3bef71cb3
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.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
dc41a466c45abbe7ff67e0eebbc38cf43568925b1523c8c2488188c25aa9283c
BLAKE2b-256 checksum
How to use checksums
47eef755bb39db8736e2552292001bfdd839caead4d9f8242ab649e238fb597c
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.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
4cd3b90c5b8f3b2ca8122137d4825f4ddd7793c67d7b4fa21e7f649703b24da4
BLAKE2b-256 checksum
How to use checksums
bbf863fae67854c3d8ee7b17d2b9bcb98223273a6a065e3f4ba0f0eb40cb2fa4
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.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
bce048d111f2cc722baa1a57d31ece00b782ac25ed207ade624fdb9fa52c050b
BLAKE2b-256 checksum
How to use checksums
63fdf337a29bf818c9bb3d424d7917a0508acd3d7124a2ea4e36ce58db266036
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 25, 2026.

Transparency log

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

Download URL glrmask-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 17.7 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2e1275b2d0c63a74cba9e0a60eca446eaf681dea1397cdcf40e9bc8abea33767
BLAKE2b-256 checksum
How to use checksums
62bdd90af484344eb39fdd969bf77f1532b8612e13ea9f9987a234358a05919f
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 25, 2026.

Transparency log

Security for glrmask 0.4.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.4.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 25, 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