Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AbstractArray{<:AbstractTracer} methods for common LinearAlgebra functions #115

Closed
adrhill opened this issue Jun 1, 2024 · 2 comments · Fixed by #131
Closed

Add AbstractArray{<:AbstractTracer} methods for common LinearAlgebra functions #115

adrhill opened this issue Jun 1, 2024 · 2 comments · Fixed by #131
Assignees
Labels
discussion Discuss design decisions / future direction of the package
Milestone

Comments

@adrhill
Copy link
Owner

adrhill commented Jun 1, 2024

As discussed in #108, some functions like logdet require control flow, which currently only works with local tracers:

julia> using SparseConnectivityTracer, SparseArrays, LinearAlgebra

julia> hessian_pattern(logdet, rand(3, 3))
ERROR: TypeError: non-boolean (SparseConnectivityTracer.HessianTracer{BitSet, Set{Tuple{Int64, Int64}}}) used in boolean context
Stacktrace:
  [1] generic_lufact!(A::Matrix{SparseConnectivityTracer.HessianTracer{BitSet, Set{…}}}, pivot::RowMaximum; check::Bool)
    @ LinearAlgebra /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/LinearAlgebra/src/lu.jl:152
...

This could be avoided by adding methods like LinearAlgebra.logdet(M::AbstractMatrix{<:AbstractTracer}) that return conservative estimates of the corresponding sparsity pattern.

@adrhill adrhill added the discussion Discuss design decisions / future direction of the package label Jun 1, 2024
@gdalle
Copy link
Collaborator

gdalle commented Jun 1, 2024

I think this is necessary, I just don't know if we should do it on a case by case basis or implement an array operator classification mirroring the scalar one

@adrhill
Copy link
Owner Author

adrhill commented Jun 5, 2024

It's worth emphasizing that, as mentioned in #118, this could also lead to large increases in performance.
Currently, operations like dense matrix-vector products of tracers dispatch down to scalar operations. Instead, we could be a lot smarter in the way we compute unions of index sets.

@adrhill adrhill added this to the Paper milestone Jun 6, 2024
@adrhill adrhill changed the title Should we add AbstractArray{<:AbstractTracer} methods for common LinearAlgebra functions? Add AbstractArray{<:AbstractTracer} methods for common LinearAlgebra functions Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss design decisions / future direction of the package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants