Repository navigation
BUG: Use power iteration as the default HITS implementation - #8620
Conversation
dschult
left a comment
There was a problem hiding this comment.
Power iteration often seems to outshine when it is supposed to be too slow. :)
I guess more troubles arises if the two largest eigenvalues are close to each other.
But that's trouble with convergence, not with speed (unless lack of convergence causes poor speed).
The SciPy sparse spectrum finders from ARPACK were rewritten in C instead of fortran during spring/summer 2025. So I think SciPy 1.17.0 is the first release. Are these timings for 1.17?
The only reason I can think of to keep the svds approach would be if there are some identifiable cases where the svds is better. Perhaps it serves as an example in case someone wants to retest in a few years -- but this PR should still be around, right? :}
Feels like removing it after any further testing you might want to do would be fine.
|
Can we add your benchmark (or something like it) to the benchmarking suite? |
I tried this and unfortunately #4847 is so old that there have been significant enough changes to make setting up the environment and building the library on that commit challenging (at least
One thing I was able to do with asv was run with both scipy 1.16 and 1.17. There was no significant difference when I ran locally on two different machines, but there was a lot of variability (i.e. timings could vary significantly on the same benchmarks between runs). This doesn't necessarily surprise me given ARPACK or any other low-level linalg libraries involved, which often include parallelism and all sorts of other fun things that make them hard to reliably benchmark (especially across systems i.e. different linalg providers like openblas vs. blas vs. blis vs. etc.)
Maybe it's worth bringing power iteration back and having both available via a "method" kwarg? In practice I doubt we can get to large enough graph sizes where the difference between the two methods is appreciable enough to be the bottleneck, so maybe it's not worth the effort! |
| hlast = h | ||
| a = h @ A | ||
| h = A @ a | ||
| a /= a.max() |
There was a problem hiding this comment.
When I implemented this a few years ago, I convinced myself that normalizing a in this loop is unnecessary and wasted effort.
Peiffap
left a comment
There was a problem hiding this comment.
Some comments below. +1 for Erik's note.
rossbar
left a comment
There was a problem hiding this comment.
Looking at this again I think my vote would be to include both implementations and add a method={"power_iteration", "svd"} kwarg to select. As for which one is the default I don't have a real preference!
|
Looks like we should rebase. Also very minor, but |
Well it is the default, so users don't really need to type it in :D |
dschult
left a comment
There was a problem hiding this comment.
This PR looks ready to merge. We've had reviews from 4 of us and 5th is the author. All comments seem to be addressed (Thanks @MridulS!)
I've gone through it again and didn't come up with anything except a tolerance rabbit hole which is nicely handled here by referring to the scipy function that is called.
I approve this PR
The SVD-based HITS was added in #4847 as a performance improvement, but there a few edge cases like #6289. I tried running the benchmarks again with a standard implementation which seems to be a bit more performant than the SVD one for most of the cases. Grid/lattice graphs are still better served by SVD.
A mini benchmark (maybe I should do a bit more benchmarking)
nx.hits_hits_svdI'm not sure if we should keep the SVD one around or not.