Repository navigation
Remove bad non-differentiable - #604
Conversation
|
Looks like this currently causes some downstream issues -- will attempt to isolate the particular rules that we need to keep Zygote and Diffractor tests passing. |
|
Diffractor never passes. Zygote failures are things like this: for which the immediate fix is that there should be rules something like |
|
This seems suprising since the PR does not touch Edit: Ah, probably |
|
Yes, the method is: If we allow I'd rather not have any of these mutating functions, but removing them might break too many things. |
|
Stumbled on this after a long dive (w/ help from Zack Li and Brian Chen on Slack) trying to understand this incorrectly dropped gradient: gradient(σ -> sum(rand(Xoshiro(1), MvNormal(zeros(2), σ*I))), 1) # nothingConversely, with this PR, instead of dropping it, you (correctly) get an error since the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #604 +/- ##
=======================================
Coverage 96.57% 96.57%
=======================================
Files 28 28
Lines 3618 3618
=======================================
Hits 3494 3494
Misses 124 124 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ers (#855) * Restrict non-differentiable rand rules to data-free and integer samplers `@non_differentiable rand(::AbstractRNG, ::Random.Sampler)` matched every sampler, including the ones that sample from arrays, tuples, non-integer ranges and dictionaries. Zygote therefore silently returned `nothing` for e.g. `gradient(x -> rand([x]), 1.0)` instead of 1.0. The rule now only covers samplers whose output does not depend on any differentiable data (types, float intervals, BigFloat, Base strings and Char arrays) and samplers for ranges of Base integer types, for both `rand` and `rand!`. The latter fixes #854 without reintroducing the over-wide `rand!` rules removed in #604. The forwarding rules for `rand`/`rand!` and `Random.randexp(::AbstractRNG)` are removed: they are reached via the sampler rules or subsumed by `randexp(::Any...)`. `randstring` is extended to all argument types since its output is always a `String`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Apply batched suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Resolves #603