Skip to content

Add GPU support for LBFGSData - #426

Open
blegat wants to merge 2 commits into
JuliaSmoothOptimizers:mainfrom
blegat:gpu
Open

blegat wants to merge 2 commits into
JuliaSmoothOptimizers:mainfrom
blegat:gpu

Conversation

@blegat

@blegat blegat commented Aug 7, 2026

Copy link
Copy Markdown
  • Add tests

Copilot AI 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.

🟡 Changes recommended

GPU shifted solves and diagonal extraction still mix CPU and GPU storage, and the new paths lack tests.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds configurable vector storage to LBFGSData/LBFGSOperator for GPU backends and updates shifted-system dispatch.

Changes:

  • Adds V storage parameter and GPU-aware constructors.
  • Generalizes LBFGS operations and shifted-system methods.
  • No GPU tests were added.
File summaries
File Description
src/lbfgs.jl Adds configurable storage backend support.
src/utilities.jl Updates shifted-system method dispatch.
Review details

Suppressed comments (2)

src/lbfgs.jl:61

  • Selecting a GPU V only moves Ax and the history vectors to the device; the shifted-system scratch buffers constructed immediately below remain Matrix{T}/Vector{T} on the CPU. Consequently solve_shifted_system!(..., B, b, σ) with CuVector inputs mixes CPU views with GPU b (and copies from GPU into shifted_u), so the new generic method fails with scalar indexing disabled instead of solving. Allocate these temporaries on the same backend, or otherwise implement a device-compatible shifted solve, before advertising GPU support.
    V(undef, n),

src/lbfgs.jl:119

  • Changing storage_type to V makes GPU operators advertise GPU storage, but diag(op) still allocates Vector{T} later in this file. After any update, diag! combines that CPU destination with data.a/data.b GPU arrays, which is incompatible with CUDA.allowscalar(false) and does not provide a usable GPU diagonal. Make diag allocate from the operator's storage backend (or require a backend-provided output) and cover this path.
storage_type(op::LBFGSOperator{T, I, F, Ft, Fct, V}) where {T, I, F, Ft, Fct, V} = V
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lbfgs.jl
Comment on lines +34 to +35
::Type{T},
::Type{V},

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Should be covered now

@blegat
blegat marked this pull request as ready for review September 19, 2026 08:40
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.

2 participants