Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/inference/set-up-vllm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ $$nemoclaw onboard
Select **Local vLLM**.
On generic hosts, the entry includes an experimental label; on DGX Spark or DGX Station, it does not.
NemoClaw validates the detected endpoint and records the model reported by `/v1/models`.
When an install request encounters an already-running server, NemoClaw selects that server instead of starting another container.
If the requested registry model and the served `id` differ, NemoClaw accepts the served `id` only when `/v1/models` reports a safe `root` that exactly matches the registry model.
NemoClaw rejects mismatched or unverifiable roots, and it still requires the exact served identity for a newly started NemoClaw-managed container and for an existing shared-gateway route.
When vLLM exposes runtime metadata such as `max_model_len`, NemoClaw uses that value for the configured context window unless you set `NEMOCLAW_CONTEXT_WINDOW`.

Start vLLM with the model you want before onboarding because NemoClaw uses the model already served by the endpoint.
Expand Down Expand Up @@ -78,7 +81,7 @@ Press **Enter** to use the profile default or select another validated model wit
NemoClaw pulls the vLLM image, downloads model weights into `~/.cache/huggingface`, starts the `nemoclaw-vllm` container on `localhost:8000`, streams Hugging Face download progress, and polls `/v1/models` until the model is ready.
The container carries a NemoClaw ownership label so later onboarding runs can distinguish it from a bring-your-own server without trusting the container name alone.
If an existing `nemoclaw-vllm` container does not carry that label, NemoClaw preserves it and asks you to remove or rename it before installing managed vLLM.
If another vLLM server already occupies port `8000`, the managed path stops and asks you to select the existing server or stop it first.
If another vLLM server already occupies port `8000`, NemoClaw selects the existing-server path and applies the model-identity checks described above.
Managed profiles and model-specific recipes use immutable image digests:

- DGX Spark and DGX Station models without a model-specific runtime use the `linux/arm64` digest `sha256:9204569b17ee4c0eff75194b8e6e458479c8aee18953b5ab9cf359fcdac659e2` with a compressed layer size of `9.60 GB` under `nvcr.io/nvidia/vllm:26.05.post1-py3`.
Expand Down
120 changes: 120 additions & 0 deletions src/lib/onboard/machine/handlers/provider-inference.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,126 @@ describe("handleProviderInferenceState", () => {
expect(result).toMatchObject({ provider: "ollama-local", model: "llama3.1" });
});

it("reuses a persisted vLLM served alias when resume repairs inference (#7023)", async () => {
const persistedServedAlias = "my-ultra-served-alias";
const session = createSession({
provider: "vllm-local",
model: persistedServedAlias,
endpointUrl: "http://host.openshell.internal:8000/v1",
credentialEnv: null,
preferredInferenceApi: "openai-completions",
});
session.steps.provider_selection.status = "complete";
const { deps, calls } = createDeps({ isInferenceRouteReady: vi.fn(() => false) });

const result = await handleProviderInferenceState({
...baseOptions(deps, session),
resume: true,
sandboxName: "my-assistant",
});

expect(calls.setupNim).not.toHaveBeenCalled();
expect(calls.setupInference).toHaveBeenCalledWith(
"my-assistant",
persistedServedAlias,
"vllm-local",
"http://host.openshell.internal:8000/v1",
null,
null,
[],
expect.objectContaining({
gatewayName: "nemoclaw",
preferredInferenceApi: "openai-completions",
}),
);
expect(calls.complete).toHaveBeenCalledWith(
"inference",
expect.objectContaining({ provider: "vllm-local", model: persistedServedAlias }),
);
expect(result).toMatchObject({ provider: "vllm-local", model: persistedServedAlias });
});

