Skip to content

fix(vulkan): keep CPU-offloaded weights in pageable RAM - #2450

Merged
leejet merged 1 commit into
masterfrom
fix/vulkan-pageable-offload-weights
Nov 28, 2026
Merged

leejet merged 1 commit into
masterfrom
fix/vulkan-pageable-offload-weights

Conversation

@leejet

@leejet leejet commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Store CPU-offloaded Vulkan source weights in pageable RAM and stage them to the GPU as needed.
  • Prevent retained Vulkan_Host weight buffers from exhausting the AMDGPU GTT pool during segmented execution. Document the Vulkan offload behavior.

Related Issue / Discussion

Fix #2334.
Fix #2439.
Fix #2015.

Additional Information

N/A

Checklist

Summary by CodeRabbit

  • Performance
    • Vulkan now stores CPU-offloaded model weights in pageable system memory, keeping driver host-buffer capacity available for transfers.
  • Documentation
    • Updated the performance guide to describe how Vulkan handles CPU-offloaded weights and host-buffer capacity.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When the compute backend is Vulkan and the params backend is CPU, buffer selection skips the compute device’s host buffer type. The performance guide states that Vulkan CPU-offloaded weights use pageable system RAM.

Changes: Vulkan CPU-offload buffer selection

Layer / File(s) Summary
CPU params buffer selection
src/model_manager.cpp, docs/guides/performance.md
The Vulkan CPU-params branch skips the compute device’s host buffer type and uses the params backend’s default buffer type when no type is selected. The guide states that CPU-offloaded weights use pageable system RAM.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: losewayy

Merge Risk: Minimal · up to d938b

This change keeps CPU-offloaded Vulkan weights in pageable system RAM instead of driver host buffers, which should reduce GPU-visible memory pressure during segmented runs. No concrete defect was found. The change is small and easy to revert.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Objectives: [#2334, #2439] Address the Vulkan segmented DiT weight-preparation failure so the segmented run completes. The reviewed change (per the AI summary, src/model_manager.cpp, +3/-1) stops `par… Provide readable source evidence for the full params_buffer_type_for change in src/model_manager.cpp (the hunk and the default buffer type fallback), and state whether the change affects device-side allocation count or budget for #2439. P…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "fix(vulkan): keep CPU-offloaded weights in pageable RAM" matches the main change. The PR stores CPU-offloaded Vulkan source weights in pageable RAM, and the code change stops selecting the …
Out of Scope Changes check Passed The reviewed changes are a narrow buffer-type selection change in src/model_manager.cpp for Vulkan compute with CPU params (+3/-1 lines, per the AI summary) and a two-line note in docs/guides/performa…
Description check Passed The description fills every section of the repository template: Summary, Related Issue / Discussion, Additional Information, and Checklist. The Summary states the change (Vulkan CPU-offloaded source w…
Full details: Title check

Explanation

The title "fix(vulkan): keep CPU-offloaded weights in pageable RAM" matches the main change. The PR stores CPU-offloaded Vulkan source weights in pageable RAM, and the code change stops selecting the compute device's host buffer type for Vulkan compute with CPU params. The title is concise, specific, and follows a conventional commit style.

Full details: Out of Scope Changes check

Explanation

The reviewed changes are a narrow buffer-type selection change in src/model_manager.cpp for Vulkan compute with CPU params (+3/-1 lines, per the AI summary) and a two-line note in docs/guides/performance.md on Vulkan CPU-offloaded weights in pageable RAM. Both changes relate directly to the Vulkan weight-staging behavior described by #2334 and #2439. Other compute backends keep their existing host-buffer selection, so the change does not alter unrelated backends. The full diff hunks could not be read, so this assessment relies on the summary for the exact scope.

Full details: Description check

Explanation

The description fills every section of the repository template: Summary, Related Issue / Discussion, Additional Information, and Checklist. The Summary states the change (Vulkan CPU-offloaded source weights moved to pageable RAM and staged to the GPU as needed) and the reason (avoiding GTT pool exhaustion during segmented execution). Related issues #2334, #2439, and #2015 are linked. Both checklist items are ticked. The description does not include verification or test results, but the template only asks for these under Additional Information, where the author wrote N/A. The description is complete enough to pass.

Full details: Linked Issues check

Explanation

Objectives: [#2334, #2439] Address the Vulkan segmented DiT weight-preparation failure so the segmented run completes. The reviewed change (per the AI summary, src/model_manager.cpp, +3/-1) stops params_buffer_type_for from selecting the compute device host buffer type when compute is Vulkan and params are CPU. This targets the pinned Vulkan_Host allocation failure reported in #2334, and the PR description states this intent. The code could not be read: the diff and file reads were truncated or unavailable, so the exact hunk and fallback behavior were not verified. No test or validation result is included. For #2439, the reported failure is a device-memory budget shortfall (need 950.26 MB device / 481.41 MB budget) and RADV allocation or command-submission limits. The summary does not show that this change addresses device-side allocation or budget behavior, so this objective is not established. The runtime effect on either issue cannot be determined from static evidence.

Resolution

Provide readable source evidence for the full params_buffer_type_for change in src/model_manager.cpp (the hunk and the default buffer type fallback), and state whether the change affects device-side allocation count or budget for #2439. Provide validation evidence, such as a segmented MiniMax-H3 run on Vulkan that passes segment 37/54 and segment 42/54, or an automated test covering the Vulkan CPU-params buffer selection.

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

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: f0971db9-e9ba-4f6e-8bd5-e6b1d3005f2b
Commits

Reviewing files that changed from the base of the PR and between 3b0426f and d938bc9.

Files selected for processing: 2

  • docs/guides/performance.md
  • src/model_manager.cpp

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

@leejet
leejet merged commit 58d1126 into master Nov 28, 2026
11 checks passed
@leejet
leejet deleted the fix/vulkan-pageable-offload-weights branch November 28, 2026 14:00
danielhanchen added a commit to unslothai/stable-diffusion.cpp that referenced this pull request Nov 28, 2026
…#106)

Cherry-picked from upstream leejet/stable-diffusion.cpp PR leejet#2450
(MIT). Only the Vulkan guard is taken; the fork's params_buffer_type_for
condition is otherwise unchanged.

(cherry picked from commit 58d1126)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment