Skip to main content

vllm-sbw

SBW Watermark Injection for vLLM — A logits processor that adds Stateless Bernoulli Watermarks during text generation.

This package provides watermark injection during inference. For detection, see sbw.

Features

  • Zero-overhead design — Watermark computation runs in parallel with model forward pass
  • CUDAGraph compatible — Works with vLLM's CUDAGraph optimization
  • Batch-aware — Efficient processing of multiple sequences
  • Configurable — Full control over watermark strength and parameters

Installation

pip install vllm-sbw

This automatically installs sbw as a dependency.

Quick Start

With vLLM Server

Start vLLM with the watermark logits processor:

vllm serve meta-llama/Llama-3.1-8B-Instruct \
    --logits-processors vllm_sbw:SBWLogitsProcessor

Then use the OpenAI-compatible API with watermark parameters:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")

response = client.completions.create(
    model="meta-llama/Llama-3.1-8B-Instruct",
    prompt="Explain quantum computing:",
    max_tokens=200,
    extra_body={
        "vllm_xargs": {
            "gamma": 0.25,
            "delta": 2.0,
        }
    }
)

print(response.choices[0].text)

With vLLM Offline

from vllm import LLM, SamplingParams
from vllm_sbw import SBWLogitsProcessor

llm = LLM(model="meta-llama/Llama-3.1-8B-Instruct")

sampling_params = SamplingParams(
    max_tokens=200,
    temperature=1.0,
    logits_processors=[SBWLogitsProcessor],
)

outputs = llm.generate(["Explain quantum computing:"], sampling_params)
print(outputs[0].outputs[0].text)

Parameters

Watermark parameters are passed via vllm_xargs in the API request:

Parameter Description Default
gamma Green list fraction (0.0-1.0) 0.25
delta Logit bias for green tokens 2.0
hash_key Secret key (must match detector) 15485863
seeding_scheme "selfhash", "lefthash", etc. "selfhash"

Disabling Watermark

Set delta=0.0 to generate text without watermarking:

extra_body={"vllm_xargs": {"gamma": 0.25, "delta": 0.0}}

Detecting Watermarks

Use the sbw package to detect watermarks in generated text:

from sbw import WatermarkDetector
from transformers import AutoTokenizer
import torch

tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
detector = WatermarkDetector(
    device=torch.device("cuda"),
    tokenizer=tokenizer,
    vocab=list(range(len(tokenizer))),
    gamma=0.25,  # Must match generation
    seeding_scheme="selfhash",
    hash_key=15485863,  # Must match generation
    z_threshold=4.0,
)

result = detector.detect(text=generated_text)
print(f"Watermark detected: {result['prediction']}")

Performance

SBW is designed for minimal inference overhead:

  • Parallel computation: Watermark logits computed during model forward pass
  • GPU-native: All operations on GPU, no CPU round-trips
  • CUDAGraph support: Compatible with vLLM's graph capture optimization

See the benchmarks directory for detailed performance measurements.

Citation

@inproceedings{flip-dont-shuffle-2026,
  title={Flip, Don't Shuffle: Watermarking LLMs at the Speed of Inference},
  author={Ceppi, Simone and Sanchez, Ignacio},
  booktitle={Proceedings of EMNLP 2026},
  year={2026}
}

License

EUPL-1.2

Metadata

Release files for vllm-sbw 1.0.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 vllm-sbw 1.0.0
File Size Uploaded
vllm_sbw-1.0.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vllm-sbw 1.0.0
File Interpreter ABI Platform
vllm_sbw-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / vllm_sbw-1.0.0.tar.gz

Download URL vllm_sbw-1.0.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4668067e1eed467a0feb406b3ce7a5ab9967aa8d5b7c28ca64ec68a65bf27e0d
BLAKE2b-256 checksum
How to use checksums
64172cd4e6b5af427f96992b5e51c07a7b84e1396792e20a57d06ecbd2f93bd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 27, 2026.

Transparency log

Release files / vllm_sbw-1.0.0-py3-none-any.whl

Download URL vllm_sbw-1.0.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c908ccb7cf8161a90956802c810c1f5e3d39906afe207fedafdfc2a1cc7ecdd
BLAKE2b-256 checksum
How to use checksums
478da06a42c6d8d1ac97f647815605bdfc7637440a6a72cbfd37443a6767f21c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.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