it("keeps a persisted vLLM served alias across a failed repair and resume retry (#7023)", async () => {
const persistedServedAlias = "my-ultra-served-alias";
const persistedEndpointUrl = "http://host.openshell.internal:8000/v1";
const session = createSession({
provider: "vllm-local",
model: persistedServedAlias,
endpointUrl: persistedEndpointUrl,
credentialEnv: null,
preferredInferenceApi: "openai-completions",
});
session.steps.provider_selection.status = "complete";
const setupInference = vi
.fn<ProviderInferenceStateOptions<Gpu, Agent, Host>["deps"]["setupInference"]>()
.mockRejectedValueOnce(new Error("alias repair failed"))
.mockResolvedValueOnce({ ok: true });
const { deps, calls } = createDeps({
setupInference,
isInferenceRouteReady: vi.fn(() => false),
});
calls.complete.mockResolvedValue(session);
const resumeOptions = {
...baseOptions(deps, session),
resume: true,
sandboxName: "my-assistant",
};

await expect(handleProviderInferenceState(resumeOptions)).rejects.toThrow(
"alias repair failed",
);

expect(calls.setupNim).not.toHaveBeenCalled();
expect(calls.complete).not.toHaveBeenCalledWith("inference", expect.anything());

const result = await handleProviderInferenceState(resumeOptions);

expect(setupInference).toHaveBeenNthCalledWith(
1,
"my-assistant",
persistedServedAlias,
"vllm-local",
persistedEndpointUrl,
null,
null,
[],
expect.objectContaining({
gatewayName: "nemoclaw",
preferredInferenceApi: "openai-completions",
}),
);
expect(setupInference).toHaveBeenNthCalledWith(
2,
"my-assistant",
persistedServedAlias,
"vllm-local",
persistedEndpointUrl,
null,
null,
[],
expect.objectContaining({
gatewayName: "nemoclaw",
preferredInferenceApi: "openai-completions",
}),
);
expect(calls.setupNim).not.toHaveBeenCalled();
expect(calls.complete).toHaveBeenCalledOnce();
expect(calls.complete).toHaveBeenCalledWith(
"inference",
expect.objectContaining({ provider: "vllm-local", model: persistedServedAlias }),
);
expect(result).toMatchObject({
provider: "vllm-local",
model: persistedServedAlias,
endpointUrl: persistedEndpointUrl,
session: {
provider: "vllm-local",
model: persistedServedAlias,
endpointUrl: persistedEndpointUrl,
},
});
});

