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

Raise a NullMask() error for degenerate token masks #27

Merged
merged 2 commits into from
Feb 21, 2025
Merged

Conversation

gabegrand
Copy link
Collaborator

As discussed in #21, there are various scenarios in which token masking results in a LMTokenMask distribution that has a null support. The previous PR partially solved this problem by returning -inf, which avoided a cryptic ValueError message. However, this still results in an uncaught downstream exception the next time sample() or observe() is called, making it hard to localize the source of the error when debugging.

On further reflection, a complete solution to this problem would be to implement tracing -- minimally, for mask objects, but ideally at the level of the hfppl itself -- to make it possible to track sequences of stochastic events leading to errors. I think this is a potentially useful approach but would require deeper refactors to the library than I have bandwidth for at the moment.

In the spirit of keeping things simple for now, I think it makes sense to introduce a NullMask() error that gets raised when observing a degenerate mask. This has the sole purpose of providing a more descriptive error and a clear stack trace for what I've found to be a common corner case in hfppl programs.

@gabegrand gabegrand requested a review from alex-lew February 19, 2025 17:53
@gabegrand gabegrand merged commit d4d6325 into main Feb 21, 2025
1 check passed
@gabegrand gabegrand deleted the gg/null_mask branch February 21, 2025 21:00
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