LinearOperators.jl icon indicating copy to clipboard operation
LinearOperators.jl copied to clipboard

Inefficient implementation of LBFGS multiply

Open MaxenceGollier opened this issue 3 months ago • 1 comments

https://github.com/JuliaSmoothOptimizers/LinearOperators.jl/blob/4575ca56d78d1cd21a080280af54540c384b3add/src/lbfgs.jl#L195-L197

This is highly inefficient. There are too many memory accesses being performed. We should replace with

@. q += bx .* data.b[k] - ax .* data.a[k]

In the same function there is also

https://github.com/JuliaSmoothOptimizers/LinearOperators.jl/blob/4575ca56d78d1cd21a080280af54540c384b3add/src/lbfgs.jl#L190

which should be improved with the @inbounds macro.

@dpo I am already getting huge improvements just with this (regarding the discussion we had this morning on Zulip).

MaxenceGollier avatar Oct 03 '25 15:10 MaxenceGollier

Thanks. That code was probably written before the dot notation existed.

dpo avatar Oct 03 '25 15:10 dpo