Skip to content

fix(server): support partial QKV LoRA adapters in SGLang - #849

Merged
svonava merged 1 commit into
mainfrom
fix/sglang-partial-qkv-lora
Oct 24, 2026
Merged

svonava merged 1 commit into
mainfrom
fix/sglang-partial-qkv-lora

Conversation

@svonava

@svonava svonava commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Selecting a valid query-only, key-only, or value-only LoRA could fail on its first SGLang inference after loading had reported success. The pinned engines assume split attention adapters include query and value projections, leaving partial adapters incompatible with the packed QKV GPU buffers.

Complete absent Q/K/V factors with zeros during adapter loading, using the base attention dimensions for grouped-query attention. Keep supplied factors and native full/fused QKV packing unchanged; reject incomplete factor pairs, mixed fused/split factors, and unsupported partial shapes before inference. The existing opt-in child hook applies this only to the reviewed SGLang versions. CUDA 13 retains its native slot cleanup, and no request path changes.

Validation:

  • 802 SGLang-related CPU tests passed, including all seven nonempty Q/K/V subsets, grouped-query attention, matrix-product parity, malformed factors, and hook isolation.
  • Public Python lint and focused typecheck passed.
  • Exact normalizers from the SHA-verified 0.5.10.post1 and 0.5.20 wheels passed all 56 layer cases per version with the unchanged synthetic GPU-test adapters; CPU matrix delta was zero and full QKV packed tensors matched upstream.
  • Real NVIDIA L4 token-level lifecycle test passed at this exact commit with Qwen3-0.6B and the same two value-only adapters on SGLang 0.5.10.post1. The actual CLI hydrated an absent adapter and an incomplete local adapter from a read-only filesystem cluster cache with Hub fallback disabled, then completed A→B→A selection, single-slot eviction, and reload. All five base projections and the reloaded A projection matched exactly; the frozen tolerance was 1e-6.
  • The bounded run made 12 native requests: eight one-token engine completions, three expected cold-load 503s, and one undeclared-adapter 400. Six completions were successful native text responses; the two A completions produced a whitespace token and the documented empty_model_output terminal. Those remain end-user text errors and were separately counted, with strict prospective parser controls; they demonstrate token-level execution only.
  • Final child-engine logs were retained, all four child processes cleaned, and the owned Modal app stopped with zero containers. Evidence archive SHA-256: 82d24949b65a9ef9f8205825eedca5359399c1f6470d1ee2c0429bd056453b27.

The GPU lifecycle control explicitly disabled radix caching. An earlier pre-LoRA repeat with default radix caching produced a logprob difference and remains a separate failed control; this change makes no default-cache numerical, task-quality, or performance claim. Earlier failed and incomplete runs are retained.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 3490dbe5-2f7c-4841-8acb-c23b147eea0e
Commits

Reviewing files that changed from the base of the PR and between a8d14bb and 922e62a.

Files selected for processing: 3
  • packages/sie_server/src/sie_server/adapters/sglang/_compat/sie_lora_compat.py
  • packages/sie_server/src/sie_server/adapters/sglang/_compat/sitecustomize.py
  • packages/sie_server/tests/adapters/test_sglang_lora_compat.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The compatibility patch completes missing split-QKV LoRA factors for SGLang 0.5.10, 0.5.10.post1, and 0.5.20. It retains GPU-slot cleanup for the first two versions. Tests cover factor packing, validation, patch installation, and deferred imports.

Changes: SGLang LoRA compatibility

Layer / File(s) Summary
Complete partial QKV factors
packages/sie_server/src/sie_server/adapters/sglang/_compat/sie_lora_compat.py, packages/sie_server/tests/adapters/test_sglang_lora_compat.py
The adapter wrapper validates split-QKV factors and attention dimensions, adds zero-valued factors for missing projections, and calls the original normalizer. Tests check packed results, tensor preservation, and validation failures.
Install version-specific patches
packages/sie_server/src/sie_server/adapters/sglang/_compat/sie_lora_compat.py, packages/sie_server/src/sie_server/adapters/sglang/_compat/sitecustomize.py, packages/sie_server/tests/adapters/test_sglang_lora_compat.py
Installation enables adapter normalization for the pinned versions and limits GPU-slot cleanup to SGLang 0.5.10 and 0.5.10.post1. Deferred import handling retries patching and restores the original import function after success or an exception. Tests cover version selection, idempotence, subprocess installation, and the unconfigured environment.

Sequence Diagram(s)

sequenceDiagram
  participant LoRAAdapter
  participant PartialQKVCompletion
  participant OriginalNormalizer
  LoRAAdapter->>PartialQKVCompletion: Validate factors and complete missing projections
  PartialQKVCompletion-->>LoRAAdapter: Return completed weights
  LoRAAdapter->>OriginalNormalizer: Normalize QKV projections
  OriginalNormalizer-->>LoRAAdapter: Return packed factors
Loading

Suggested reviewers: krisztian-gajdar

Priority: Normal

Merge Risk: Minimal · up to 922e6

No concrete issue currently blocks merging; real-GPU qualification remains pending.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding support for partial QKV LoRA adapters in SGLang.
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.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@svonava

svonava commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review this focused load-time compatibility repair, especially partial Q/K/V dimensions for grouped-query attention, preservation of full/fused QKV packing, exact version gating, and child-import hook isolation. CPU validation passed; bounded real L4 qualification is being prepared with the same value-only fixtures that exposed the failure.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@svonava
svonava marked this pull request as ready for review October 24, 2026 20:11
@svonava
svonava requested a review from a team as a code owner October 24, 2026 20:11
@svonava
svonava merged commit 1f686b4 into main Oct 24, 2026
47 checks passed
@svonava
svonava deleted the fix/sglang-partial-qkv-lora branch October 24, 2026 20:28
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