-
Notifications
You must be signed in to change notification settings - Fork 63
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
Fix is_complete_for check #587
Conversation
@manopapad @aschaffer thanks for catching this bug. It's my fault to assume comparison between tuples to be element-wise.
Note that completeness of a partition symbol is a constraint on the partition and not a command to the solver. It's perfectly fine to pass a complete partition to a place where an incomplete partition is expected (the inverse isn't true though). That said, the solver currently doesn't check if the solution for a given partition symbol abides by the completeness constraint, though I should and will add it at some point.
Let's change |
I tried removing the definitions of all inequality comparisons from
I don't like this, for two reasons. First and less importantly, this would make I would rather we define proper CCing @bryevdv for his opinion too. |
I don't have all the context, but return all(a <= b for (a, b) in zip(my_lo, offsets)) and all(
a <= b for (a, b) in zip(offsets + extents, my_hi)
) is pretty tedious and verbose, and not very expressive of the fact that some kind of higher level comparison is happening between |
An alternative is to have |
@magnatelee is suggesting we simply use the built-in
However, I am a little worried about this solution, because this would imply:
so IMHO this is breaking the principle of least surprise. I would instead suggest an explicit "elementwise" comparison function (naming & placement TBD). |
I agree with the principle. However, in this particular case I think there is (justifiably) a high risk of confusion. The class is named "shape", which is bound to be conflated with a NumPy shape, which is an actual tuple. Moreover, a lot of the time we are initializing a
That's a better solution, I can proceed with that. |
Just noting that in case someone forgets to do if all(s1 <= s2): # if all((True, False, True....)): [False] and instead does (the IMO more typical) if s1 <= s2: # if (True, False, True....): [Truthy] then the comparison will nearly always return True. |
Will mypy flag it as an error? |
I don't see why it would, it's perfectly valid (if not useful) to do
|
I think we can return our own container where |
That's fair, but I'd blame inherent ambiguity in the comparison operators defined to return a single boolean. Except for the unfortunate naming collision with ndarray.shape, there's nothing in
See my comment about a custom boolean container. We could do it if we want to avoid all footguns.
I believe when an object |
I went ahead and implemented the approach of returning a tuple-like of bools, guarding that Assuming that this is a core-internal API, I just used asserts to signal misuse, but happy to switch to something else if you guys prefer.
We need two types of subsumes, |
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.
I think a proper compare API would be nicer, but if users aren't really expected to be comparing shapes this seems OK at least for the short term to get some guardrails in the next release.
This is the underlying issue behind nv-legate/cunumeric#721 (comment). Thanks to @aschaffer for doing most of the work to uncover this.
The error in the original logic can be seen when running the following example:
with
LEGATE_TEST=1 CUNUMERIC_TEST=1 legate --cpus 3 --event --dataflow
, in which case legion spy verification fails with:The call to
is_complete_for
for the offending partition is misjudging it as complete. Here are the values in that call:@magnatelee please also take a look at the following potential related issues:
deferred.py:convolve
is settingPartSym.complete = False
, but this information is not honored when creating the partitions. Insteadis_complete_for
is consulted like normal.Shape
was used where an elementwise comparison was intended. It would be good to check any other uses of these operators, to confirm that this mixup isn't happening there too.