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
18 changes: 16 additions & 2 deletions src/lib/inference/vllm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ describe("vLLM profile detection", () => {
const args = buildVllmRunArgs(runtime, ultra!, flags, {} as NodeJS.ProcessEnv);
expect(args).toEqual([
"--pull=never",
"--init",
"--restart",
"unless-stopped",
"--gpus",
Expand Down Expand Up @@ -446,11 +447,18 @@ describe("vLLM image pull", () => {
});

describe("vLLM run command", () => {
it("adds Docker init so restarts can reap the server process (#7219)", () => {
const profile = detectVllmProfile({ platform: "spark", type: "nvidia" });
expect(profile).not.toBeNull();
const args = buildVllmRunArgs(profile!, profile!.defaultModel, profile!.dockerRunFlags);
expect(args.slice(0, 4)).toEqual(["--pull=never", "--init", "--restart", "unless-stopped"]);
});

it("adds --restart unless-stopped so the container survives a host reboot (#4886)", () => {
const profile = detectVllmProfile({ platform: "spark", type: "nvidia" });
expect(profile).not.toBeNull();
const args = buildVllmRunArgs(profile!, profile!.defaultModel, profile!.dockerRunFlags);
expect(args.slice(0, 3)).toEqual(["--pull=never", "--restart", "unless-stopped"]);
expect(args).toEqual(expect.arrayContaining(["--restart", "unless-stopped"]));
expect(args).toContain("--name");
expect(args[args.indexOf("--name") + 1]).toBe(profile!.containerName);
expect(args).toEqual(
Expand Down Expand Up @@ -997,7 +1005,13 @@ describe("installVllm model resolution", () => {
{ env?: Record<string, string> },
];
expect(args).toEqual(
expect.arrayContaining(["--pull=never", "--restart", "unless-stopped", profile.image]),
expect.arrayContaining([
"--pull=never",
"--init",
"--restart",
"unless-stopped",
profile.image,
]),
);
expect(args).not.toContain("HF_TOKEN");
expect(args.join(" ")).not.toContain("hf_test");
Expand Down
10 changes: 6 additions & 4 deletions src/lib/inference/vllm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,11 @@ function validateDockerArgs(args: readonly string[], label: string): string[] {
}

// Build the `docker run` argv for the long-lived vLLM inference container.
// Exported for testing. `--restart unless-stopped` makes the container come
// back after a host reboot or Docker daemon restart (#4886); without a restart
// policy the container stays down after a reboot and `nemoclaw inference get`
// fails until a full `nemoclaw onboard --fresh --gpu` recreates it.
// Exported for testing. `--init` forwards signals and reaps child processes so
// Docker can stop and restart the long-lived server cleanly. `--restart
// unless-stopped` brings it back after a host reboot or Docker daemon restart
// (#4886); without a restart policy the container stays down after a reboot and
// `nemoclaw inference get` fails until onboarding recreates it.
export function buildVllmRunArgs(
profile: VllmProfile,
model: VllmModelDef,
Expand All @@ -513,6 +514,7 @@ export function buildVllmRunArgs(
const safeRunFlags = validateDockerArgs(runFlags, "vLLM docker run flags");
return [
"--pull=never",
"--init",
"--restart",
"unless-stopped",
...safeRunFlags,
Expand Down
Loading