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

Add safe mode #55

Merged
merged 4 commits into from
May 14, 2024
Merged

Add safe mode #55

merged 4 commits into from
May 14, 2024

Conversation

willtebbutt
Copy link
Contributor

@willtebbutt willtebbutt commented May 14, 2024

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Tapir.jl now has a "safe mode", in which lots of additional type checking is performed, in addition to some value checks. I would like to enable it by default (I'll be adding @info calls on the Tapir end to make it clear to users that they're using safe mode). This is to ensure that users are aware of this feature, which often makes debugging a lot easier, and can pick up on issues before they propagate to some arbitrary point further on in the code.

Provided that people are happy with this, if someone could advise on the appropriate version bump for this package I would appreciate it.

@gdalle
Copy link
Collaborator

gdalle commented May 14, 2024

Would it make sense for it to be a type parameter with two possible values, instead of a field? In other words, does it bring any benefit to have that information statically available?

Copy link

codecov bot commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d749b5a) to head (00985ad).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #55   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines           64        65    +1     
=========================================
+ Hits            64        65    +1     
Flag Coverage Δ
docs ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@willtebbutt
Copy link
Contributor Author

Good question.

It shouldn't matter for performance, because whether or not a rule operates in safe mode is baked in when you call build_rrule (extra code is injected during codegen to check pre- and post-conditions of every call to a rule that happens inside a derived rule on both the forwards and reverse passes -- this is propagated through the entire compiled function so that everything gets checked).

On a practical level, (I think) adding type parameters would technically be breaking, so it would be good to avoid if possible.

@gdalle
Copy link
Collaborator

gdalle commented May 14, 2024

Okay then you can bump the minor version and I'll merge this

@willtebbutt
Copy link
Contributor Author

Great, thanks!

test/dense.jl Outdated Show resolved Hide resolved
@gdalle
Copy link
Collaborator

gdalle commented May 14, 2024

Tests only fail due to codecov throttling, merging now

@gdalle gdalle merged commit 3d4e912 into SciML:main May 14, 2024
4 of 5 checks passed
@willtebbutt willtebbutt deleted the wct/tapir-safe-mode branch May 14, 2024 11:27
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.

2 participants