Repository navigation
Conversation
|
cool! I'll try to play around with this at some point. @willow-ahrens @kylebd99 just copying over these notes from scipy/scipy#26217 in case you can help:
|
|
Hey, thanks for contributing! Also, thanks for the PRs over on Finch.jl :) For the benchmarks in SAPS, the goal is to show how different array frameworks (e.g. pydata/sparse, scipy.sparse, pytorch.sparse, etc.) perform across various workloads leveraging the array API. So, what happens when different framework's arrays are input into scipy_spla? Does it internally use their functionality or does it just translate to a scipy array then call scipy's internal cg function? The latter wouldn't be a great fit as a benchmark in this suite because it wouldn't be able to demonstrate a difference between frameworks and any errors would either be in scipy or in compatibility with scipy. |
|
Thank you for the notes on usability btw. These are super helpful for us as we refine the (framework/benchmark) contributor process. The freshness tests have been a bit tricky for us to nail down. We'd like to ensure that the data and the code come as a coherent pair, but the current setup may be too restrictive. In the end, we will likely move that check to the release process instead of CI. |
Currently, inputs are wrapped with https://scipy.github.io/devdocs/reference/generated/scipy.sparse.linalg.aslinearoperator.html#scipy.sparse.linalg.aslinearoperator. In addition to what is mentioned in that documentation, pydata sparse arrays are also special-cased. The My open PR scipy/scipy#24450 switches this to an array API native implementation. The idea is that any sparse array backend which works with the current SAPS benchmarks should also be able to run through the That part is I suppose largely to test correctness / interoperability / check that we aren't butchering performance with I/O. A follow-up could look at adding batched benchmarks here, which is the novel part of my |
|
it is admittedly extremely confusing that functions which work with more-than-just- |
|
Confirming that empirically since it is easy to check: It does show up in the numbers too. On |
|
yeah, in my rather rudimentary benchmarking of ref. https://discord.com/channels/786703927705862175/1301155724646289420/1476247207886979225 (#pydata-sparse in the Scientific Python discord) |
|
@lucascolley I am not able to open that discord link :(, Do I need an invite link to the channel first? |
Try clicking the discord logo in the footer of https://scientific-python.org/ |
|
Got in, Thanks! |
|
Ah, very cool that this supports any array-api compatible backend. My gut intuition is to add this benchmark in with an "experimental" suite tag, just because the benchmark function is subject to change based on your PR/the status of scipy.sparse.linalg. Fortunately, the scipy version is pinned in the repo, so there should be no variation in the benchmark function within a single version of SAPS. Going forward, we'll likely be refining the notion of benchmark suites, and we will move it out of experimental and into something like 'solvers'. @willow-ahrens @JoelMathewC thoughts? |
|
Also, @AJ0070, we're doing a series of interviews with people in the sparse ecosystem, would you be open to finding a time to chat https://calendly.com/d/dv9p-7b9-96m/pose-interview ? |
Yeah, at least from my side there is no rush for anything to actually be merged into SAPS, as long as there is a branch that is usable. Hopefully this helps drive the design though :) |
@kylebd99 Thanks for the offer! Bit stretched for time at the moment, but I am happy to keep helping here, so do ping me whenever something comes up. |
|
A few notes:
|
|
Perhaps we should start thinking about how to include benchmarking against a development version of It would be a one-line change with Pixi, but I realise that switching this repo from |
|
Done: the scipy import now happens inside
Main has moved on since I branched, so I checked against current main too. The benchmark passes under numpy, scipy and pydata/sparse, but fails under the new |
|
hi @willow-ahrens @kylebd99, just checking in here — any way I can help on the framework-side? Would be great to progress this |
|
@AJ0070 Eventually, we hope to remove the smart framework, but we don't yet have an external framework capable of executing all of the suite. The point of the smart framework was to be a place where we contain any hacks we need to get frameworks to run, so we can just hack it until it runs this one too. @lucascolley On the framework side, our goal is to eventually remove "Framework" from the saps suite altogether by putting as much of it as possible in array api extra. If you have any suggestions for how to work towards this I would be on board! Overall, I think this PR is ready for me to take a look at and merge, I can take it from here. It would be great to see more PRs like this one for other solvers in Scipy! |
let me review data-apis/array-api-extra#1072 now and we can move from there 👍 |
Draft, following up on scipy/scipy#26217.
Adds
SciPyCGBenchmark, which runsscipy.sparse.linalg.cgon the same datasets as the existingcgbenchmark so the two can be compared directly. It reusesCGTestGeneratorandCGGenerator, and delegateschecktoCGBenchmark.It subclasses
Benchmarkrather thanCGBenchmark, so that it doesn't also inherit the generatedtime_cg_solverentry point.The tolerances map directly: scipy stops on
norm(b - A @ x) <= max(rtol*norm(b), atol)and the SAPS cg usesmax(rel_tol*norm(b), abs_tol), sortol=rel_tol,atol=abs_tol,maxiter=max_iter, with no pre-processing needed. On the six SPD matrices I tried the two produce bit-identical solutions, so they are taking the same iterations and any timing difference is implementation overhead rather than different amounts of work.On those matrices, 24,696 to 74,752 rows, medians over 25 repeats, the two come out within a few percent of each other in both directions. Numbers are in scipy/scipy#26217.
Not included here:
metadata.jsonneeds regenerating before the benchmark is discovered, but doing that locally rewrote everyfreshnesshash, 52k lines, since they cover installed dependency versions. Happy to add it if you would rather have it in.