Skip to content

Add RecursiveArrayToolsExt to support ArrayPartitions - #164

Draft
hakkelt wants to merge 5 commits into
JuliaFirstOrder:masterfrom
hakkelt:recursive-array-tools-ext
Draft

Add RecursiveArrayToolsExt to support ArrayPartitions#164
hakkelt wants to merge 5 commits into
JuliaFirstOrder:masterfrom
hakkelt:recursive-array-tools-ext

Conversation

@hakkelt

@hakkelt hakkelt commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a package extension (RecursiveArrayToolsExt) that lets SeparableSum and PrecomposedSlicedSeparableSum operate directly on RecursiveArrayTools.ArrayPartition, avoiding the need to manually convert to/from tuples.
  • Extension is triggered by RecursiveArrayTools as a weak dependency (Project.toml [weakdeps]/[extensions]), so it adds no dependency unless the user already has RecursiveArrayTools loaded.

Test plan

  • test/test_recursivearraytools.jl exercises prox, prox!, gradient, gradient!, and function evaluation on ArrayPartitions for both SeparableSum and PrecomposedSlicedSeparableSum.
  • test/runtests.jl updated to run the new test file and load RecursiveArrayTools in a Julia version that supports it.
  • Aqua tests updated/passing for the new extension.

Marking as draft to get early feedback on the extension's API surface before finalizing.

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master 6596794... master / 6596794...
IndBallL1/Float32 3.73 ± 3.5 μs 3.79 ± 3.4 μs 0.984 ± 1.3
IndBallL1/Float64 4.19 ± 1.6 μs 4.16 ± 1.6 μs 1.01 ± 0.55
IndBox/Float32 8.18 ± 0.47 μs 8.13 ± 0.45 μs 1.01 ± 0.08
IndBox/Float64 8.61 ± 1.7 μs 9.23 ± 1.5 μs 0.933 ± 0.24
IndExpPrimal/Float32 0.158 ± 0.0089 ms 0.155 ± 0.0088 ms 1.02 ± 0.081
IndExpPrimal/Float64 0.159 ± 0.0095 ms 0.156 ± 0.0093 ms 1.02 ± 0.086
IndNonnegative/Float32 2.69 ± 1.2 μs 2.71 ± 1.1 μs 0.992 ± 0.6
IndNonnegative/Float64 3.68 ± 2.7 μs 4.5 ± 2.1 μs 0.818 ± 0.72
IndPSD/("ComplexF64", 10) 15 ± 0.67 μs 15 ± 0.66 μs 1 ± 0.063
IndPSD/("ComplexF64", 20) 0.0557 ± 0.00071 ms 0.0556 ± 0.00071 ms 1 ± 0.018
IndPSD/("ComplexF64", 50) 0.462 ± 0.012 ms 0.463 ± 0.012 ms 0.999 ± 0.037
IndPSD/("Float64", 10) 12.2 ± 0.47 μs 12.2 ± 0.47 μs 0.999 ± 0.055
IndPSD/("Float64", 20) 0.039 ± 0.00092 ms 0.0391 ± 0.00091 ms 0.997 ± 0.033
IndPSD/("Float64", 50) 0.24 ± 0.0079 ms 0.24 ± 0.0073 ms 0.999 ± 0.045
IndSimplex/Float32 20.6 ± 0.49 μs 20.2 ± 0.5 μs 1.02 ± 0.035
IndSimplex/Float64 24 ± 2.6 μs 23.7 ± 2.7 μs 1.01 ± 0.16
LeastSquares/("ComplexF64", "(11, 5)", 0, 0) 0.932 ± 0.03 μs 0.942 ± 0.03 μs 0.989 ± 0.045
LeastSquares/("ComplexF64", "(11, 5)", 0, 1) 1.28 ± 0.13 μs 1.26 ± 0.14 μs 1.02 ± 0.15
LeastSquares/("ComplexF64", "(11, 5)", 1, 0) 7.69 ± 0.37 μs 7.79 ± 0.4 μs 0.987 ± 0.07
LeastSquares/("ComplexF64", "(11, 5)", 1, 1) 1.28 ± 0.14 μs 1.27 ± 0.14 μs 1.01 ± 0.16
LeastSquares/("ComplexF64", "(5, 11)", 0, 0) 1.05 ± 0.031 μs 1.05 ± 0.04 μs 0.999 ± 0.048
LeastSquares/("ComplexF64", "(5, 11)", 0, 1) 1.38 ± 0.13 μs 1.38 ± 0.14 μs 1 ± 0.14
LeastSquares/("ComplexF64", "(5, 11)", 1, 0) 7.9 ± 0.37 μs 7.95 ± 0.36 μs 0.994 ± 0.065
LeastSquares/("ComplexF64", "(5, 11)", 1, 1) 1.41 ± 0.15 μs 1.43 ± 0.16 μs 0.986 ± 0.15
LeastSquares/("Float64", "(11, 5)", 0, 0) 0.771 ± 0.02 μs 0.761 ± 0.03 μs 1.01 ± 0.048
LeastSquares/("Float64", "(11, 5)", 0, 1) 1.04 ± 0.14 μs 1.06 ± 0.13 μs 0.981 ± 0.18
LeastSquares/("Float64", "(11, 5)", 1, 0) 7.52 ± 0.34 μs 7.49 ± 0.32 μs 1 ± 0.063
LeastSquares/("Float64", "(11, 5)", 1, 1) 1.06 ± 0.15 μs 1.06 ± 0.16 μs 0.999 ± 0.21
LeastSquares/("Float64", "(5, 11)", 0, 0) 0.891 ± 0.021 μs 0.891 ± 0.021 μs 1 ± 0.033
LeastSquares/("Float64", "(5, 11)", 0, 1) 1.17 ± 0.12 μs 1.16 ± 0.12 μs 1.01 ± 0.15
LeastSquares/("Float64", "(5, 11)", 1, 0) 7.64 ± 0.31 μs 7.7 ± 0.28 μs 0.992 ± 0.054
LeastSquares/("Float64", "(5, 11)", 1, 1) 1.16 ± 0.16 μs 1.16 ± 0.15 μs 1 ± 0.19
NormL2/Float32 3.5 ± 0.32 μs 3.48 ± 0.31 μs 1.01 ± 0.13
NormL2/Float64 9.19 ± 1.9 μs 9.23 ± 1.8 μs 0.996 ± 0.28
time_to_load 0.876 ± 0.0038 s 0.887 ± 0.01 s 0.987 ± 0.012
Memory benchmarks
master 6596794... master / 6596794...
IndBallL1/Float32 10 allocs: 10.4 kB 10 allocs: 10.4 kB 1
IndBallL1/Float64 10 allocs: 20.5 kB 10 allocs: 20.5 kB 1
IndBox/Float32 1 allocs: 16 B 1 allocs: 16 B 1
IndBox/Float64 1 allocs: 16 B 1 allocs: 16 B 1
IndExpPrimal/Float32 11 k allocs: 0.179 MB 11 k allocs: 0.179 MB 1
IndExpPrimal/Float64 11 k allocs: 0.179 MB 11 k allocs: 0.179 MB 1
IndNonnegative/Float32 1 allocs: 16 B 1 allocs: 16 B 1
IndNonnegative/Float64 1 allocs: 16 B 1 allocs: 16 B 1
IndPSD/("ComplexF64", 10) 19 allocs: 11.9 kB 19 allocs: 11.9 kB 1
IndPSD/("ComplexF64", 20) 22 allocs: 29.2 kB 22 allocs: 29.2 kB 1
IndPSD/("ComplexF64", 50) 23 allocs: 0.116 MB 23 allocs: 0.116 MB 1
IndPSD/("Float64", 10) 16 allocs: 5.88 kB 16 allocs: 5.88 kB 1
IndPSD/("Float64", 20) 18 allocs: 14 kB 18 allocs: 14 kB 1
IndPSD/("Float64", 50) 19 allocs: 0.0564 MB 19 allocs: 0.0564 MB 1
IndSimplex/Float32 24 allocs: 0.0344 MB 24 allocs: 0.0344 MB 1
IndSimplex/Float64 26 allocs: 0.0685 MB 26 allocs: 0.0685 MB 1
LeastSquares/("ComplexF64", "(11, 5)", 0, 0) 7 allocs: 1.05 kB 7 allocs: 1.05 kB 1
LeastSquares/("ComplexF64", "(11, 5)", 0, 1) 17 allocs: 1.14 kB 17 allocs: 1.14 kB 1
LeastSquares/("ComplexF64", "(11, 5)", 1, 0) 0.059 k allocs: 4.6 kB 0.059 k allocs: 4.6 kB 1
LeastSquares/("ComplexF64", "(11, 5)", 1, 1) 17 allocs: 1.17 kB 17 allocs: 1.17 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 0, 0) 7 allocs: 1.05 kB 7 allocs: 1.05 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 0, 1) 17 allocs: 1.14 kB 17 allocs: 1.14 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 1, 0) 0.059 k allocs: 4.6 kB 0.059 k allocs: 4.6 kB 1
LeastSquares/("ComplexF64", "(5, 11)", 1, 1) 17 allocs: 1.17 kB 17 allocs: 1.17 kB 1
LeastSquares/("Float64", "(11, 5)", 0, 0) 7 allocs: 0.609 kB 7 allocs: 0.609 kB 1
LeastSquares/("Float64", "(11, 5)", 0, 1) 17 allocs: 0.984 kB 17 allocs: 0.984 kB 1
LeastSquares/("Float64", "(11, 5)", 1, 0) 0.059 k allocs: 3.96 kB 0.059 k allocs: 3.96 kB 1
LeastSquares/("Float64", "(11, 5)", 1, 1) 17 allocs: 1.02 kB 17 allocs: 1.02 kB 1
LeastSquares/("Float64", "(5, 11)", 0, 0) 7 allocs: 0.609 kB 7 allocs: 0.609 kB 1
LeastSquares/("Float64", "(5, 11)", 0, 1) 17 allocs: 0.984 kB 17 allocs: 0.984 kB 1
LeastSquares/("Float64", "(5, 11)", 1, 0) 0.059 k allocs: 3.96 kB 0.059 k allocs: 3.96 kB 1
LeastSquares/("Float64", "(5, 11)", 1, 1) 17 allocs: 1.02 kB 17 allocs: 1.02 kB 1
NormL2/Float32 1 allocs: 16 B 1 allocs: 16 B 1
NormL2/Float64 1 allocs: 16 B 1 allocs: 16 B 1
time_to_load 0.149 k allocs: 11.2 kB 0.149 k allocs: 11.2 kB 1

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.

1 participant