-
Notifications
You must be signed in to change notification settings - Fork 19
feat(models): generic engine support #476
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
61 changes: 61 additions & 0 deletions
61
services/core/models/src/nmp/core/models/controllers/backends/generic_compiler.py
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,61 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Backend-agnostic compiler for the ``generic`` engine. | ||
|
|
||
| The ``generic`` engine runs an arbitrary container as-is: there is no | ||
| inference-engine compiler synthesizing args or env. The deployment declares a | ||
| container image + tag, a readiness-probe path, and (optionally) raw args and | ||
| environment variables; the platform runs the image and probes it. | ||
|
|
||
| Like :mod:`vllm_compiler`, these functions take a :class:`DeploymentConfigView` | ||
| and return plain data (image tuple, arg vector, env dict). They are NOT specific | ||
| to any service backend: the docker backend renders the result into a | ||
| ``docker run`` container; the k8s backend renders it into a native Kubernetes | ||
| Deployment. Keep this module free of backend-specific imports so both can reuse | ||
| it. | ||
|
|
||
| Unlike the vLLM/NIM engines there is no platform-default image for a generic | ||
| container, so :func:`resolve_generic_image` raises when ``image_name`` is unset. | ||
| The create/update API layer validates this up front; the compiler enforces it | ||
| again as a defensive backstop. | ||
| """ | ||
|
|
||
| from nmp.core.models.controllers.backends.common import DeploymentConfigView | ||
|
|
||
|
|
||
| def resolve_generic_image(view: DeploymentConfigView) -> tuple[str, str]: | ||
| """Resolve the generic container image name and tag. | ||
|
|
||
| There is no platform default for a generic image (it is an arbitrary | ||
| user-supplied container), so ``image_name`` is required. ``image_tag`` | ||
| defaults to ``latest`` when unset, mirroring Docker/Kubernetes conventions. | ||
|
|
||
| Both values are trimmed: the API layer already rejects whitespace-padded | ||
| inputs for generic configs, but this stays robust to any other call path. | ||
| """ | ||
| if not (view.image_name and view.image_name.strip()): | ||
| raise ValueError("The 'generic' engine requires executor_config.image_name to be set (no platform default).") | ||
| image_name = view.image_name.strip() | ||
| image_tag = (view.image_tag or "").strip() or "latest" | ||
| return image_name, image_tag | ||
|
|
||
|
|
||
| def compile_generic_args(view: DeploymentConfigView) -> list[str]: | ||
| """Return the container arg vector for a generic container. | ||
|
|
||
| The platform synthesizes nothing for the generic engine: the user's | ||
| ``additional_args`` are the entire arg vector (appended to the image's own | ||
| entrypoint). Returns an empty list when none are supplied, in which case the | ||
| image's default command/args are used unchanged. | ||
| """ | ||
| return list(view.additional_args or []) | ||
|
|
||
|
|
||
| def compile_generic_env_vars(view: DeploymentConfigView) -> dict[str, str]: | ||
| """Return the environment variables for a generic container. | ||
|
|
||
| Only the user's ``additional_envs`` are applied; the platform injects no | ||
| engine-specific environment for a generic container. | ||
| """ | ||
| return {str(k): str(v) for k, v in (view.additional_envs or {}).items()} |
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
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.