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.

Related Projects

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vllm_sbw-1.0.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vllm_sbw-1.0.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file vllm_sbw-1.0.0.tar.gz.

File metadata

  • Download URL: vllm_sbw-1.0.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vllm_sbw-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4668067e1eed467a0feb406b3ce7a5ab9967aa8d5b7c28ca64ec68a65bf27e0d
MD5 17311c2469f3157b1d4d34d014f4f379
BLAKE2b-256 64172cd4e6b5af427f96992b5e51c07a7b84e1396792e20a57d06ecbd2f93bd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for vllm_sbw-1.0.0.tar.gz:

Publisher: publish.yml on si-mon-jinn/sbw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vllm_sbw-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vllm_sbw-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vllm_sbw-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c908ccb7cf8161a90956802c810c1f5e3d39906afe207fedafdfc2a1cc7ecdd
MD5 a4f339a3b3314be0a65fbf6fb7c563bb
BLAKE2b-256 478da06a42c6d8d1ac97f647815605bdfc7637440a6a72cbfd37443a6767f21c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vllm_sbw-1.0.0-py3-none-any.whl:

Publisher: publish.yml on si-mon-jinn/sbw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 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