Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Read detailed usage below, or jump to the documentation with [Getting Started](h
uv pip install "nemo-safe-synthesizer[cu129,engine]" \
--index https://flashinfer.ai/whl/cu129 \
--index https://download.pytorch.org/whl/cu129 \
--index https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129 \
--index https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129 \
--index-strategy unsafe-best-match

# With pip:
pip install "nemo-safe-synthesizer[cu129,engine]" \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--extra-index-url https://flashinfer.ai/whl/cu129 \
--extra-index-url https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129
--extra-index-url https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129
```

Or install from source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Each score maps to concrete remediation guidance in the documentation. The [Prod
pip install "nemo-safe-synthesizer[cu129,engine]" \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--extra-index-url https://flashinfer.ai/whl/cu129 \
--extra-index-url https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129
--extra-index-url https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129
```

The quickest way to run your first pipeline is the CLI:
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/differential-privacy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"# SPDX-License-Identifier: Apache-2.0\n",
"\n",
"if command -v uv > /dev/null 2>&1; then\n",
" uv pip install \"nemo-safe-synthesizer[engine,cu129]\" --index https://flashinfer.ai/whl/cu129 --index https://download.pytorch.org/whl/cu129 --index https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129 --index-strategy unsafe-best-match\n",
" uv pip install \"nemo-safe-synthesizer[engine,cu129]\" --index https://flashinfer.ai/whl/cu129 --index https://download.pytorch.org/whl/cu129 --index https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129 --index-strategy unsafe-best-match\n",
" uv pip install kagglehub\n",
"else\n",
" pip install \"nemo-safe-synthesizer[engine,cu129]\" --extra-index-url https://flashinfer.ai/whl/cu129 --extra-index-url https://download.pytorch.org/whl/cu129 --extra-index-url https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129\n",
" pip install \"nemo-safe-synthesizer[engine,cu129]\" --extra-index-url https://flashinfer.ai/whl/cu129 --extra-index-url https://download.pytorch.org/whl/cu129 --extra-index-url https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129\n",
" pip install kagglehub\n",
"fi\n"
]
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/safe-synthesizer-101.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"# SPDX-License-Identifier: Apache-2.0\n",
"\n",
"if command -v uv > /dev/null 2>&1; then\n",
" uv pip install \"nemo-safe-synthesizer[engine,cu129]\" --index https://flashinfer.ai/whl/cu129 --index https://download.pytorch.org/whl/cu129 --index https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129 --index-strategy unsafe-best-match\n",
" uv pip install \"nemo-safe-synthesizer[engine,cu129]\" --index https://flashinfer.ai/whl/cu129 --index https://download.pytorch.org/whl/cu129 --index https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129 --index-strategy unsafe-best-match\n",
" uv pip install datasets\n",
"else\n",
" pip install \"nemo-safe-synthesizer[engine,cu129]\" --extra-index-url https://flashinfer.ai/whl/cu129 --extra-index-url https://download.pytorch.org/whl/cu129 --extra-index-url https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129\n",
" pip install \"nemo-safe-synthesizer[engine,cu129]\" --extra-index-url https://flashinfer.ai/whl/cu129 --extra-index-url https://download.pytorch.org/whl/cu129 --extra-index-url https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129\n",
" pip install datasets\n",
"fi\n"
]
Expand Down Expand Up @@ -217,7 +217,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -231,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.9"
"version": "3.13.12"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/time-series-financial-transactions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"# SPDX-License-Identifier: Apache-2.0\n",
"\n",
"if command -v uv > /dev/null 2>&1; then\n",
" uv pip install \"nemo-safe-synthesizer[engine,cu129]\" --index https://flashinfer.ai/whl/cu129 --index https://download.pytorch.org/whl/cu129 --index https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129 --index-strategy unsafe-best-match\n",
" uv pip install \"nemo-safe-synthesizer[engine,cu129]\" --index https://flashinfer.ai/whl/cu129 --index https://download.pytorch.org/whl/cu129 --index https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129 --index-strategy unsafe-best-match\n",
"else\n",
" pip install \"nemo-safe-synthesizer[engine,cu129]\" --extra-index-url https://flashinfer.ai/whl/cu129 --extra-index-url https://download.pytorch.org/whl/cu129 --extra-index-url https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129\n",
" pip install \"nemo-safe-synthesizer[engine,cu129]\" --extra-index-url https://flashinfer.ai/whl/cu129 --extra-index-url https://download.pytorch.org/whl/cu129 --extra-index-url https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129\n",
"fi"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ indexes outside PyPI. You must pass the extra index URLs shown below.
pip install "nemo-safe-synthesizer[cu129,engine]" \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--extra-index-url https://flashinfer.ai/whl/cu129 \
--extra-index-url https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129
--extra-index-url https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129
```

=== "uv"
Expand All @@ -46,7 +46,7 @@ indexes outside PyPI. You must pass the extra index URLs shown below.
uv pip install "nemo-safe-synthesizer[cu129,engine]" \
--index https://flashinfer.ai/whl/cu129 \
--index https://download.pytorch.org/whl/cu129 \
--index https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129 \
--index https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129 \
--index-strategy unsafe-best-match
```

