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

[WIP] Use Tullio for pairwise distances #385

Closed
wants to merge 24 commits into from
Closed

[WIP] Use Tullio for pairwise distances #385

wants to merge 24 commits into from

Conversation

theogf
Copy link
Member

@theogf theogf commented Oct 19, 2021

Summary
We have a long-time problem for binary operations like DotProduct not satisfying the requirements of the Distances.jl framework (not a proper metric). Additionally, Distances.jl is very incompatible with GPU operations (see JuliaStats/Distances.jl#143 and JuliaStats/Distances.jl#137).
Using Tullio.jl should solve both these problems. Some quick benchmarks shows that Tullio is both faster and more GPU-able than Distances.jl

There is a longer discussion about this PR in #380
This should also close #98 and replace #194

Proposed changes

  • Tullio is used for computing all pairwise and colwise
  • The only thing used from Distances.jl are their types (we stop using Distances.pairwise).
  • Adding special implementations of pairwise for ColVecs and RowVecs when possible to improve speed (and GPU compatibility)
  • Create a AbstractBinaryOp abstract type for objects like DotProduct and Delta and combine them with Distances using BinaryOp = Union{AbstractBinaryOp,Distances.PreMetric}.

What alternatives have you considered?
Dropping Distances.jl operations anyway but without Tullio but Tullio shows it's faster.

Breaking changes

  • It's technically not breaking since the API does not change, only the internal computations change

theogf and others added 24 commits April 16, 2021 14:48
I was checking the docstrings and the one for the `spectral_mixture_kernel` is particularly wrong I think. I double checked with the first reference paper as well as the implementation and changed the formula/description of the arguments
…ssianProcesses/KernelFunctions.jl into tg/correct_doc_spectral_mixture
Co-authored-by: David Widmann <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@theogf
Copy link
Member Author

theogf commented Oct 19, 2021

Ah... Ups I think I did not branch from master....


function colwise(::DotProduct, x::ColVecs, y::ColVecs=x)
return @tullio out[i] := x.X[k, i] * y.X[k, i]
end
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
end

return map(d, x, y)
end
return @tullio out[i] := d(x[i], y[i])
end
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
end

@theogf theogf closed this Oct 19, 2021
@theogf
Copy link
Member Author

theogf commented Oct 19, 2021

Blessed be git cherry-pick

@yebai yebai deleted the tgf/binary_op branch January 13, 2023 20:11
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.

DotProduct "metric"
2 participants