Skip to content

fix(models): point LoRA sidecar to write nmp state to writable scratch volume#798

Merged
albcui merged 1 commit into
mainfrom
albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir
Jul 21, 2026
Merged

fix(models): point LoRA sidecar to write nmp state to writable scratch volume#798
albcui merged 1 commit into
mainfrom
albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir

Conversation

@albcui

@albcui albcui commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

LoRA-enabled deployments never errors with PermissionError because the adapter sidecar runs as uid 2000 (controlled by the pod's securityContext), but the nmp-api image's baked-in HOME=/home/nvs is owned by uid 1000. The sidecar tries to run nemo services run --sidecars adapters, which tries to write its state to $XDG_STATE_HOME (default /home/nvs/.local/state), which uid 2000 doesn't have access to.

The fix is to point $XDG_STATE_HOME to a directory that the sidecar does have access to, which is the locally mounted /scratch.

Summary by CodeRabbit

  • Bug Fixes

    • Improved LoRA adapter sidecar reliability by storing runtime state on writable scratch storage.
    • Prevented failures caused by attempts to write state to an unavailable or read-only location.
  • Tests

    • Added coverage to verify the sidecar uses the writable scratch-backed state directory.

@github-actions github-actions Bot added the fix label Jul 20, 2026
@albcui
albcui force-pushed the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch from 4ab8e1e to 1c6932d Compare July 20, 2026 22:43
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 26391/34046 77.5% 61.7%
Integration Tests 15161/32671 46.4% 18.6%

@albcui albcui closed this Jul 20, 2026
@albcui
albcui force-pushed the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch from 1c6932d to a8b5a72 Compare July 20, 2026 22:44
@albcui albcui reopened this Jul 20, 2026
@albcui
albcui force-pushed the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch from 642f755 to 8f2ab22 Compare July 20, 2026 23:11
@albcui
albcui marked this pull request as ready for review July 20, 2026 23:16
@albcui
albcui requested review from a team as code owners July 20, 2026 23:16
@albcui
albcui requested review from benmccown and soluwalana July 20, 2026 23:16
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The deployments-plugin compiler configures the LoRA adapters sidecar to store service state under /scratch/.nmp-state and adds unit-test coverage for the resulting XDG_STATE_HOME value.

Changes

Writable service state paths

Layer / File(s) Summary
LoRA sidecar state wiring
services/core/models/src/nmp/core/models/controllers/backends/deployments_plugin/compiler.py, services/core/models/tests/unit/controllers/backends/deployments_plugin/test_compiler.py
Defines the scratch-backed state directory, assigns it to the sidecar’s XDG_STATE_HOME, and verifies the /scratch/.nmp-state value in the compiler test.

Possibly related PRs

Suggested reviewers: soluwalana, anubhutivyas, tylersbray

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: redirecting the LoRA sidecar's nmp state to a writable scratch volume.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/services/_process.py`:
- Around line 135-141: Update the warning in the state-directory resolver to
remove the unsupported _NMP_STATE_DIR reference and advise users to set only
XDG_STATE_HOME, while preserving the existing preferred and fallback values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8fa2c9ee-d272-4b54-92f1-69ca35058534

📥 Commits

Reviewing files that changed from the base of the PR and between 84db18d and 8f2ab22.

⛔ Files ignored due to path filters (2)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/services/_process.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_services_process.py is excluded by !sdk/**
📒 Files selected for processing (4)
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/services/_process.py
  • packages/nemo_platform_ext/tests/cli/commands/test_services_process.py
  • services/core/models/src/nmp/core/models/controllers/backends/k8s_nim_operator/reconcilers/k8s.py
  • services/core/models/tests/unit/controllers/test_k8s_nim_operator_backend.py

@albcui
albcui force-pushed the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch 3 times, most recently from 5a2aaf7 to f798f15 Compare July 21, 2026 00:09
@albcui
albcui requested review from anubhutivyas and removed request for benmccown July 21, 2026 16:37
@albcui
albcui force-pushed the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch from f798f15 to fbb164b Compare July 21, 2026 18:46
@albcui
albcui requested a review from tylersbray July 21, 2026 18:47
The adapters sidecar runs the nmp-api image via `nemo services run
--sidecars adapters`, but the pod's securityContext runs it as the vLLM uid
(2000), which does not own that image's baked $HOME (/home/nvs, uid 1000).
`nemo services run` writes per-instance lock/descriptor state under
$XDG_STATE_HOME (default ~/.local/state), so the sidecar hit PermissionError
creating /home/nvs/.local and crash-looped to ERROR, blocking LoRA adapter
inference.

Point the sidecar's XDG_STATE_HOME at the writable scratch volume
(/scratch/.nmp-state), outside the /scratch/loras subtree the adapters
controller GCs. `nemo services run` already honors XDG_STATE_HOME, so no CLI
change is needed.

Re-homed onto the deployments_plugin cutover (#705), which removed the
k8s_nim_operator backend the original fix patched; the redirect now lives in
deployments_plugin/compiler.py::_lora_sidecar and is covered by that
backend's compiler unit test. The XDG_STATE_HOME redirect itself was
validated end-to-end on minikube earlier (a uid-2000 sidecar crash-loops
without it and starts cleanly with it); this commit emits that same env from
the new backend.

Signed-off-by: Albert Cui <albcui@nvidia.com>
@albcui
albcui force-pushed the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch from fbb164b to 98b09e2 Compare July 21, 2026 18:57
@albcui albcui changed the title fix(models): stop LoRA sidecar crash-looping on unwritable state dir fix(models): point LoRA sidecar to write nmp state to writable scratch volume Jul 21, 2026
@albcui
albcui enabled auto-merge July 21, 2026 19:08
@albcui
albcui added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 9f336d5 Jul 21, 2026
61 of 62 checks passed
@albcui
albcui deleted the albcui/nvbugs/fix-lora-sidecar-unwritable-state-dir branch July 21, 2026 19:23
soluwalana pushed a commit that referenced this pull request Jul 22, 2026
…#842)

* fix(models): redirect LoRA sidecar XDG_DATA_HOME to a writable volume

Follow-up to #798, which redirected only $XDG_STATE_HOME. The adapters
sidecar's `nemo services run` also resolves its local data dir (SQLite DB,
encryption key) via nmp_user_data_dir(), which honors $XDG_DATA_HOME
(default ~/.local/share/nemo) -- a distinct XDG home from $XDG_STATE_HOME
(default ~/.local/state). The pod runs the sidecar as the vLLM uid (2000),
which does not own the nmp-api image's baked $HOME (/home/nvs, uid 1000),
so startup still crash-looped with `PermissionError: [Errno 13] Permission
denied: '/home/nvs/.local'` when mkdir'ing ~/.local/share/nemo.

Point both XDG homes at a single writable scratch base (/scratch/.local),
named for the ~/.local these homes normally live under. State lands under
.../nmp/ and data under .../nemo/, so one base holds both without collision,
and it stays outside the /scratch/loras subtree the adapters controller GCs.
Covered by the deployments_plugin compiler unit test.

Signed-off-by: Albert Cui <albcui@nvidia.com>

* Make comments less verbose

Signed-off-by: Albert Cui <albcui@nvidia.com>

---------

Signed-off-by: Albert Cui <albcui@nvidia.com>
Signed-off-by: Sam Oluwalana <soluwalana@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants