Skip to content

Conversation

@DanielVandH
Copy link
Collaborator

@DanielVandH DanielVandH commented Nov 12, 2025

WIP for what we were discussing @dlfivefifty. WIP because I need to fix this new StackOverflow

using SemiclassicalOrthogonalPolynomials
P = SemiclassicalJacobi(2, 0.1, 0.2, 0.3)
B = diff(P).args[2]
n = 100
julia> B'.data[:, 1:1]
Warning: detected a stack overflow; program state may be corrupted, so further execution might be unreliable.
ERROR: StackOverflowError:
Stacktrace:
  [1] layout_broadcasted
    @ c:\Users\djv23\.julia\dev\LazyArrays.jl\src\lazybroadcasting.jl:9 [inlined]
  [2] layout_broadcasted
    @ c:\Users\djv23\.julia\dev\LazyArrays.jl\src\lazybroadcasting.jl:10 [inlined]
  [3] broadcasted
    @ c:\Users\djv23\.julia\dev\LazyArrays.jl\src\lazybroadcasting.jl:13 [inlined]
  [4] broadcasted
    @ .\broadcast.jl:1353 [inlined]
  [5] resize_bcargs!
    @ c:\Users\djv23\.julia\dev\LazyArrays.jl\src\cache.jl:399 [inlined]
  [6] copyto!(dest::SubArray{…}, bc::Base.Broadcast.Broadcasted{…})
    @ LazyArrays c:\Users\djv23\.julia\dev\LazyArrays.jl\src\cache.jl:421
  [7] copyto!(dest::SubArray{…}, bc::Base.Broadcast.Broadcasted{…}) (repeats 47525 times)
    @ LazyArrays c:\Users\djv23\.julia\dev\LazyArrays.jl\src\cache.jl:422
  [8] copyto!(dest::SubArray{…}, bc::Base.Broadcast.Broadcasted{…})
    @ LazyArrays c:\Users\djv23\.julia\dev\LazyArrays.jl\src\cache.jl:422
  [9] materialize!
    @ .\broadcast.jl:905 [inlined]
 [10] materialize!
    @ .\broadcast.jl:902 [inlined]
 [11] copyto!_layout(::ColumnMajor, ::BroadcastLayout{…}, dest::SubArray{…}, bc::SubArray{…})
    @ LazyArrays c:\Users\djv23\.julia\dev\LazyArrays.jl\src\lazybroadcasting.jl:43
 [12] copyto!_layout
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\memorylayout.jl:310 [inlined]
 [13] copyto!_layout
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\ArrayLayouts.jl:272 [inlined]
 [14] copyto!
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\ArrayLayouts.jl:288 [inlined]
 [15] sub_materialize(lay::LazyArrays.ApplyLayout{…}, V::SubArray{…}, ::Tuple{…})
    @ LazyArrays c:\Users\djv23\.julia\dev\LazyArrays.jl\src\lazyconcat.jl:887
 [16] sub_materialize
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\ArrayLayouts.jl:136 [inlined]
 [17] sub_materialize
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\ArrayLayouts.jl:137 [inlined]
 [18] layout_getindex
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\ArrayLayouts.jl:143 [inlined]
 [19] getindex(A::ApplyArray{Float64, 2, typeof(vcat), Tuple{Adjoint{…}, Adjoint{…}}}, kr::Colon, jr::UnitRange{Int64})
    @ ArrayLayouts C:\Users\djv23\.julia\packages\ArrayLayouts\FxFFC\src\ArrayLayouts.jl:156
 [20] eval(m::Module, e::Any)
    @ Core .\boot.jl:489
Some type information was truncated. Use `show(err)` to see complete types.

Also doesn't really change any of the timing issues we found - they're still on the same scale. Gotta do more digging. Creating the PR now just incase I can see what other downstream stuff might be breaking.

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.89%. Comparing base (d7d4f63) to head (58fa1c1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #387   +/-   ##
=======================================
  Coverage   95.88%   95.89%           
=======================================
  Files          17       17           
  Lines        3351     3359    +8     
=======================================
+ Hits         3213     3221    +8     
  Misses        138      138           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielVandH DanielVandH reopened this Nov 13, 2025
src/cache.jl Outdated
const _cache = cache_layout # TODO: deprecate
cacheddata(A::AbstractCachedArray) = view(A.data,OneTo.(A.datasize)...)
cacheddata(A::Adjoint{<:Any, <:AbstractCachedArray}) = adjoint(cacheddata(parent(A)))
cacheddata(A::Transpose{<:Any, <:AbstractCachedArray}) = transpose(cacheddata(parent(A)))
Copy link
Member

Choose a reason for hiding this comment

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

There's no reason to assume the parent is an AbstractCachedArray (it could just conform to the cached array interface):

Suggested change
cacheddata(A::Transpose{<:Any, <:AbstractCachedArray}) = transpose(cacheddata(parent(A)))
cacheddata(A::Adjoint) = adjoint(cacheddata(parent(A)))
cacheddata(A::Transpose) = transpose(cacheddata(parent(A)))

src/cache.jl Outdated

MemoryLayout(::Type{<:AbstractCachedArray}) = GenericCachedLayout()

transposelayout(::GenericCachedLayout) = GenericCachedLayout()
Copy link
Member

Choose a reason for hiding this comment

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

Should this be:

Suggested change
transposelayout(::GenericCachedLayout) = GenericCachedLayout()
transposelayout(::AbstractCachedLayout) = GenericCachedLayout()

(also next line)

CachedArrayStyle{M}(::Val{N}) where {N,M} = CachedArrayStyle{N}()

BroadcastStyle(::Type{<:AbstractCachedArray{<:Any,N}}) where N = CachedArrayStyle{N}()
BroadcastStyle(::Type{<:AdjOrTrans{<:Any, <:AbstractCachedArray{<:Any,N}}}) where N = CachedArrayStyle{N}()
Copy link
Member

Choose a reason for hiding this comment

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

Do we also need to support adjoints of views of cached arrays?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think that comes up but I can add support for it anyway

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.

3 participants