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

[AD] Fix missing masks on symbolic calls inside loops #338

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

njroussel
Copy link
Member

When running AD through evaluated-mode loops, any dynamic dispatch will not have the loop's mask applied.

This PR fixes this issue by saving the loop's mask (top of the mask stack) at the time of tracing the dynamic dispatch into the CallOp custom operation. This allows the custom operation to then apply that saved masked whenever it gets traversed.

Without this patch, the issue would typically manifest itself as a CUDA error or segfault during kernel execution. Typically, lanes that should have been masked were accessing out-of-bounds memory.

A regression test was added in test_switch.py::test18_apply_loop_mask.

When the `CallOp` node is traversed in forward/reverse-mode it is possible that the mask stack no longer matches what it was during the initial tracing. The `CallOp` therfore stores an extra reference to the mask at the top of the mask and applies it when it is traversed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant