Skip to content

fix(model-server): preserve aliases in ORJSON responses - #3047

Merged
ananthsub merged 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ananthsub/fix-orjson-response-aliases
Sep 28, 2026
Merged

ananthsub merged 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ananthsub/fix-orjson-response-aliases

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

Summary

  • serialize Pydantic model responses with their declared aliases in the non-streaming ORJSON fast path
  • preserve the text.format.schema wire contract used by structured-output requests
  • add regression coverage using the real NeMoGymResponse schema

Performance

A local in-process benchmark alternated the previous and corrected model_dump calls before orjson.dumps, with 100 warmups and nine repeats. The corrected path was unchanged for a 1.2 KB response (6.560 vs 6.556 microseconds per operation) and 1.77% slower for a synthetic 71.8 KB response (30.669 vs 31.211 microseconds). The change affects key selection during the existing dump and does not add another traversal.

Test plan

  • uv run --extra dev pytest -q tests/unit_tests/test_base_responses_api_model.py
  • scoped pre-commit checks for changed files

Closes #3041.
Parent roadmap: #2998.

@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Sep 4, 2026
@ananthsub
ananthsub force-pushed the ananthsub/fix-orjson-response-aliases branch from 0e56c2a to 03a008f Compare September 4, 2026 19:05
@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 03a008f

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Sep 7, 2026
@ananthsub
ananthsub force-pushed the ananthsub/fix-orjson-response-aliases branch from 03a008f to 2e4dcba Compare September 8, 2026 13:02
@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 2e4dcba

Keep FastAPI-compatible wire names when the non-streaming response fast path serializes Pydantic models.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/fix-orjson-response-aliases branch from 2e4dcba to b6499f5 Compare September 28, 2026 17:37
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

/ok to test b6499f5

@ananthsub
ananthsub added this pull request to the merge queue Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36491624867

Merged via the queue into NVIDIA-NeMo:main with commit 5a529c4 Sep 28, 2026
41 checks passed
@ananthsub
ananthsub deleted the ananthsub/fix-orjson-response-aliases branch September 28, 2026 22:31

This branch was previously deployed

1 inactive deployment
public — b6499f59 Deployed Sep 28, 2026 by copy-pr-bot[bot] via release / finalize / notify #3748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve response aliases in model-server ORJSON dispatch

2 participants