Expand Down
13 changes: 6 additions & 7 deletions docs/user-guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,21 @@ configuration reference.
`uv sync` fails with an error mentioning incompatible `transformers` and
`vllm` requirements.

Safe Synthesizer requires `transformers>=5.6,<6`. vLLM 0.20.0 accepts
transformers v5, but excludes several early 5.x releases that are not
compatible with its runtime. Keep vLLM's exclusions intact and resolve to a
newer transformers v5 release.
Safe Synthesizer requires `transformers>=5.12,<5.12.1` with vLLM 0.24.0.
Keep vLLM's constraints intact so the resolver selects the tested
Transformers/vLLM pairing.

```toml
[project]
dependencies = [
"transformers>=5.6,<6",
"vllm==0.20.0",
"transformers>=5.12,<5.12.1",
"vllm==0.24.0",
]
```

If you've vendored or copied parts of `pyproject.toml` into another project,
avoid adding a broad `transformers>=5.0,<6` override for vLLM. That can erase
vLLM's explicit exclusions and allow incompatible early v5 releases.
vLLM's explicit constraints and allow incompatible Transformers releases.

### Slow Tokenizer Warning

Expand Down
28 changes: 14 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ engine = [
cpu = [
"accelerate>=1.1.0",
"bitsandbytes>=0.46.1",
"flashinfer-python==0.6.8.post1; sys_platform=='linux'",
"flashinfer-cubin==0.6.8.post1; sys_platform=='linux'",
"flashinfer-python==0.6.13; sys_platform=='linux'",
"flashinfer-cubin==0.6.13; sys_platform=='linux'",
"gliner",
"kernels>=0.12.1,<0.15",
"peft>=0.18.0",
Expand All @@ -127,19 +127,19 @@ cpu = [
"torchvision==0.26.0; sys_platform == 'darwin'",
"torchvision==0.26.0+cpu; sys_platform == 'linux'",
"torchao==0.17.0",
"transformers>=5.6,<6",
"transformers==5.12.0",
"triton>=2.0.0; sys_platform=='linux'",
"trl>=0.23.0",
"vllm==0.20.0; sys_platform=='linux'",
"vllm==0.24.0; sys_platform=='linux'",
"xgrammar>=0.2.0; sys_platform=='linux'",
]

cu129 = [
"accelerate>=1.1.0",
"bitsandbytes>=0.46.1",
"flashinfer-python==0.6.8.post1; sys_platform == 'linux'",
"flashinfer-cubin==0.6.8.post1; sys_platform == 'linux'",
"flashinfer-jit-cache==0.6.8.post1+cu129; sys_platform == 'linux'",
"flashinfer-python==0.6.13; sys_platform == 'linux'",
"flashinfer-cubin==0.6.13; sys_platform == 'linux'",
"flashinfer-jit-cache==0.6.13+cu129; sys_platform == 'linux'",
"gliner",
"kernels>=0.12.1,<0.15",
"nvidia-cublas-cu12; sys_platform == 'linux'",
Expand All @@ -152,10 +152,10 @@ cu129 = [
"torchaudio==2.11.0+cu129; sys_platform == 'linux'",
"torchvision==0.26.0+cu129; sys_platform == 'linux'",
"torchao==0.17.0+cu129; sys_platform == 'linux' and platform_machine == 'x86_64'",
"transformers>=5.6,<6",
"transformers>=5.12,<5.12.1",
"triton>=2.0.0; sys_platform == 'linux'",
"trl>=0.23.0",
"vllm==0.20.0+cu129; sys_platform == 'linux'",
"vllm==0.24.0+cu129; sys_platform == 'linux'",
"xgrammar>=0.2.0; sys_platform == 'linux'",
]

Expand All @@ -180,8 +180,8 @@ conflicts = [


override-dependencies = [
"flashinfer-python==0.6.8.post1; sys_platform != 'darwin'",
"flashinfer-cubin==0.6.8.post1; sys_platform != 'darwin'",
"flashinfer-python==0.6.13; sys_platform != 'darwin'",
"flashinfer-cubin==0.6.13; sys_platform != 'darwin'",
]

environments = [
Expand Down Expand Up @@ -225,7 +225,7 @@ constraint-dependencies = [
# here we specifiy the dep's source from which UV should attempt to resolve
triton = { index = "pytorch-cu129", extra = "cu129" }
vllm = [
{ index = "vllm-v0-20-0-cu129", marker = "sys_platform == 'linux'", extra = "cu129" },
{ index = "vllm-v0-24-0-cu129", marker = "sys_platform == 'linux'", extra = "cu129" },
]
# for torch - we have a "cpu" dep set and "cu129" dep set, specified in the optional dependencies above
torch = [
Expand Down Expand Up @@ -319,8 +319,8 @@ url = "https://flashinfer.ai/whl/cu129"
explicit = true

[[tool.uv.index]]
name = "vllm-v0-20-0-cu129"
url = "https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129"
name = "vllm-v0-24-0-cu129"
url = "https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129"
Comment thread
mckornfield marked this conversation as resolved.
explicit = true

[[tool.uv.index]]
Expand Down
2 changes: 1 addition & 1 deletion script/slurm/slurm_nss_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if [[ -n "${NSS_VERSION:-}" ]]; then
uv pip install "nemo-safe-synthesizer[cu129,engine]==${NSS_VERSION}" \
--index https://flashinfer.ai/whl/cu129 \
--index https://download.pytorch.org/whl/cu129 \
--index https://wheels.vllm.ai/88d34c6409e9fb3c7b8ca0c04756f061d2099eb1/cu129 \
--index https://wheels.vllm.ai/ee0da84ab9e04ac7610e28580af62c365e898389/cu129 \
--index-strategy unsafe-best-match
NSS_RUN_CMD="${PYPI_VENV}/bin/safe-synthesizer"
echo "[NSS SLURM] Using PyPI install: nemo-safe-synthesizer==${NSS_VERSION} on Python ${NSS_PYTHON_VERSION}"
Expand Down
20 changes: 12 additions & 8 deletions src/nemo_safe_synthesizer/generation/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any
from typing import Any, Protocol

from ..config import SafeSynthesizerParameters
from ..config.generate import ValidationParameters
Expand All @@ -21,9 +21,6 @@
from ..llm.metadata import ModelMetadata
from ..observability import get_logger

if TYPE_CHECKING:
from transformers import PreTrainedTokenizerBase

logger = get_logger(__name__)

# Re-export the parsed-record types so existing imports of
Expand All @@ -39,6 +36,13 @@
]


class EncodeOnlyTokenizer(Protocol):
"""Tokenizer interface needed for per-record token counting."""

def encode(self, text: str, *args: Any, **kwargs: Any) -> list[int]:
"""Return token IDs for ``text``."""


class Processor(ABC):
"""Abstract class for processing text generation results from the LLM.

Expand All @@ -55,7 +59,7 @@ def __init__(
self,
schema: dict[str, Any],
config: ValidationParameters,
tokenizer: PreTrainedTokenizerBase | None = None,
tokenizer: EncodeOnlyTokenizer | None = None,
):
self.schema = schema
self.config = config
Expand Down Expand Up @@ -166,7 +170,7 @@ def __init__(
time_column: str | None,
interval_seconds: int | None,
time_format: str | None,
tokenizer: PreTrainedTokenizerBase | None = None,
tokenizer: EncodeOnlyTokenizer | None = None,
):
super().__init__(schema=schema, config=config, tokenizer=tokenizer)
if time_column is None:
Expand Down Expand Up @@ -232,7 +236,7 @@ def __init__(
eos_token: str,
group_by: str,
order_by: str | None = None,
tokenizer: PreTrainedTokenizerBase | None = None,
tokenizer: EncodeOnlyTokenizer | None = None,
):
super().__init__(schema=schema, config=config, tokenizer=tokenizer)
self.group_by: list[str] = [group_by]
Expand Down Expand Up @@ -376,7 +380,7 @@ def create_processor(
schema: dict[str, Any],
metadata: ModelMetadata,
config: SafeSynthesizerParameters,
tokenizer: PreTrainedTokenizerBase | None = None,
tokenizer: EncodeOnlyTokenizer | None = None,
) -> Processor:
"""Create the appropriate record processor for the current pipeline mode.

Expand Down
Loading
Loading