-
Notifications
You must be signed in to change notification settings - Fork 521
[SYSTEMDS-3386] Refactor replacement of CP instructions #1628
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
Conversation
kev-inn
left a comment
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.
Some comments to explain myself :)
src/main/java/org/apache/sysds/runtime/instructions/cp/CovarianceCPInstruction.java
Outdated
Show resolved
Hide resolved
| return new QuantilePickCPInstruction(null, in1, new CPOperand(), out, ptype, inmem, opcode, str); | ||
| return new QuantilePickCPInstruction(null, in1, out, ptype, inmem, opcode, str); |
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.
Our new approach allows us to remove this fix/hack.
src/main/java/org/apache/sysds/runtime/instructions/cp/QuantilePickCPInstruction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/cp/QuantileSortCPInstruction.java
Outdated
Show resolved
Hide resolved
| import org.apache.sysds.runtime.matrix.operators.UnaryOperator; | ||
|
|
||
| public class UnaryScalarCPInstruction extends UnaryMatrixCPInstruction { | ||
| public class UnaryScalarCPInstruction extends UnaryCPInstruction { |
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.
This is a problem due to inheritance. We replace UnaryMatrixCPInstructions, but don't replace UnaryScalarCPInstructions, with FED instructions. I think this inheritance made no sense and probably was a bug.
If it wasn't we can also overload the tryReplaceWithFederated() here.
src/main/java/org/apache/sysds/runtime/instructions/fed/AggregateBinaryFEDInstruction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/fed/AggregateBinaryFEDInstruction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/fed/MMChainFEDInstruction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/sysds/runtime/instructions/fed/TsmmFEDInstruction.java
Outdated
Show resolved
Hide resolved
|
As a side note, when I ran all the tests the following testcases fail, but work when executed in isolation:
I remember that this is a known problem. |
352adb3 to
3bdf394
Compare
Yes this is known. You can run your tests such that they repeat if failing, there you will detect these "flaky" tests. mvn clean compile test -Dmaven.test.skip=false -Drerun.failingtests.count=1 -D automatedtestbase.outputbuffering=true -Dtest=org.apache.sysds.test.$@ |
I am not sure if this is the best location to edit. |
|
You have a point there, I also realized this recently when trying to also replace SP Instructions without duplicating code. I will weigh the options, if I come up with more, but will most likely opt to replace it already during parsing. Edit: this actually is not that simple, as we create our instructions before we get the runtime information if an object is federated AFAIK. Note that federated instruction compilation exists by now, but this is about a runtime decision. I will search for a smooth approach, currently only interfaces come to mind, but would like to find something better. |
You are right, it is not that simple but try to prioritize a good extensible design and then we can expand upon it. |
|
Sure, that is the number one priority of this rework, that is why I also would like to remove the dependency for the string representations of those instructions to be similar/matching. |
|
After a lot of consideration I propose the following:
|
|
Thanks for getting started on this issue @kev-inn. Unfortunately, I think the PR goes a bit in the wrong direction. We first want to do a basic cleanup of the federated instructions, without modifying the CP or Spark instructions. The replace in In a second step, we would remove the replicated instructions like In a third step, we then extend the federated workers to (under certain conditions) create a hop that represents the CP instruction and generate lops and instructions as needed (e.g., CP, Spark, GPU). Sorry, if I was not clear during our offline discussions. |
|
(Just because i regret deleting it -- i wrote this while you commented Matthias) I suggest that you make the methods inside CP and SP instructions part of a interface that allows any instruction to change to FED, and then make the footprint of these functions as small as possible inside each of the CP and SP instructions. All of these instructions should call into the fitting FEDInstructions class that then handle the logic of converting the instructions to FEDInstructions though static constructors that can return null. This design addresses all 3 points with (i think) the least amount of code. -- Comment to Matthias's point We are missing one step where we can avoid the whole FEDInstructionUtils code with casting that Kevin i think correctly is addressing in some of in his changes, where we can remove the entire if else tree if we add a interface method that simply map to the static constructors in your step 1. |
No worries, as @Baunsgaard stated, I think the majority of this PR is still a nice addition and it fits your first step nicely. I would like to have 2/3 methods:
EDIT: Method names can be changed, please feel free to give your opinion |
|
I am sorry that this PR got so large. I believe it is better to do it in one go, but I can also break it down so the review is faster. I recommend to open the old |
|
Not ready for review, found some problems with the spark instructions. |
|
|
2d97961 to
45271b1
Compare
45271b1 to
f527f82
Compare
- Refactor replacement with FED instructions - Fix FED output flag removal Closes apache#1680 Closes apache#1628
|
Closing to begin the merging phase, Thanks for the contribution @kev-inn |
- Refactor replacement with FED instructions - Fix FED output flag removal Closes #1628
- Refactor replacement with FED instructions - Fix FED output flag removal Closes apache#1628
This reworks our runtime replacement of CP instructions with FED versions when appropriate.
SP replacement will be done in another PR.
This implementation was my second approach, the first one consisted of static methods in the FED instructions. I much prefer this one as it is quite clear which instructions are replaced, which constraints the CP imposes and we don't have to lead every check with an
instanceofcheck. The downside of this approach is that it can get a bit confusing with inheritance, but it is---and will probably stay---manageable.Note that not everything is replaced yet, I will work on it while the general approach can already be reviewed.
During the testing I found myself requiring to check if actual FED instructions are executed, is there a way to ensure this in the test framework, or is this already ensured in some way via privacy? Tests checking the heavy hitters do it implicitly.
NOTE: I deleted a fix in
QuantilePickCPInstruction(bf19244), as the common layout is no longer necessary and null is cleaner. This is intentional and the fix is no longer necessary.