-
Notifications
You must be signed in to change notification settings - Fork 322
[NMCUR-421] Add inference-server PDF benchmark path #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
praateekmahajan
merged 24 commits into
NVIDIA-NeMo:main
from
praateekmahajan:inference-server-pdf-nmcur-421
Sep 9, 2026
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e2595e7
feat(benchmarking): add PDF inference server benchmark
praateekmahajan 865a453
refactor(pdf): let composite configure inference
praateekmahajan 78b1c1f
feat(pdf): batch inference server requests
praateekmahajan 2fc0903
perf(pdf): saturate inference servers
praateekmahajan 54750bb
fix(benchmarking): use Dynamo TCP request plane
praateekmahajan 0d34007
perf(benchmarking): report inference stage throughput
praateekmahajan 71c5cb6
refactor(benchmarking): configure PDF client workers
praateekmahajan fbe0d60
refactor(benchmarking): trim PDF server matrix
praateekmahajan eec5d23
refactor(benchmarking): share inference JSON parsing
praateekmahajan cdd75c7
refactor(pdf): configure inference workers directly
praateekmahajan 0dc086b
refactor(pdf): name inference caller as HTTP client
praateekmahajan 12bccbd
refactor(pdf): simplify inference server paths
praateekmahajan a109f8a
docs(pdf): recommend Dynamo inference serving
praateekmahajan 9ab8302
docs(inference): clarify default Dynamo routing
praateekmahajan b901d27
Merge remote-tracking branch 'upstream/main' into inference-server-pd…
praateekmahajan 4fc7724
fix(pdf): align inference execution paths
praateekmahajan 2680ae8
test(benchmarking): drop PDF config assertions
praateekmahajan 8ce10ac
Merge remote-tracking branch 'upstream/main' into inference-server-pd…
praateekmahajan 096db7b
fix(pdf): address inference server review feedback
praateekmahajan 009d3a0
chore(ci): refresh secrets baseline
praateekmahajan cba1db8
Merge remote-tracking branch 'upstream/main' into inference-server-pd…
praateekmahajan e1554a7
fix(pdf): separate served and in-process CLIs
praateekmahajan 1c184e8
fix(pdf): keep tutorial execution streaming
praateekmahajan 4d22af6
docs(benchmarking): preserve inference server context
praateekmahajan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # ruff: noqa: PLR0913 | ||
|
|
||
| """Shared helpers for inference servers used by benchmark scripts.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from typing import TYPE_CHECKING, Any, Literal | ||
|
|
||
| if TYPE_CHECKING: | ||
| from nemo_curator.core.serve import InferenceServer | ||
|
|
||
| InferenceServerBackend = Literal["ray-serve", "dynamo"] | ||
|
|
||
|
|
||
| def parse_json_object(value: str | None, *, argument: str) -> dict[str, Any]: | ||
| """Parse an optional command-line JSON object.""" | ||
| if value is None: | ||
| return {} | ||
| try: | ||
| parsed = json.loads(value) | ||
| except json.JSONDecodeError as error: | ||
| msg = f"{argument} must be valid JSON: {error}" | ||
| raise ValueError(msg) from error | ||
| if not isinstance(parsed, dict): | ||
| msg = f"{argument} must decode to a JSON object" | ||
| raise TypeError(msg) | ||
| return parsed | ||
|
|
||
|
|
||
| def static_num_replicas(autoscaling_config: dict[str, Any] | None) -> int: | ||
| """Resolve a fixed replica count from a Ray-style autoscaling config.""" | ||
| if not autoscaling_config: | ||
| return 1 | ||
| min_replicas = int(autoscaling_config.get("min_replicas", 1)) | ||
| max_replicas = int(autoscaling_config.get("max_replicas", min_replicas)) | ||
| if min_replicas != max_replicas: | ||
| msg = ( | ||
| "Dynamo does not support autoscaling in benchmarks; " | ||
| f"min_replicas ({min_replicas}) must equal max_replicas ({max_replicas})." | ||
| ) | ||
| raise ValueError(msg) | ||
| if min_replicas < 1: | ||
| msg = f"num_replicas must be at least 1, got {min_replicas}" | ||
| raise ValueError(msg) | ||
| return min_replicas | ||
|
|
||
|
|
||
| def start_inference_server( | ||
| *, | ||
| backend: InferenceServerBackend, | ||
| model_id: str, | ||
| num_replicas: int, | ||
| engine_kwargs: dict[str, Any] | None = None, | ||
| model_path: str | None = None, | ||
| model_runtime_env: dict[str, Any] | None = None, | ||
| dynamo_kwargs: dict[str, Any] | None = None, | ||
| dynamo_router_kwargs: dict[str, Any] | None = None, | ||
| dynamo_subprocess_env: dict[str, str] | None = None, | ||
| ray_serve_deployment_config: dict[str, Any] | None = None, | ||
| health_check_timeout_s: int = 900, | ||
| ) -> InferenceServer: | ||
| """Build, start, and return an inference server. | ||
|
|
||
| If ``model_path`` is set, the server loads weights from that local path | ||
| while exposing ``model_id`` as the served model name. | ||
|
|
||
| ``model_runtime_env`` is passed to Ray Serve replicas or Dynamo workers. | ||
| For gpt-oss, set ``TIKTOKEN_RS_CACHE_DIR`` there to read the Harmony | ||
| encoding from a pre-populated local cache instead of downloading it from | ||
| Azure at startup (see https://github.com/openai/harmony/issues/101). | ||
|
|
||
| ``health_check_timeout_s`` controls how long server startup waits for the | ||
| model to register at ``/v1/models``. | ||
| """ | ||
| from nemo_curator.core.serve import InferenceServer | ||
|
|
||
| if num_replicas < 1: | ||
| msg = f"num_replicas must be at least 1, got {num_replicas}" | ||
| raise ValueError(msg) | ||
| if backend == "dynamo": | ||
| from nemo_curator.core.serve import DynamoRouterConfig, DynamoServerConfig, DynamoVLLMModelConfig | ||
|
|
||
| model = DynamoVLLMModelConfig( | ||
| model_identifier=model_path or model_id, | ||
| model_name=model_id if model_path else None, | ||
| engine_kwargs=engine_kwargs or {}, | ||
| num_replicas=num_replicas, | ||
| dynamo_kwargs=dynamo_kwargs or {}, | ||
| runtime_env=model_runtime_env or {}, | ||
| ) | ||
| server = InferenceServer( | ||
| models=[model], | ||
| backend=DynamoServerConfig( | ||
| request_plane="tcp", | ||
| router=DynamoRouterConfig(router_kwargs=dynamo_router_kwargs or {}), | ||
| subprocess_env=dynamo_subprocess_env or {}, | ||
| ), | ||
| health_check_timeout_s=health_check_timeout_s, | ||
| ) | ||
| else: | ||
| if backend != "ray-serve": | ||
| msg = f"Unsupported inference server backend: {backend}" | ||
| raise ValueError(msg) | ||
|
|
||
| from nemo_curator.core.serve import RayServeModelConfig | ||
|
|
||
| model = RayServeModelConfig( | ||
| model_identifier=model_path or model_id, | ||
| model_name=model_id if model_path else None, | ||
| deployment_config=( | ||
| ray_serve_deployment_config | ||
| if ray_serve_deployment_config is not None | ||
| else {"num_replicas": num_replicas} | ||
| ), | ||
| engine_kwargs=engine_kwargs or {}, | ||
| runtime_env=model_runtime_env or {}, | ||
| ) | ||
| server = InferenceServer(models=[model], health_check_timeout_s=health_check_timeout_s) | ||
|
|
||
| server.start() | ||
| return server |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.