it("reserves the prompted sandbox route when resume skips already-ready inference (#6562)", async () => {
const session = createSession({
provider: "nvidia-prod",
Expand Down
140 changes: 133 additions & 7 deletions src/lib/onboard/setup-nim-vllm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,105 @@ describe("setupNim vLLM route containment", () => {
expect(events).toEqual(["preflight", "probe", "exact", "validate"]);
});

it("rejects a detected model that differs from the durable shared route before validation", async () => {
it("adopts a served alias when its reported root matches the requested model (#7023)", async () => {
const validate = vi.fn(async () => ({ ok: true, api: "openai-completions" }));
const selection = state("nvidia/nemotron-3-ultra-550b-a55b");
selection.assertRouteCompatible = () => ({
requiredModel: null,
requiredEndpointUrl: null,
requiredInferenceApi: null,
});
const handler = createSetupNimVllmHandler(
deps({
runCapture: () =>
JSON.stringify({
data: [
{
id: "nemotron-ultra",
root: "nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-NVFP4",
},
],
}),
validateOpenAiLikeSelection: validate,
}),
);

await expect(handler(selection)).resolves.toBe("selected");
expect(selection.model).toBe("nemotron-ultra");
expect(validate).toHaveBeenCalledWith(
"Local vLLM",
"http://127.0.0.1:8000/v1",
"nemotron-ultra",
null,
);
expect(console.error).not.toHaveBeenCalled();
});

it("rejects a root-matched served alias during managed install (#7023)", async () => {
const validate = vi.fn(async () => ({ ok: true, api: "openai-completions" }));
const requestedModel = "nvidia/nemotron-3-ultra-550b-a55b";
const selection = state(requestedModel);
selection.assertRouteCompatible = () => ({
requiredModel: null,
requiredEndpointUrl: null,
requiredInferenceApi: null,
});
const handler = createSetupNimVllmHandler(
deps({
runCapture: () =>
JSON.stringify({
data: [
{
id: "nemotron-ultra",
root: "nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-NVFP4",
},
],
}),
validateOpenAiLikeSelection: validate,
}),
);

await expect(handler(selection, { managedInstall: true })).rejects.toThrow("exit 1");
expect(selection.model).toBe(requestedModel);
expect(validate).not.toHaveBeenCalled();
expect(console.error).toHaveBeenCalledWith(
" Detected vLLM model 'nemotron-ultra' does not match the shared gateway route 'nvidia/nemotron-3-ultra-550b-a55b'.",
);
});

it("rejects a served alias when its reported root differs from the requested model", async () => {
const validate = vi.fn(async () => ({ ok: true }));
const selection = state("required/model");
const selection = state("nvidia/nemotron-3-ultra-550b-a55b");
selection.assertRouteCompatible = () => ({
requiredModel: "required/model",
requiredModel: null,
requiredEndpointUrl: null,
requiredInferenceApi: null,
});
const handler = createSetupNimVllmHandler(deps({ validateOpenAiLikeSelection: validate }));
const handler = createSetupNimVllmHandler(
deps({
runCapture: () =>
JSON.stringify({
data: [
{
id: "deepseek",
root: "deepseek-ai/DeepSeek-V4-Flash",
},
],
}),
validateOpenAiLikeSelection: validate,
}),
);

await expect(handler(selection)).rejects.toThrow("exit 1");
expect(validate).not.toHaveBeenCalled();
expect(console.error).toHaveBeenCalledWith(
" Detected vLLM model 'served/model' does not match the shared gateway route 'required/model'.",
" Detected vLLM model 'deepseek' does not match the shared gateway route 'nvidia/nemotron-3-ultra-550b-a55b'.",
);
expect(console.error).toHaveBeenCalledWith(
" To install 'required/model', stop the existing vLLM server on localhost:8000, then rerun the original install/onboard command.",
" To install 'nvidia/nemotron-3-ultra-550b-a55b', stop the existing vLLM server on localhost:8000, then rerun the original install/onboard command.",
);
expect(console.error).toHaveBeenCalledWith(
" To keep 'served/model' instead, start detailed setup:",
" To keep 'deepseek' instead, start detailed setup:",
);
expect(console.error).toHaveBeenCalledWith(
" unset NEMOCLAW_PROVIDER NEMOCLAW_MODEL NEMOCLAW_VLLM_MODEL",
Expand All @@ -104,6 +183,53 @@ describe("setupNim vLLM route containment", () => {
expect(console.error).toHaveBeenCalledWith(" Then select Local vLLM when prompted.");
});

it("rejects a served alias when root metadata is missing (#7023)", async () => {
const validate = vi.fn(async () => ({ ok: true }));
const selection = state("nvidia/nemotron-3-ultra-550b-a55b");
selection.assertRouteCompatible = () => ({
requiredModel: null,
requiredEndpointUrl: null,
requiredInferenceApi: null,
});
const handler = createSetupNimVllmHandler(
deps({
runCapture: () => JSON.stringify({ data: [{ id: "nemotron-ultra" }] }),
validateOpenAiLikeSelection: validate,
}),
);

await expect(handler(selection)).rejects.toThrow("exit 1");
expect(validate).not.toHaveBeenCalled();
expect(console.error).toHaveBeenCalledWith(
" Detected vLLM model 'nemotron-ultra' does not match the shared gateway route 'nvidia/nemotron-3-ultra-550b-a55b'.",
);
});

it("exact-checks an adopted alias against the durable shared route before validation", async () => {
const validate = vi.fn(async () => ({ ok: true }));
const selection = state("required/model");
selection.assertRouteCompatible = vi
.fn()
.mockReturnValueOnce({
requiredModel: null,
requiredEndpointUrl: null,
requiredInferenceApi: null,
})
.mockImplementationOnce(() => {
throw new Error("shared route conflict");
});
const handler = createSetupNimVllmHandler(
deps({
runCapture: () =>
JSON.stringify({ data: [{ id: "served/model", root: "required/model" }] }),
validateOpenAiLikeSelection: validate,
}),
);

await expect(handler(selection)).rejects.toThrow("shared route conflict");
expect(validate).not.toHaveBeenCalled();
});

it("warns on DGX Spark identified via GPU name (firmware-unknown GB10 host)", async () => {
const selection = state(null);
const handler = createSetupNimVllmHandler(
Expand Down
26 changes: 25 additions & 1 deletion src/lib/onboard/setup-nim-vllm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { VLLM_MODELS } from "../inference/vllm-models";
import { cliName } from "./branding";
import type { SetupNimSelectionResult, SetupNimSelectionState } from "./setup-nim-flow";

Expand Down Expand Up @@ -83,6 +84,24 @@ function reportedModelRoot(entry: VllmModelEntry | null): string | null {
return root && SAFE_REPORTED_MODEL_ID_PATTERN.test(root) ? root : null;
}

/** Match an arbitrary served alias to the requested model through vLLM's reported root. */
function reportedModelMatchesRequest(
models: VllmModels,
detectedModel: string,
requestedModel: string,
): boolean {
if (detectedModel === requestedModel) return true;
const root = reportedModelRoot(findVllmModelEntry(models, detectedModel));
if (!root) return false;
const normalizedRequest = requestedModel.toLowerCase();
const registeredModel = VLLM_MODELS.find(
(model) =>
model.id.toLowerCase() === normalizedRequest ||
model.servedModelId?.toLowerCase() === normalizedRequest,
);
return root.toLowerCase() === (registeredModel?.id ?? requestedModel).toLowerCase();
}

/** Read a string property from optional nested vLLM model metadata. */
function readObjectString(value: unknown, key: string): string | null {
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
Expand Down Expand Up @@ -191,7 +210,12 @@ export function createSetupNimVllmHandler(
console.error(" Detected vLLM model ID contains invalid characters.");
deps.exitProcess(1);
}
if (requiredModel && detectedModel !== requiredModel) {
if (
requiredModel &&
detectedModel !== requiredModel &&
(options.managedInstall === true ||
!reportedModelMatchesRequest(models, detectedModel, requiredModel))
) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
console.error(
` Detected vLLM model '${detectedModel}' does not match the shared gateway route '${requiredModel}'.`,
);
Expand Down
Loading
Loading