Skip to content

fix: restore runtime LoRA tensor counts - #2400

Merged
leejet merged 2 commits into
masterfrom
fix/dgl-runtime-lora-counts
Nov 22, 2026
Merged

leejet merged 2 commits into
masterfrom
fix/dgl-runtime-lora-counts

Conversation

@leejet

@leejet leejet commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Restore runtime LoRA tensor counts in DGL. Log the applied count by model component and adapter file after execution, and warn when incompatible tensors are skipped.
  • Reset the counters after reporting so each sampling run produces one summary per adapter.

Related Issue / Discussion

N/A

Additional Information

N/A

Checklist

Summary by CodeRabbit

  • Improvements
    • Automatic LoRA mode now applies unquantized weights immediately when using the compute backend without row splitting, and applies LoRA at runtime for quantized, offloaded, or row-split weights.
    • LoRA adapter reports show clearer counts of applied and incompatible tensors, with optional component labels.
    • Runtime reporting captures adapter statistics when tensors were applied or skipped as incompatible.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Automatic LoRA mode selection now uses row-split status, backend placement, and tensor metadata. Model integrations and documentation use the resolved selection rules. LoRA execution also updates statistics reporting and tracking cleanup.

Changes: LoRA Mode and Execution

Layer / File(s) Summary
Mode resolution and model integration
src/dgl/models/lora.h, src/dgl/models/lora.cpp, src/dgl/models/model_runtime.cpp, src/dgl/models/model_base.h, src/dgl/models/model_base.cpp, src/dgl/model_value.cpp, src/dgl/models/detail_detector.cpp, src/dgl/models/upscaler.cpp, docs/dgl.md, docs/models/lora.md, examples/common/common.cpp
Automatic mode selection now considers row splitting, backend placement, and tensor quantization metadata. Runtime model setup, detector and upscaler integrations, and the related documentation use the resolved mode rules.
Statistics reporting
src/model/adapter/lora.hpp
LoraModel::stat accepts an optional component label and reports compatible and incompatible tensor counts. Unused-tensor and incomplete-application warnings remain limited to non-runtime calls.
Execution lifecycle
src/dgl/models/lora.h, src/dgl/models/lora.cpp
prepare stores the backend module. At execution end, the code records statistics and clears applied and skipped-incompatible tensor tracking when an adapter exists and either list is nonempty, then ends each model runner.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ModelRuntime
  participant ModelLoader
  participant SDBackendManager
  participant resolve_lora_mode
  ModelRuntime->>ModelLoader: inspect stored tensor metadata
  ModelRuntime->>SDBackendManager: inspect backend placement
  ModelRuntime->>resolve_lora_mode: provide mode and row-split status
  resolve_lora_mode-->>ModelRuntime: return resolved mode
Loading

Suggested reviewers: wbruna

Merge Risk: Minimal · up to 4cba5

This change unifies automatic LoRA mode selection, updates the documentation to match, and adds per-component LoRA tensor count reporting. No concrete merge-blocking issue was found. Normal build and runtime checks are still advisable.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix: restore runtime LoRA tensor counts" names the main change. The raw summary and PR description both show the change restores runtime LoRA tensor count logging by model component and ada…
Description check Passed The description follows the repository template. It includes Summary, Related Issue / Discussion, Additional Information, and Checklist sections. The Summary explains the change: runtime LoRA tensor c…
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.
Full details: Title check

Explanation

The title "fix: restore runtime LoRA tensor counts" names the main change. The raw summary and PR description both show the change restores runtime LoRA tensor count logging by model component and adapter, with warnings for skipped incompatible tensors and counter reset after reporting. The title is specific and concise. The summary also covers a mode-resolution refactor (resolve_lora_mode, auto mode selection) from the commit message, which the title does not mention. That gap is partial, not a mismatch.

Full details: Description check

Explanation

The description follows the repository template. It includes Summary, Related Issue / Discussion, Additional Information, and Checklist sections. The Summary explains the change: runtime LoRA tensor count logging per component and adapter, incompatible-tensor warnings, and counter reset after each run. Related Issue is marked N/A, and Additional Information is marked N/A. Both checklist items are checked. The description does not mention the auto-mode resolution refactor, the documentation updates for auto mode, or the removal of the persistent argument. These omissions are non-critical for the pass decision but reduce reviewer context.

Resolution

Optionally add a note to the Summary that describes the auto LoRA mode unification (resolve_lora_mode) and the related documentation changes, because the diff changes user-facing auto-mode behavior.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

src/dgl/models/model_runtime.cpp

Cppcheck interrupted; analysis of this file is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7a424ebb-f293-432c-9358-6ecdfa2bdfcf
Commits

Reviewing files that changed from the base of the PR and between 7001abe and 4cba5db.

Files selected for processing: 11

  • docs/dgl.md
  • docs/models/lora.md
  • examples/common/common.cpp
  • src/dgl/model_value.cpp
  • src/dgl/models/detail_detector.cpp
  • src/dgl/models/lora.cpp
  • src/dgl/models/lora.h
  • src/dgl/models/model_base.cpp
  • src/dgl/models/model_base.h
  • src/dgl/models/model_runtime.cpp
  • src/dgl/models/upscaler.cpp

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

@leejet
leejet merged commit 0d71f96 into master Nov 22, 2026
10 checks passed
@leejet
leejet deleted the fix/dgl-runtime-lora-counts branch November 22, 2026 18:44
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