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 dpnp.linalg.eigh() function #1383

Merged
merged 5 commits into from
Apr 29, 2023

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Apr 19, 2023

The PR is about to close #1344, since it covers the last functional gap of pca benchmark.

PR adds a missing dpnp.linalg.eigh() function to calculate the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric input matrix. OneMKL LAPACK library is used for that.
The implementation is written as a pybind11 extension above required LAPACK functions.

This is a base PR which assumes to be extended later with remaining functions from OneMKL LAPACK library, once new functionality required.

Numbers for a laptop with Iris Xe:

import dpnp, numpy

sh = (2024, 2024)
a = numpy.random.uniform(-1, 1, sh) + 1.j * numpy.random.uniform(-1, 1, sh)
a = a.astype(numpy.complex64)
x = numpy.matrix(a)

nx = x.getH()
%timeit _, _ = numpy.linalg.eigh(nx)
Out: 2.21 s ± 199 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

dx = dpnp.array(nx, device='level_zero:gpu')
%timeit _, _ = dpnp.linalg.eigh(dx)
Out: 858 ms ± 25.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

dx = dpnp.array(nx, device='opencl:gpu')
%timeit _, _ = dpnp.linalg.eigh(dx)
Out: 849 ms ± 37.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

dx = dpnp.array(nx, device='opencl:cpu')
%timeit _, _ = dpnp.linalg.eigh(dx)
Out: 841 ms ± 47.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

nx.size, dx.size
Out: (4096576, 4096576)
  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you filing the PR as a draft?

@antonwolfy antonwolfy self-assigned this Apr 19, 2023
@antonwolfy antonwolfy force-pushed the add_linalg_eigh branch 7 times, most recently from 1950d5b to 547f5b3 Compare April 20, 2023 17:31
.gitignore Outdated Show resolved Hide resolved
Copy link
Collaborator

@npolina4 npolina4 left a comment

Choose a reason for hiding this comment

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

Works in pca workload. Thanks!

dpnp/dpnp_iface.py Outdated Show resolved Hide resolved
@antonwolfy antonwolfy merged commit 4d27b4c into IntelPython:master Apr 29, 2023
@antonwolfy antonwolfy deleted the add_linalg_eigh branch April 29, 2023 14:10
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.

Support PCA dpnp implementation on dpbench
3 participants