-
Notifications
You must be signed in to change notification settings - Fork 501
[SYSTEMDS-3910] OOC matrix-matrix multiplication #2319
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mboehm7 , I've attempted to implement matrix-matrix multiplication. There are some concerns.
- copy() method
- about a situation where different blocks having different sparsity. Since, I'm not explicitly handling - could that be handled?
src/main/java/org/apache/sysds/runtime/instructions/ooc/MatrixMatrixBinaryOOCInstruction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/OOCInstructionParser.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/ooc/MatrixMatrixBinaryOOCInstruction.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your effort here @j143 and my comments are below. However, in the future let's please better synchronize on who is doing which task (I thought I shared that @jessicapriebe is working on OOC matrix-multiplication; one PR merged, but additional ones to come). For now please continue with this PR since Jessica is anyway busy for the next weeks.
src/main/java/org/apache/sysds/runtime/instructions/OOCInstructionParser.java
Outdated
Show resolved
Hide resolved
src/test/java/org/apache/sysds/test/functions/ooc/MatrixMatrixBinaryMultiplicationTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/ooc/MatrixMatrixBinaryOOCInstruction.java
Show resolved
Hide resolved
|
||
// Create a copy | ||
MatrixBlock sourceBlock = (MatrixBlock) tmpA.getValue(); | ||
MatrixBlock blockCopy = new MatrixBlock(sourceBlock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need for explicit copies - for every block that is streamed in we perform a block matrix multiplication which creates new output blocks and these output blocks are then aggregated if necessary. By default we have copy-on-write-semantics which means operations are never performed in place unless we explicitly say so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/main/java/org/apache/sysds/runtime/instructions/ooc/MatrixVectorBinaryOOCInstruction.java
Show resolved
Hide resolved
This patch introduces the MatrixMatrix multiplication logic. It performs a shuffle-based matrix multiplication on two large matrix streams. Implementation Detail: Asynchronous Producer: The processInstruction method launches a background thread to perform the entire two-phase multiplication, but returns control to the main thread immediately. This non-blocking setup allows the compiler to build the downstream executionplan while the OOC operation prepares to run upon data request. Two-Phase Streaming Logic: The background thread implements a shuffle-based algorithm to handle two large inputs: * Phase 1 (Grouping/Shuffle): It first consumes both input streams entirely. Blocks from each stream (A_ik and B_kj) are partitioned into groups based on the output block index (C_ij) they contribute to. A HashMap stores these groups, effectively "shuffling" the data for parallel processing. * Phase 2 (Aggregation/Reduce): After grouping, it processes each group independently. Within a group, it pairs the corresponding blocks using their common index k, performs the block-level multiplication, and aggregates the results to produce a single, final output block which is then enqueued to theoutput stream. Robust Block Identification: A TaggedMatrixValue wrapper is used during the grouping phase to explicitly tag each block with its source matrix (A or B). This ensures correct and unambiguous identification during the aggregation phase, a critical requirement that cannot be met by relying on block dimensions alone. Integration: The new instruction is fully integrated into the OOC framework: * The OOCInstructionParser is updated to recognize the aggregate binary in OOC context.
648d9bf
to
eb44ff0
Compare
Hi @mboehm7 , any codestyle or commit style suggestions that I might be missing please do let me know - I will try to take care of them in the future code changes. Across all my code. |
..