fix: upgrade xgrammar and use new structured gen method - #541
Conversation
Signed-off-by: mkornfield <mkornfield@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR adds XGrammar Structural Tag support for structured generation, enabling a new ChangesStructural Tag Feature Implementation
Configuration, Generation, & Integration Tests
Documentation & Benchmarking
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR upgrades xgrammar from 0.1.32 to 0.2.1 and introduces a new
Confidence Score: 5/5Safe to merge — the The No files require special attention. Important Files Changed
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ec9a86c4-abdc-4ae2-b966-48a29404293a
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock,!uv.lock
📒 Files selected for processing (14)
docs/user-guide/configuration.mddocs/user-guide/running.mdpyproject.tomlsrc/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/config/generate.pysrc/nemo_safe_synthesizer/generation/regex_manager.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pysrc/nemo_safe_synthesizer/sdk/library_builder.pytests/benchmarks/test_generation_structured_methods.pytests/cli/test_run.pytests/e2e/test_safe_synthesizer.pytests/generation/test_regex_manager.pytests/generation/test_vllm_backend.pytests/sdk/test_process_data.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Unit Tests (3.12)
- GitHub Check: Unit Tests (3.13)
- GitHub Check: Unit Tests (3.11)
- GitHub Check: Smoke Tests
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{md,markdown,py}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown,py}: Avoid decorative bold (**text**) in list items, body text, and docstrings; use structural cues (headers, list markers, colons, backticks) for emphasis instead
Use backticks for code identifiers, paths, and CLI commands in markdown and docstrings
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pytests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pysrc/nemo_safe_synthesizer/generation/regex_manager.pydocs/user-guide/running.mdtests/generation/test_regex_manager.pytests/cli/test_run.pydocs/user-guide/configuration.mdtests/benchmarks/test_generation_structured_methods.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*.py: Use American English spelling: 'initialize' not 'initialise', 'recognize' not 'recognise', 'color' not 'colour'.
Useobservability.get_logger(__name__)for logging, neverlogging.getLogger()orstructlog.get_logger()directly.
Use category loggers:.runtimefor internals,.userfor progress/results,.systemfor system events.
Never useprint()for operational output. Useclick.echo()for CLI output orsys.stdout.write()for raw output in tools.
Useextra={}in logging for structured data that downstream tools should query or aggregate; use f-strings for human-readable context.
Raise from the custom error hierarchy with dual inheritance:SafeSynthesizerError(base),UserError,DataError,ParameterError,GenerationError,InternalError.
UseNSSBaseModelfor config/parameter models inconfig/which define user-facing configuration. Use rawBaseModelor module-specific bases for data transfer objects and internal structures.
UseBaseSettingsfor env/CLI settings. PreferAliasChoiceson individual fields when a field needs to respond to both its Python name and an env var name.
IncludeField(description=...)for Pydantic model fields as the canonical field docstring for API documentation and CLI help text.
Use assignment-styletype = Field(default=..., description="...")as the default for Pydantic model fields because type checkers understanddefault,default_factory, andaliasin assignment style.
UseAnnotatedonly when the field carries additional metadata beyondField()--ValueValidator,AutoParam,DependsOnValidator, reusable constrained type aliases, nested-type constraints, or discriminated unions.
Put defaults as bare assignment (= value), not insideField(default=...), when usingAnnotated. Exception: use assignment-styleField(default_factory=...)for defaults that cannot be expressed as bare assignments.
Use@dataclass(frozen=True)for immutable value objects and validators; mu...
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pytests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pysrc/nemo_safe_synthesizer/generation/regex_manager.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
src/**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
src/**/*.py: Use relative imports insrc/(e.g.,from ..observability import get_logger).
Do not useprint()statements in library code. Useget_logger(__name__)fromobservability.pyorclick.echo()for CLI.
Do not useassertfor validation in library code. Useif/raisefor input validation.assertstatements can be stripped by-Oand must never guard correctness.
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pysrc/nemo_safe_synthesizer/config/generate.pysrc/nemo_safe_synthesizer/generation/regex_manager.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
⚙️ CodeRabbit configuration file
Review library code against STYLE_GUIDE.md. Focus on behavior, API contracts, error handling, resource cleanup, typing, logging, and user-facing failures. Public APIs and nontrivial functions need Google-style docstrings.
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pysrc/nemo_safe_synthesizer/config/generate.pysrc/nemo_safe_synthesizer/generation/regex_manager.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
**/*.{py,sh,yaml,yml}
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Include SPDX copyright header at the top:
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.and# SPDX-License-Identifier: Apache-2.0. Themake formatcommand handles this automatically.
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pytests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pysrc/nemo_safe_synthesizer/generation/regex_manager.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
**/*
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*: Include a newline at the end of all files, never trailing whitespace. This is enforced bypre-commit.
Use line length of 120 characters for code, comments, and docstrings (configured inruff.toml).
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pytests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pysrc/nemo_safe_synthesizer/generation/regex_manager.pydocs/user-guide/running.mdtests/generation/test_regex_manager.pypyproject.tomltests/cli/test_run.pydocs/user-guide/configuration.mdtests/benchmarks/test_generation_structured_methods.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
⚙️ CodeRabbit configuration file
**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.
- Refactor suggestion: use for local maintainability problems introduced
by the diff when they have clear future cost, such as duplicated setup,
unclear boundaries, over-mocking, avoidable complexity, or opaque test
helpers.- Nitpick: avoid in chill mode. Do not emit formatting, import-order,
wording, or style-only comments unless automated tools cannot catch the
issue and it affects maintainability.Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.
- Major: incorrect generation/training/evaluation behavior, broken
CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
cleanup and process-isolation bugs likely to fail CI or production
runs.- Minor: localized bugs, missing focused tests for changed behavior, or
bad test patterns that weaken regression coverage.- Trivial: small cleanup with no behavior impact. Usually suppress in
chill mode.- Info: context only. Avoid unless it helps reviewers understand risk.
Safe-Synthesizer-specific review focus: - Data ...
Files:
src/nemo_safe_synthesizer/cli/run.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pytests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pysrc/nemo_safe_synthesizer/generation/regex_manager.pydocs/user-guide/running.mdtests/generation/test_regex_manager.pypyproject.tomltests/cli/test_run.pydocs/user-guide/configuration.mdtests/benchmarks/test_generation_structured_methods.pysrc/nemo_safe_synthesizer/sdk/library_builder.py
src/nemo_safe_synthesizer/generation/**/*.py
⚙️ CodeRabbit configuration file
Review generation changes for retry loops, stopping conditions, invalid record handling, regex/structured output contracts, backend teardown, memory cleanup, and vLLM assumptions.
Files:
src/nemo_safe_synthesizer/generation/vllm_backend.pysrc/nemo_safe_synthesizer/generation/regex_manager.py
tests/**
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Tests should mirror the
src/directory structure intests/
Files:
tests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pytests/generation/test_vllm_backend.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.py
tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Tests in
tests/e2e/should be auto-marked withe2emarker, tests intests/smoke/withsmokemarker, others withunitmarker
tests/**/*.py: Use absolute imports intests/(e.g.,from nemo_safe_synthesizer.observability import get_logger).
Usefixture_prefix convention for fixtures for grep-ability and to separate fixtures from test functions. Add a one-line docstring describing the fixture's purpose and data.
Use function-scoped fixtures by default. Session scope only when empirically justified by test runtime.
Use bareassertas the primary assertion style;pytest.raises()withmatch=for exceptions;pytest.approx()for floating-point comparisons.
Mark CUDA-dependent tests with@pytest.mark.e2e,@pytest.mark.smoke, or@pytest.mark.requires_gpu.
Mock only external boundaries, not internal implementation details.
Ensure test isolation: no shared mutable state or execution-order dependencies between tests. If something must be run first before executing a test, include it in the test or a fixture.
Use@pytest.mark.parametrizefor testing multiple input combinations rather than copy-pasting similar tests.Organize tests using pytest following the structure in
tests/TESTING.mdwith support for unit tests, smoke tests, and end-to-end tests
Files:
tests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pytests/generation/test_vllm_backend.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.py
⚙️ CodeRabbit configuration file
Review tests against tests/TESTING.md. Check marker usage, fixture naming, tmp_path usage, determinism, and GPU/vLLM process-isolation requirements. Flag slop tests that only check that code runs, assert result is not None when stronger invariants exist, over-mock internal implementation details, patch around the bug instead of reproducing it, or add broad snapshot/golden churn without a clear contract. Flag change detector tests that fail on harmless refactors, formatting, record ordering, incidental wording, or private implementation details without demonstrating a behavior regression. Prefer existing fixtures or focused new fixtures for repeated setup; keep tests DRY when reasonable without making the behavior under test opaque. print() is allowed in tests.
Files:
tests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pytests/generation/test_vllm_backend.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.py
**/*test*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
unit_testmarker is deprecated; useunitinstead
Files:
tests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pytests/generation/test_vllm_backend.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.py
src/nemo_safe_synthesizer/config/**/*.py
⚙️ CodeRabbit configuration file
Treat config changes as user-facing API changes. Check Pydantic field descriptions, defaults, validators, aliases, override behavior, CLI help text impact, YAML compatibility, and documented parameter semantics.
Files:
src/nemo_safe_synthesizer/config/generate.py
**/*.{md,markdown}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown}: Bold is acceptable only in markdown tables where it's the conventional way to mark header-like cells in the body
Use##headers to segment markdown sections instead of bold text
Use--(em-dash) instead of-(hyphen) for asides in markdown
Files:
docs/user-guide/running.mddocs/user-guide/configuration.md
**/*.md
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*.md: No decorative**bold**in body text, list items, or docstrings. Use headers, list markers, colons, and backticks for structure.
Use--(em-dash) for asides, not-(hyphen).
Use single backticks for code identifiers, paths, and CLI commands in Markdown.
Use Mermaid diagrams with no spaces in node IDs, quote labels with special characters, no explicit colors or styles.
Include SPDX copyright header in Markdown files using HTML comments:<!-- SPDX-FileCopyrightText: ... -->and<!-- SPDX-License-Identifier: Apache-2.0 -->. Exception: for.mdfiles with YAML frontmatter, include hash-comment headers inside the frontmatter block.All Markdown files require SPDX copyright headers, automatically added by
make format
Files:
docs/user-guide/running.mddocs/user-guide/configuration.md
docs/**/*.md
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Classify documentation pages as tutorial, how-to, explanation, or reference per the Diataxis framework. Use MkDocs Material syntax for admonitions (
!!! note), tabs (===), and code blocks with titles and highlights.
docs/**/*.md: Classify documentation content using the Diataxis framework (TUTORIAL, HOW-TO, EXPLANATION, or REFERENCE) and ensure each page fits ONE type only
Use MkDocs Material admonition syntax (!!! note, !!! warning, ??? tip) for callouts and collapsible content
Use MkDocs Material tab syntax (=== "Tab Name") to present multiple variations or language-specific examples
Include code block metadata in MkDocs Material format: use title attribute for filenames and hl_lines for syntax highlighting of specific lines
Use Mermaid diagram syntax for flowcharts and visual representations in documentation
List prerequisites at the top of each documentation page before main content
End documentation pages with 'Next steps' section containing links to related content
docs/**/*.md: Documentation pages must follow Diataxis framework organization: getting-started/ for tutorials, user-guide/ for how-tos and reference, architecture/ for explanations, reference/ for API docs (auto-generated), dev-notes/ for release notes
Add new documentation pages to thenav:section ofmkdocs.ymlfor sidebar appearance
Use MkDocs Material Markdown extensions including admonitions (!!! note, !!! warning), content tabs (===), code blocks with syntax highlighting, mermaid diagrams, task lists, footnotes, and definition lists
Files:
docs/user-guide/running.mddocs/user-guide/configuration.md
docs/**
⚙️ CodeRabbit configuration file
Review documentation as MkDocs Material content. Check Diataxis fit, accurate commands, internal links, code fences, and markdown style from STYLE_GUIDE.md.
Files:
docs/user-guide/running.mddocs/user-guide/configuration.md
pyproject.toml
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Package metadata, dependencies, and extras (cpu/cu128/engine) should be configured in
pyproject.tomlOrder sections in
pyproject.tomlas:[project],[dependency-groups],[project.optional-dependencies],[tool.uv],[build-system],[tool.*].Python version support must be 3.11–3.13 as specified in
.python-versionand pyproject.toml; Python 3.14+ is not supported
Files:
pyproject.toml
⚙️ CodeRabbit configuration file
Treat pyproject.toml as high-risk. Check package metadata, uv indexes, dependency groups, optional extras, Python version bounds, hatch config, ty config, script entry points, dependency consistency, and whether changes require regenerating uv.lock.
Files:
pyproject.toml
**/*.toml
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*.toml: Use spaces around=for key-value pairs in TOML files.
Use# commentformat for comments in TOML files; use inline comments for dependency pins.
Files:
pyproject.toml
🧠 Learnings (1)
📚 Learning: 2026-05-27T22:20:37.354Z
Learnt from: kendrickb-nvidia
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 520
File: tests/generation/test_vllm_backend.py:556-587
Timestamp: 2026-05-27T22:20:37.354Z
Learning: In NVIDIA-NeMo/Safe-Synthesizer, `tests/conftest.py`’s `pytest_collection_modifyitems` hook applies pytest category markers automatically based on each test file’s path: tests under `/e2e/` get `pytest.mark.e2e`, tests under `/smoke/` get `pytest.mark.smoke`, and all other tests get `pytest.mark.unit`. Therefore, when reviewing pytest tests outside `tests/e2e/` and `tests/smoke/`, do not flag missing explicit `pytest.mark.unit` decorators on test classes/functions as an issue (the hook will add them during collection). If a new test directory/category is introduced, ensure the hook is updated so it’s categorized correctly.
Applied to files:
tests/e2e/test_safe_synthesizer.pytests/sdk/test_process_data.pytests/generation/test_vllm_backend.pytests/generation/test_regex_manager.pytests/cli/test_run.pytests/benchmarks/test_generation_structured_methods.py
🪛 Ruff (0.15.14)
tests/benchmarks/test_generation_structured_methods.py
[error] 208-208: subprocess call: check for execution of untrusted input
(S603)
🔇 Additional comments (12)
tests/benchmarks/test_generation_structured_methods.py (5)
206-221: Static analysis S603 is a false positive here.The subprocess call uses
sys.executable(the current Python interpreter) and constructs the command from controlled test fixtures and environment variables. This is standard practice for integration/benchmark tests that invoke the project's CLI. The warning about "untrusted input" doesn't apply to this controlled test scenario.
1-39: LGTM!
42-130: LGTM!
132-166: LGTM!
169-248: LGTM!tests/generation/test_vllm_backend.py (1)
117-124: LGTM!Also applies to: 220-248
src/nemo_safe_synthesizer/cli/run.py (1)
571-571: LGTM!tests/cli/test_run.py (1)
623-650: LGTM!tests/sdk/test_process_data.py (1)
442-478: LGTM!docs/user-guide/configuration.md (1)
163-163: LGTM!docs/user-guide/running.md (1)
886-891: LGTM!tests/e2e/test_safe_synthesizer.py (1)
75-75: ⚡ Quick winAudit
pretrained_modelfixture/parameter usage intests/e2e/test_safe_synthesizer.py: Locate wherepretrained_modelis defined (fixture or imported symbol) and confirm the e2e test actually uses it; if unused, remove the fixture/parameter to avoid unnecessary setup/side effects.
Signed-off-by: mkornfield <mkornfield@nvidia.com>
kendrickb-nvidia
left a comment
There was a problem hiding this comment.
A few comments, but looks promising.
Signed-off-by: mkornfield <mkornfield@nvidia.com>
Signed-off-by: mkornfield <mkornfield@nvidia.com>
nina-xu
left a comment
There was a problem hiding this comment.
lgtm! agree with the other comments
Signed-off-by: mkornfield <mkornfield@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e20f69c8-4514-401c-99c2-b93c4fd625bc
📒 Files selected for processing (10)
src/nemo_safe_synthesizer/config/generate.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pysrc/nemo_safe_synthesizer/preflight/__init__.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/checks/generation.pytests/benchmarks/test_generation_structured_methods.pytests/config/test_generate.pytests/generation/structural_tag_helpers.pytests/generation/test_regex_manager.pytests/preflight/test_preflight.py
🚧 Files skipped from review as they are similar to previous changes (2)
- src/nemo_safe_synthesizer/generation/vllm_backend.py
- tests/benchmarks/test_generation_structured_methods.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Unit Tests (3.12)
- GitHub Check: Unit Tests (3.11)
- GitHub Check: Unit Tests (3.13)
- GitHub Check: Smoke Tests
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{md,markdown,py}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown,py}: Avoid decorative bold (**text**) in list items, body text, and docstrings; use structural cues (headers, list markers, colons, backticks) for emphasis instead
Use backticks for code identifiers, paths, and CLI commands in markdown and docstrings
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pytests/preflight/test_preflight.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*.py: Use American English spelling: 'initialize' not 'initialise', 'recognize' not 'recognise', 'color' not 'colour'.
Useobservability.get_logger(__name__)for logging, neverlogging.getLogger()orstructlog.get_logger()directly.
Use category loggers:.runtimefor internals,.userfor progress/results,.systemfor system events.
Never useprint()for operational output. Useclick.echo()for CLI output orsys.stdout.write()for raw output in tools.
Useextra={}in logging for structured data that downstream tools should query or aggregate; use f-strings for human-readable context.
Raise from the custom error hierarchy with dual inheritance:SafeSynthesizerError(base),UserError,DataError,ParameterError,GenerationError,InternalError.
UseNSSBaseModelfor config/parameter models inconfig/which define user-facing configuration. Use rawBaseModelor module-specific bases for data transfer objects and internal structures.
UseBaseSettingsfor env/CLI settings. PreferAliasChoiceson individual fields when a field needs to respond to both its Python name and an env var name.
IncludeField(description=...)for Pydantic model fields as the canonical field docstring for API documentation and CLI help text.
Use assignment-styletype = Field(default=..., description="...")as the default for Pydantic model fields because type checkers understanddefault,default_factory, andaliasin assignment style.
UseAnnotatedonly when the field carries additional metadata beyondField()--ValueValidator,AutoParam,DependsOnValidator, reusable constrained type aliases, nested-type constraints, or discriminated unions.
Put defaults as bare assignment (= value), not insideField(default=...), when usingAnnotated. Exception: use assignment-styleField(default_factory=...)for defaults that cannot be expressed as bare assignments.
Use@dataclass(frozen=True)for immutable value objects and validators; mu...
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pytests/preflight/test_preflight.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
src/**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
src/**/*.py: Use relative imports insrc/(e.g.,from ..observability import get_logger).
Do not useprint()statements in library code. Useget_logger(__name__)fromobservability.pyorclick.echo()for CLI.
Do not useassertfor validation in library code. Useif/raisefor input validation.assertstatements can be stripped by-Oand must never guard correctness.
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pysrc/nemo_safe_synthesizer/config/generate.py
⚙️ CodeRabbit configuration file
Review library code against STYLE_GUIDE.md. Focus on behavior, API contracts, error handling, resource cleanup, typing, logging, and user-facing failures. Public APIs and nontrivial functions need Google-style docstrings.
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pysrc/nemo_safe_synthesizer/config/generate.py
**/*.{py,sh,yaml,yml}
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Include SPDX copyright header at the top:
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.and# SPDX-License-Identifier: Apache-2.0. Themake formatcommand handles this automatically.
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pytests/preflight/test_preflight.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
**/*
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*: Include a newline at the end of all files, never trailing whitespace. This is enforced bypre-commit.
Use line length of 120 characters for code, comments, and docstrings (configured inruff.toml).
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pytests/preflight/test_preflight.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
⚙️ CodeRabbit configuration file
**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.
- Refactor suggestion: use for local maintainability problems introduced
by the diff when they have clear future cost, such as duplicated setup,
unclear boundaries, over-mocking, avoidable complexity, or opaque test
helpers.- Nitpick: avoid in chill mode. Do not emit formatting, import-order,
wording, or style-only comments unless automated tools cannot catch the
issue and it affects maintainability.Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.
- Major: incorrect generation/training/evaluation behavior, broken
CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
cleanup and process-isolation bugs likely to fail CI or production
runs.- Minor: localized bugs, missing focused tests for changed behavior, or
bad test patterns that weaken regression coverage.- Trivial: small cleanup with no behavior impact. Usually suppress in
chill mode.- Info: context only. Avoid unless it helps reviewers understand risk.
Safe-Synthesizer-specific review focus: - Data ...
Files:
src/nemo_safe_synthesizer/preflight/checks/generation.pysrc/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.pytests/preflight/test_preflight.pysrc/nemo_safe_synthesizer/config/generate.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
src/**/__init__.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Include
__init__.pyfiles in every directory undersrc/that contains Python files, even if empty, to ensure the directory is recognized as a Python package.
Files:
src/nemo_safe_synthesizer/preflight/checks/__init__.pysrc/nemo_safe_synthesizer/preflight/__init__.py
tests/**
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Tests should mirror the
src/directory structure intests/
Files:
tests/preflight/test_preflight.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Tests in
tests/e2e/should be auto-marked withe2emarker, tests intests/smoke/withsmokemarker, others withunitmarker
tests/**/*.py: Use absolute imports intests/(e.g.,from nemo_safe_synthesizer.observability import get_logger).
Usefixture_prefix convention for fixtures for grep-ability and to separate fixtures from test functions. Add a one-line docstring describing the fixture's purpose and data.
Use function-scoped fixtures by default. Session scope only when empirically justified by test runtime.
Use bareassertas the primary assertion style;pytest.raises()withmatch=for exceptions;pytest.approx()for floating-point comparisons.
Mark CUDA-dependent tests with@pytest.mark.e2e,@pytest.mark.smoke, or@pytest.mark.requires_gpu.
Mock only external boundaries, not internal implementation details.
Ensure test isolation: no shared mutable state or execution-order dependencies between tests. If something must be run first before executing a test, include it in the test or a fixture.
Use@pytest.mark.parametrizefor testing multiple input combinations rather than copy-pasting similar tests.Organize tests using pytest following the structure in
tests/TESTING.mdwith support for unit tests, smoke tests, and end-to-end tests
Files:
tests/preflight/test_preflight.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
⚙️ CodeRabbit configuration file
Review tests against tests/TESTING.md. Check marker usage, fixture naming, tmp_path usage, determinism, and GPU/vLLM process-isolation requirements. Flag slop tests that only check that code runs, assert result is not None when stronger invariants exist, over-mock internal implementation details, patch around the bug instead of reproducing it, or add broad snapshot/golden churn without a clear contract. Flag change detector tests that fail on harmless refactors, formatting, record ordering, incidental wording, or private implementation details without demonstrating a behavior regression. Prefer existing fixtures or focused new fixtures for repeated setup; keep tests DRY when reasonable without making the behavior under test opaque. print() is allowed in tests.
Files:
tests/preflight/test_preflight.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
**/*test*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
unit_testmarker is deprecated; useunitinstead
Files:
tests/preflight/test_preflight.pytests/config/test_generate.pytests/generation/test_regex_manager.py
src/nemo_safe_synthesizer/config/**/*.py
⚙️ CodeRabbit configuration file
Treat config changes as user-facing API changes. Check Pydantic field descriptions, defaults, validators, aliases, override behavior, CLI help text impact, YAML compatibility, and documented parameter semantics.
Files:
src/nemo_safe_synthesizer/config/generate.py
🧠 Learnings (1)
📚 Learning: 2026-05-27T22:20:37.354Z
Learnt from: kendrickb-nvidia
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 520
File: tests/generation/test_vllm_backend.py:556-587
Timestamp: 2026-05-27T22:20:37.354Z
Learning: In NVIDIA-NeMo/Safe-Synthesizer, `tests/conftest.py`’s `pytest_collection_modifyitems` hook applies pytest category markers automatically based on each test file’s path: tests under `/e2e/` get `pytest.mark.e2e`, tests under `/smoke/` get `pytest.mark.smoke`, and all other tests get `pytest.mark.unit`. Therefore, when reviewing pytest tests outside `tests/e2e/` and `tests/smoke/`, do not flag missing explicit `pytest.mark.unit` decorators on test classes/functions as an issue (the hook will add them during collection). If a new test directory/category is introduced, ensure the hook is updated so it’s categorized correctly.
Applied to files:
tests/preflight/test_preflight.pytests/generation/structural_tag_helpers.pytests/config/test_generate.pytests/generation/test_regex_manager.py
🪛 Ruff (0.15.15)
src/nemo_safe_synthesizer/config/generate.py
[warning] 25-30: __all__ is not sorted
Apply an isort-style sorting to __all__
(RUF022)
🔇 Additional comments (12)
tests/preflight/test_preflight.py (1)
42-42: LGTM!Also applies to: 265-309
tests/config/test_generate.py (1)
27-40: ⚡ Quick winPydantic wrapping of
ParameterErroris appropriate
ParameterErroris defined asclass ParameterError(UserError, ValueError), so Pydantic v2 will wrap it aspydantic.ValidationError; these tests’pytest.raises(ValidationError, ...)expectations align with the error hierarchy.src/nemo_safe_synthesizer/config/generate.py (4)
221-229: LGTM!
33-46: LGTM!
23-23: LGTM!
174-185: LGTM!src/nemo_safe_synthesizer/preflight/checks/generation.py (1)
1-33: LGTM!src/nemo_safe_synthesizer/preflight/__init__.py (1)
27-27: LGTM!Also applies to: 81-81
src/nemo_safe_synthesizer/preflight/checks/__init__.py (1)
33-33: LGTM!Also applies to: 47-47, 64-64
tests/generation/test_regex_manager.py (2)
562-611: LGTM!
614-626: LGTM!tests/generation/structural_tag_helpers.py (1)
31-35: xgrammar 0.2.0 Structural Tag round-trip API matches the helper’s usage
GrammarCompiler.compile_structural_tag()in xgrammar 0.2.0 accepts thestructural_tagargument as a JSON string (as well as a dict/StructuralTag), andGrammarMatcherprovidesaccept_string()plusis_completed()for the exact matcher round-trip pattern used here.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Signed-off-by: mkornfield <mkornfield@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/config/test_generate.py (1)
70-72: ⚡ Quick winStrengthen the assertion to match the precise validation message.
match="outlines"only checks that the backend value is echoed somewhere in the error, so this test can pass even if the rejection comes from an unrelated validation path. The sibling test at Line 52 already asserts the precise condition message; mirroring it here makes the regression coverage meaningful.♻️ Proposed change
def test_from_params_rejects_incompatible_backend(self) -> None: - with pytest.raises(ValidationError, match="outlines"): + with pytest.raises(ValidationError, match="requires `structured_generation_backend`"): SafeSynthesizerParameters.from_params(**self._generation_kwargs(backend="outlines"))
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f20564a9-1a16-45ac-ad01-7196ec409e92
📒 Files selected for processing (7)
docs/user-guide/configuration.mddocs/user-guide/running.mdsrc/nemo_safe_synthesizer/config/generate.pysrc/nemo_safe_synthesizer/generation/vllm_backend.pytests/config/test_generate.pytests/generation/test_regex_manager.pytests/generation/test_vllm_backend.py
💤 Files with no reviewable changes (1)
- tests/generation/test_regex_manager.py
✅ Files skipped from review due to trivial changes (2)
- docs/user-guide/configuration.md
- docs/user-guide/running.md
🚧 Files skipped from review as they are similar to previous changes (1)
- src/nemo_safe_synthesizer/generation/vllm_backend.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Unit Tests (3.12)
- GitHub Check: Unit Tests (3.13)
- GitHub Check: Unit Tests (3.11)
- GitHub Check: Smoke Tests
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{md,markdown,py}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown,py}: Avoid decorative bold (**text**) in list items, body text, and docstrings; use structural cues (headers, list markers, colons, backticks) for emphasis instead
Use backticks for code identifiers, paths, and CLI commands in markdown and docstrings
Files:
src/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pytests/config/test_generate.py
**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*.py: Use American English spelling: 'initialize' not 'initialise', 'recognize' not 'recognise', 'color' not 'colour'.
Useobservability.get_logger(__name__)for logging, neverlogging.getLogger()orstructlog.get_logger()directly.
Use category loggers:.runtimefor internals,.userfor progress/results,.systemfor system events.
Never useprint()for operational output. Useclick.echo()for CLI output orsys.stdout.write()for raw output in tools.
Useextra={}in logging for structured data that downstream tools should query or aggregate; use f-strings for human-readable context.
Raise from the custom error hierarchy with dual inheritance:SafeSynthesizerError(base),UserError,DataError,ParameterError,GenerationError,InternalError.
UseNSSBaseModelfor config/parameter models inconfig/which define user-facing configuration. Use rawBaseModelor module-specific bases for data transfer objects and internal structures.
UseBaseSettingsfor env/CLI settings. PreferAliasChoiceson individual fields when a field needs to respond to both its Python name and an env var name.
IncludeField(description=...)for Pydantic model fields as the canonical field docstring for API documentation and CLI help text.
Use assignment-styletype = Field(default=..., description="...")as the default for Pydantic model fields because type checkers understanddefault,default_factory, andaliasin assignment style.
UseAnnotatedonly when the field carries additional metadata beyondField()--ValueValidator,AutoParam,DependsOnValidator, reusable constrained type aliases, nested-type constraints, or discriminated unions.
Put defaults as bare assignment (= value), not insideField(default=...), when usingAnnotated. Exception: use assignment-styleField(default_factory=...)for defaults that cannot be expressed as bare assignments.
Use@dataclass(frozen=True)for immutable value objects and validators; mu...
Files:
src/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pytests/config/test_generate.py
src/**/*.py
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
src/**/*.py: Use relative imports insrc/(e.g.,from ..observability import get_logger).
Do not useprint()statements in library code. Useget_logger(__name__)fromobservability.pyorclick.echo()for CLI.
Do not useassertfor validation in library code. Useif/raisefor input validation.assertstatements can be stripped by-Oand must never guard correctness.
Files:
src/nemo_safe_synthesizer/config/generate.py
⚙️ CodeRabbit configuration file
Review library code against STYLE_GUIDE.md. Focus on behavior, API contracts, error handling, resource cleanup, typing, logging, and user-facing failures. Public APIs and nontrivial functions need Google-style docstrings.
Files:
src/nemo_safe_synthesizer/config/generate.py
**/*.{py,sh,yaml,yml}
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
Include SPDX copyright header at the top:
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.and# SPDX-License-Identifier: Apache-2.0. Themake formatcommand handles this automatically.
Files:
src/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pytests/config/test_generate.py
**/*
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*: Include a newline at the end of all files, never trailing whitespace. This is enforced bypre-commit.
Use line length of 120 characters for code, comments, and docstrings (configured inruff.toml).
Files:
src/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pytests/config/test_generate.py
⚙️ CodeRabbit configuration file
**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.
- Refactor suggestion: use for local maintainability problems introduced
by the diff when they have clear future cost, such as duplicated setup,
unclear boundaries, over-mocking, avoidable complexity, or opaque test
helpers.- Nitpick: avoid in chill mode. Do not emit formatting, import-order,
wording, or style-only comments unless automated tools cannot catch the
issue and it affects maintainability.Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.
- Major: incorrect generation/training/evaluation behavior, broken
CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
cleanup and process-isolation bugs likely to fail CI or production
runs.- Minor: localized bugs, missing focused tests for changed behavior, or
bad test patterns that weaken regression coverage.- Trivial: small cleanup with no behavior impact. Usually suppress in
chill mode.- Info: context only. Avoid unless it helps reviewers understand risk.
Safe-Synthesizer-specific review focus: - Data ...
Files:
src/nemo_safe_synthesizer/config/generate.pytests/generation/test_vllm_backend.pytests/config/test_generate.py
src/nemo_safe_synthesizer/config/**/*.py
⚙️ CodeRabbit configuration file
Treat config changes as user-facing API changes. Check Pydantic field descriptions, defaults, validators, aliases, override behavior, CLI help text impact, YAML compatibility, and documented parameter semantics.
Files:
src/nemo_safe_synthesizer/config/generate.py
tests/**
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Tests should mirror the
src/directory structure intests/
Files:
tests/generation/test_vllm_backend.pytests/config/test_generate.py
tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)
Tests in
tests/e2e/should be auto-marked withe2emarker, tests intests/smoke/withsmokemarker, others withunitmarker
tests/**/*.py: Use absolute imports intests/(e.g.,from nemo_safe_synthesizer.observability import get_logger).
Usefixture_prefix convention for fixtures for grep-ability and to separate fixtures from test functions. Add a one-line docstring describing the fixture's purpose and data.
Use function-scoped fixtures by default. Session scope only when empirically justified by test runtime.
Use bareassertas the primary assertion style;pytest.raises()withmatch=for exceptions;pytest.approx()for floating-point comparisons.
Mark CUDA-dependent tests with@pytest.mark.e2e,@pytest.mark.smoke, or@pytest.mark.requires_gpu.
Mock only external boundaries, not internal implementation details.
Ensure test isolation: no shared mutable state or execution-order dependencies between tests. If something must be run first before executing a test, include it in the test or a fixture.
Use@pytest.mark.parametrizefor testing multiple input combinations rather than copy-pasting similar tests.Organize tests using pytest following the structure in
tests/TESTING.mdwith support for unit tests, smoke tests, and end-to-end tests
Files:
tests/generation/test_vllm_backend.pytests/config/test_generate.py
⚙️ CodeRabbit configuration file
Review tests against tests/TESTING.md. Check marker usage, fixture naming, tmp_path usage, determinism, and GPU/vLLM process-isolation requirements. Flag slop tests that only check that code runs, assert result is not None when stronger invariants exist, over-mock internal implementation details, patch around the bug instead of reproducing it, or add broad snapshot/golden churn without a clear contract. Flag change detector tests that fail on harmless refactors, formatting, record ordering, incidental wording, or private implementation details without demonstrating a behavior regression. Prefer existing fixtures or focused new fixtures for repeated setup; keep tests DRY when reasonable without making the behavior under test opaque. print() is allowed in tests.
Files:
tests/generation/test_vllm_backend.pytests/config/test_generate.py
**/*test*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
unit_testmarker is deprecated; useunitinstead
Files:
tests/generation/test_vllm_backend.pytests/config/test_generate.py
🧠 Learnings (1)
📚 Learning: 2026-05-27T22:20:37.354Z
Learnt from: kendrickb-nvidia
Repo: NVIDIA-NeMo/Safe-Synthesizer PR: 520
File: tests/generation/test_vllm_backend.py:556-587
Timestamp: 2026-05-27T22:20:37.354Z
Learning: In NVIDIA-NeMo/Safe-Synthesizer, `tests/conftest.py`’s `pytest_collection_modifyitems` hook applies pytest category markers automatically based on each test file’s path: tests under `/e2e/` get `pytest.mark.e2e`, tests under `/smoke/` get `pytest.mark.smoke`, and all other tests get `pytest.mark.unit`. Therefore, when reviewing pytest tests outside `tests/e2e/` and `tests/smoke/`, do not flag missing explicit `pytest.mark.unit` decorators on test classes/functions as an issue (the hook will add them during collection). If a new test directory/category is introduced, ensure the hook is updated so it’s categorized correctly.
Applied to files:
tests/generation/test_vllm_backend.pytests/config/test_generate.py
🪛 Ruff (0.15.15)
src/nemo_safe_synthesizer/config/generate.py
[warning] 29-38: __all__ is not sorted
Apply an isort-style sorting to __all__
(RUF022)
🔇 Additional comments (8)
tests/config/test_generate.py (2)
4-34: LGTM!
38-68: LGTM!src/nemo_safe_synthesizer/config/generate.py (5)
29-38:__all__sorting issue already flagged.Ruff RUF022 still reports that
__all__is not sorted using isort-style conventions. This was raised in a previous review comment. Runningmake formatshould auto-fix this.
23-26: LGTM!
41-55: LGTM!
199-211: LGTM!
247-255: LGTM!tests/generation/test_vllm_backend.py (1)
100-106: LGTM!
Verify full argument contracts in auto schema-method tests and fix isort-style __all__ ordering in generate config. Signed-off-by: mkornfield <mkornfield@nvidia.com>
kendrickb-nvidia
left a comment
There was a problem hiding this comment.
So the defaults are backend="auto" and method="auto" which will use xgrammar and structural tags, right?
* Also address loading of params tweak * benchmark for methods using pretrained paths # Summary <!-- Brief description of changes --> ## Pre-Review Checklist <!-- These checks should be completed before a PR is reviewed, --> <!-- but you can submit a draft early to indicate that the issue is being worked on. --> Ensure that the following pass: - [x] `make format && make check` or via prek validation. - [x] `make test` passes locally - [x] `make test-e2e` passes locally - [ ] `make test-ci-container` passes locally (recommended) - [ ] GPU CI status check passes -- comment `/sync` on this PR to trigger a run (auto-triggers on ready-for-review) ## Pre-Merge Checklist <!-- These checks need to be completed before a PR is merged, --> <!-- but as PRs often change significantly during review, --> <!-- it's OK for them to be incomplete when review is first requested. --> - [x] New or updated tests for any fix or new behavior - [x] Updated documentation for new features and behaviors, including docstrings for API docs. ## Other Notes <!-- Please add the issue number that should be closed when this PR is merged. --> - Closes #540 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added `"auto"` schema method for structured generation, now the default. Intelligently selects `"structural_tag"` on compatible backends or falls back to `"regex"`. * Added `"structural_tag"` method option for structured generation with XGrammar support. * **Documentation** * Updated configuration reference and guides to reflect new `"auto"` default and additional schema method options. * **Chores** * Added XGrammar dependency (Linux-only) to optional dependencies. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: mkornfield <mkornfield@nvidia.com> Signed-off-by: Sean Yang <seayang@nvidia.com>
Summary
Pre-Review Checklist
Ensure that the following pass:
make format && make checkor via prek validation.make testpasses locallymake test-e2epasses locallymake test-ci-containerpasses locally (recommended)/syncon this PR to trigger a run (auto-triggers on ready-for-review)Pre-Merge Checklist
Other Notes
Summary by CodeRabbit
Release Notes
New Features
"auto"schema method for structured generation, now the default. Intelligently selects"structural_tag"on compatible backends or falls back to"regex"."structural_tag"method option for structured generation with XGrammar support.Documentation
"auto"default and additional schema method options.Chores