Skip to content

fix(cuda): preserve argv boundaries in compiler shell commands - #22

Open
Afloat16 wants to merge 2 commits into
deepseek-ai:mainfrom
Afloat16:fix/cuda-shell-argv
Open

Afloat16 wants to merge 2 commits into
deepseek-ai:mainfrom
Afloat16:fix/cuda-shell-argv

Conversation

@Afloat16

Copy link
Copy Markdown

Problem

CUDA compiler commands interpolate paths and arguments into shell strings. Spaces, apostrophes and dollar signs can split or alter argv.

Changes

  • Add POSIX shell_quote and shell_join helpers, rejecting embedded NUL.
  • Quote version probes, NVCC, working directories, post-hooks, PTX and cuobjdump commands.
  • Keep generic join and cache-key serialization unchanged. Add a standalone C++ regression test.

Validation

Reran the focused CPU/Linux command-path harness: original 2 passed / 8 failed; patched 10 passed / 0 failed. It compiles the production command-construction header with dependency stubs and runs real /bin/sh against recording executables.

Real CUDA tools, GPU execution and full project CI were not run. Flag entries now retain individual argv boundaries; callers relying on shell expansion need compatibility review.

@Afloat16

Copy link
Copy Markdown
Author

Additional validation: compiled and ran the submitted standalone C++ regression against this PR header using g++ -std=c++20 -I include tests/test_shell_args.cpp -o test-shell-args && ./test-shell-args on Linux. It passed, including real shell argv roundtrips for whitespace, apostrophes, dollar signs, Unicode, newlines and empty arguments, plus embedded-NUL rejection. Real CUDA/GPU validation remains outstanding.

kjlubick added a commit to NVIDIA/Personal-AI-Router that referenced this pull request Nov 16, 2026
<!-- pair-release-intent:v1 -->
### Changelog title
More reliable vLLM setup and model loading across supported devices

### Changelog body
- Install PAIR-managed vLLM outside the space-containing app-data
directory to avoid GPU-kernel compilation failures.
- Size vLLM memory allocations using reliable device readings, including
verified shared-memory systems.

### Bumps
- services: minor
- nvpair-cluster-manager: none
- nvpair-engine-manager: patch
- nvpair-errors: none
- nvpair-job-scheduler: none
- nvpair-manual-nodes: none
- nvpair-node-info: none
- nvpair-node-scanner: none
- nvpair-node-settings: none
- nvpair-proxy: none
- nvpair-tui: none
- nvpair-ui-broker: none
- nvpair-workload-manager: none
<!-- /pair-release-intent:v1 -->

## Description

Fix vLLM model-startup failures caused by paths containing spaces and
unreliable device-memory readings.

Install PAIR-managed vLLM under `~/.nvpair/engine-bin/vllm` instead of
the space-containing app-data directory, and put its virtual-environment
tools on `PATH`. Reset and uninstall remove this managed environment
while preserving downloaded Hugging Face models.

The location change works around upstream compiler-command quoting
problems:
- [FlashInfer
#3515](flashinfer-ai/flashinfer#3515)
documents a related host-compiler path failure.
- [DeepJIT #22](deepseek-ai/DeepJIT#22) proposes
a fix for unquoted compiler arguments and working directories in the
runtime used by DeepGEMM.

The workaround avoids affected installation paths while upstream fixes
work their way into PAIR’s vLLM dependency.

Incorrect memory assumptions can prevent models from starting even when
they fit. Physical RAM can exceed MLX’s usable working set, while FP8
checkpoint files understate the BF16 weights MLX loads. Match the
worker’s memory pool and let MLX measure expanded weights, retaining
startup headroom.

Validate installation paths so managed environments remain safely
removable without touching models. Fingerprint embedded Python files so
probe-only fixes cannot leave the desktop running stale memory logic.

## Validation

- Focused engine-manager tests:
`go test ./... -run
'Test(AutoContext|ApplyAutoLaunch|PlanToolCalling|ParsesToolCalls|DetectDeviceMemory|ParseDeviceMemoryProbe|GPUMemoryFromQuery|PlanHFContext_|PlanMetalKVCache|ValidateMetalModel|ProcessEnvironment|VenvBinDir|StartManagedProc_FindsTools|Validate_.*InstallDirectory|ApplyPlatformDefaults_|UninstallManaged_|BundledVLLMManifest|BundledModelStores_)'
-count=1`
- Cleanup inventory: `npx --no-install vitest run
tests/modular/app-data-wipe.test.ts`
  (`12` tests passed across the configured unit and e2e projects).
- Packaging/static checks: `bash -n` on the three shell cleanup scripts,
`scripts/wipe-app-data.sh --dry-run`, Python AST parsing for the
embedded probe,
Prettier check, `git diff --check`, and `node scripts/spdx-headers.mjs`.
- Cross-builds: `GOOS=darwin GOARCH=arm64 go build .` and
`GOOS=windows GOARCH=amd64 go build .` from
`services/nvpair-engine-manager`.
- DGX Spark, real PAIR install: fresh vLLM install created the
executable and
ownership marker under `~/.nvpair/engine-bin/vllm`. With kernels
enabled,
  `nvidia/Llama-3.1-8B-Instruct-NVFP4` and
`nvidia/Llama-3.1-8B-Instruct-FP8` both reached public/internal health
`200`
  and answered inference requests. Logs contained no `nvcc fatal`,
  `ninja: error`, readiness exit, `NotImplementedError`, or OOM.
- Apple M4, real vLLM-Metal install: reproduced the reported FP8
KV-cache error;
forcing a BF16 KV cache passed that check but then proved the ModelOpt
FP8
weights themselves are unsupported. The final manager rejected the
checkpoint
in about `0.007 s`, with no vLLM child or listening port. The new memory
probe
also reported the machine's `48 GiB` unified memory and current free
memory.

## Checklist

- [x] I have read the [Contributing
Guidelines](https://github.com/NVIDIA/Personal-AI-Router/blob/main/CONTRIBUTING.md).
- [x] Every commit is signed off (`git commit -s`), certifying the
[Developer Certificate of Origin](https://developercertificate.org/).
- [x] New or existing tests cover the change.
- [x] Relevant documentation is updated.
- [x] I checked the diff, changed filenames, and commit messages for
credentials, private data, internal URLs, internal issue identifiers,
and generated artifacts.
- [x] I recorded the validation commands and results above.
- [x] I declared version bumps in the release-intent block above.
`services/versions.json` is written by automation — do not edit it by
hand.

---------

Signed-off-by: nvrithik <[email protected]>
Signed-off-by: Kaylee Lubick <[email protected]>
Co-authored-by: Kaylee Lubick <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant