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

Faster MTTKRP #33

Closed
dahong67 opened this issue Nov 15, 2023 · 1 comment
Closed

Faster MTTKRP #33

dahong67 opened this issue Nov 15, 2023 · 1 comment

Comments

@dahong67
Copy link
Owner

dahong67 commented Nov 15, 2023

The current MTTKRP implementation (used for ALS) is simple but inefficient.

A significant part of the cost can come from forming the tensor matricization on this line:

# Matricized tensor (in mode n)
Xn = reshape(permutedims(X, [n; setdiff(1:N, n)]), size(X, n), :)

Can be seen by profiling in VS Code as follows:

X = randn(100,200,300);
@profview gcp(X, 10)

Note that time spent in permutedims accounts for a significant part of gcp.

image

We should implement the more efficient MTTKRP described in Section III-B of this paper: https://ieeexplore.ieee.org/document/6544287

Just focus on a single mode for now - we'll save the MTTKRPS (MTTKRP sequence) for #17.

Make sure to give them credit in the docstring!

@dahong67
Copy link
Owner Author

dahong67 commented Mar 1, 2024

Re-running the above profile with the new implementation indicates that the bottlenecks are now:

image

For this simple test case, the main Khatri-Rao costs came from the n==1 and n==N MTTKRP's. Makes sense since those Khatri-Rao products are larger.

image

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

No branches or pull requests

1 participant