Skip to content

fix: allow relaxing numeric ranges for highly numeric datasets#661

Open
mckornfield wants to merge 2 commits into
mainfrom
allow-numeric-range-relax/mck
Open

fix: allow relaxing numeric ranges for highly numeric datasets#661
mckornfield wants to merge 2 commits into
mainfrom
allow-numeric-range-relax/mck

Conversation

@mckornfield

@mckornfield mckornfield commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Pre-Review Checklist

Ensure that the following pass:

  • mise run format && mise run check or via prek validation.
  • mise run test passes locally
  • mise run test:e2e passes locally
  • mise run 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

  • New or updated tests for any fix or new behavior
  • Updated documentation for new features and behaviors, including docstrings for API docs.

Other Notes

  • Closes #

Summary by CodeRabbit

  • New Features
    • Added a configuration option to enable or disable validation of generated floating-point values against observed numeric ranges (enabled by default).
    • When disabled, floating-point bounds are relaxed while integer limits and enum constraints remain enforced.
    • Numeric bound relaxation is applied consistently during generation schema handling, including nullable numeric fields.
  • Tests
    • Added unit tests covering float bound stripping, preservation of integer/enum constraints, nullable behavior, input-schema immutability, and end-to-end schema integration.

Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9cf487f2-e566-4536-beaa-f22f70c63235

📥 Commits

Reviewing files that changed from the base of the PR and between b7f1eea and ed00eae.

📒 Files selected for processing (1)
  • src/nemo_safe_synthesizer/config/generate.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/nemo_safe_synthesizer/config/generate.py
📜 Recent review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: Unit Tests (3.13)
  • GitHub Check: Unit Tests (3.11)
  • GitHub Check: Unit Tests (3.12)
  • GitHub Check: End-user Wheel Install
  • GitHub Check: Smoke Tests
  • GitHub Check: Greptile Review
  • GitHub Check: Typecheck
  • GitHub Check: Analyze (Python)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (python)

Walkthrough

Adds configurable floating-point range enforcement. Disabled enforcement removes numeric bounds from generation schemas while retaining integer and enum constraints, with tests covering nullable types, immutability, and schemas generated from data.

Changes

Numeric range enforcement

Layer / File(s) Summary
Schema relaxation and backend integration
src/nemo_safe_synthesizer/config/generate.py, src/nemo_safe_synthesizer/data_processing/dataset.py, src/nemo_safe_synthesizer/generation/vllm_backend.py
Adds the enforce_numeric_range setting, removes bounds from pure number properties, and applies the transformation during VLLM backend initialization when disabled.
Numeric range transformation tests
tests/data_processing/test_dataset.py
Covers float and nullable-float bound removal, preservation of integer and enum constraints, input immutability, and integration with generated schemas.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: bug, test

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making numeric range validation relaxable for highly numeric datasets.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch allow-numeric-range-relax/mck

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added feature New feature or request test Test-only addition or change labels Jul 17, 2026
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new enforce_numeric_range flag (ValidationParameters) that, when set to False, strips observed minimum/maximum bounds from float-typed properties in the generation schema before validation runs. The new relax_numeric_bounds helper in dataset.py does the stripping, and vllm_backend.py applies it at initialisation time so the relaxed schema is consistently used for both structured-generation constraints and post-generation record validation.

  • New config flag (enforce_numeric_range, default True) added to ValidationParameters in generate.py; existing behaviour is preserved by default.
  • relax_numeric_bounds in dataset.py produces a deep-ish copy of the schema with minimum/maximum removed from pure number properties; integer and enum constraints are left untouched.
  • VllmBackend.__init__ applies the relaxation immediately after loading the schema file so the same object is used everywhere downstream (processor, structured-generation params).

Confidence Score: 5/5

Safe to merge. The change is additive and opt-in (default keeps existing strict behaviour), the schema relaxation is isolated to a single well-tested helper, and the relaxed schema is applied consistently to all downstream consumers in VllmBackend.

All changed code paths are straightforward and additive. The new enforce_numeric_range flag defaults to True, so no existing behaviour changes without an explicit opt-in. The relax_numeric_bounds helper is pure (no side effects on its input), its logic correctly handles string types, nullable type arrays, integer bounds, and enum constraints, and the test suite covers all four of those cases including an end-to-end round-trip with make_json_schema.

No files require special attention.

Important Files Changed

Filename Overview
src/nemo_safe_synthesizer/config/generate.py Adds enforce_numeric_range: bool = True to ValidationParameters; follows existing field patterns exactly and preserves backward compatibility.
src/nemo_safe_synthesizer/data_processing/dataset.py Adds relax_numeric_bounds helper; correctly handles string types, type lists (nullable), integer bounds, and does not mutate the input.
src/nemo_safe_synthesizer/generation/vllm_backend.py Applies relax_numeric_bounds immediately after schema load so the relaxed schema propagates uniformly to the processor and structured-generation parameters.
tests/data_processing/test_dataset.py New test file covering float bounds removal, integer/enum preservation, nullable type lists, immutability, and round-trip with make_json_schema.

Reviews (2): Last reviewed commit: "docs: shorten enforce_numeric_range Fiel..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/nemo_safe_synthesizer/data_processing/dataset.py 93.33% 1 Missing ⚠️
...c/nemo_safe_synthesizer/generation/vllm_backend.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
@coderabbitai coderabbitai Bot added bug Defects in shipped behavior and removed feature New feature or request labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:config area:data-processing area:generation area:tests bug Defects in shipped behavior test Test-only addition or change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant