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

[SYSTEMDS-3333] Improve matrix mult chain opt #1948

Conversation

gogokotsev00
Copy link
Contributor

@gogokotsev00 gogokotsev00 commented Nov 24, 2023

Now our chain of Hops gets rewritten when we have t(A %% B) into t(B) %% t(A), which contributes to a larger optimization space.

@gogokotsev00 gogokotsev00 marked this pull request as ready for review November 24, 2023 16:16
@gogokotsev00 gogokotsev00 marked this pull request as draft November 24, 2023 16:17
@phaniarnab
Copy link
Contributor

Thanks for the PR. It's a good start @gogokotsev00.
Here are a few general comments.

  • Investigate why some of the tests failed.
  • Add tests to verify your changes are working. Follow the examples of RewriteMatrixMultChainOptTest and RewriteMatrixMultChainOptTest2.
  • Try to integrate the new rewrites in self-contained functions. This way we can easily disable the new rewrites if we encounter bugs or harmful impacts. You can also add static flags to enable/disable the rewrites (e.g. PUSH_DOWN_TRANSPOSE = true).
  • Export developer code style (/dev/CodeStyle_eclipse.xml) to avoid unintended diffs such as space vs tabs.

@gogokotsev00 gogokotsev00 marked this pull request as ready for review November 26, 2023 23:14
@gogokotsev00 gogokotsev00 marked this pull request as draft November 26, 2023 23:15
@gogokotsev00 gogokotsev00 marked this pull request as ready for review November 27, 2023 23:29
@gogokotsev00 gogokotsev00 marked this pull request as draft November 27, 2023 23:30
@phaniarnab
Copy link
Contributor

Thanks @gogokotsev00 for adding the tests.
Besides the correction check, is it possible to add an assertion for the tests to verify if your rewrite is picked up? You can utilize the Statistics.getCPHeavyHitterCount module (e.g. matching the number of transpose). Rewrites often contradict. This assertion will detect if a future rewrite unintentionally reverts your changes.
I also recommend adding few more tests with different matmult patterns, such as using the same input multiple times so that the mmchain operator is used (check the mmchain tests).
Do not worry about the federated test failure. That is not due to your changes. Please rebase on main once Sebastian fixes the issue there.

@phaniarnab
Copy link
Contributor

@gogokotsev00, please do not merge branches. Instead, rebase your changes on the latest main branch.
Otherwise, it'd be hard to cherry-pick your changes while pushing your changes.

@gogokotsev00 gogokotsev00 force-pushed the SYSTEMDS-3333_improve_matrix_mult_chain_opt branch from 8dce318 to ad8c793 Compare December 10, 2023 18:24
@gogokotsev00 gogokotsev00 marked this pull request as ready for review December 10, 2023 22:00
@j143 j143 changed the title Systemds 3333: improve matrix mult chain opt [SYSTEMDS-3333] Improve matrix mult chain opt Dec 17, 2023
@j143 j143 added this to the systemds-3.2.0 milestone Dec 17, 2023
@gogokotsev00 gogokotsev00 force-pushed the SYSTEMDS-3333_improve_matrix_mult_chain_opt branch 2 times, most recently from 6f5131f to a382cf4 Compare January 26, 2024 11:02
@gogokotsev00 gogokotsev00 force-pushed the SYSTEMDS-3333_improve_matrix_mult_chain_opt branch from a382cf4 to 16c89ba Compare February 1, 2024 21:58
@gogokotsev00
Copy link
Contributor Author

We were not able to find rewrites which impede an optimal matrix multiplication chain. We have tested with the following examples:

  • -t(a) %*% b %*% -t(c) %*% d
  • -t(a) %*% b
  • -t(a) %*% b %*% c

@j143
Copy link
Contributor

j143 commented Feb 8, 2024

Hi,

this PR may not make it to 3.2.0 to avoid last minute internal behavior changes,
applying the next-release milestone

@j143 j143 modified the milestones: systemds-3.2.0, next-release Feb 8, 2024
@mboehm7
Copy link
Contributor

mboehm7 commented Mar 16, 2024

LGTM - thanks for the patch @gogokotsev00 and team. During the merge, I moved the rewrite to a separate experimental rewrite which is not yet fully integrated (because I think it's not ready for that). The reason why you did not see your rewrite being applied as expected is that the transposes for folded into the generation of constant matrices (with flipped dimensions). By adding our special program block cut while(FALSE){} you can separate them and the tests fail with an unexpected number of transposes.

@mboehm7 mboehm7 closed this in e11eb24 Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants