-
Notifications
You must be signed in to change notification settings - Fork 61
Added dynamic-shape 0/1 bucketing: "zero_nonzero" env var #1053
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?
Added dynamic-shape 0/1 bucketing: "zero_nonzero" env var #1053
Conversation
…th in a diff way while 1 just goes >= 2 similar to already present '_tensor_key' logic & this can be turned on with an environment variable 'HELION_SHAPE_BUCKETING' that default to 'min2', and disables 0/1 when using 'zero_nonzero'.
|
Hi @Itssshikhar! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
please rebase to main and make sure the lint is passing, and move your PR from draft to ready for review when you're ready |
|
Appreciate the comments. I've rebase the main to this branch and lint seems to be passing. Let me know if there is anything else. |
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 fixes the bucketing that happens inside the kernel.py specialization key, but I think it may have some correctness issues because there is still similar shape bucketing coming from ShapeEnv/FakeTensors (which are part of PyTorch). So the code the is generated may not be shape agnostic, but this will cause it to be used as if it is.
You should be able to surface this issue by adding tests that:
- Run the full kernel with varying 1-ness of shapes
- Inspect the generated output code (via assertExpectedJournal) so you can see if shape specialization is happening.
Resolves #934
Used a zero-nonzero specialization in which 0 is kept distinct while 1 just goes >= 2 similar to already present '_tensor_key' logic & this can be turned on with an environment variable 'HELION_SHAPE_BUCKETING' that defaults to 'min2' (current behavior: bucket dims are 0, 1, >=2), and disables 0/1 when using 'zero_nonzero'. Kept 0 as a separate bucket to deal with zero-numel edge cases. Added test for the same as well.