checktag's permissive fallback silently disables tag checking (e.g. for derivative(f!, y, x, cfg))
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 50/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 領域
- tooling
調査の方向性
まず checktag メソッドと derivative/derivative! の呼び出し箇所から始め、その動作を gradient の InvalidTagException パスと比較します。scalar な derivative 呼び出しで、誤った関数用の DerivativeConfig が拒否され、documented nothing とカスタムタグの動作が考慮されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
A DerivativeConfig built for one function is silently accepted by another, so derivative(f!, y, x, cfg) gets no perturbation confusion protection at all:
julia> a!(y, x) = (y .= sin(x)); b!(y, x) = (y .= cos(x));
julia> y = Vector{Float64}(undef, 2);
julia> cfg = ForwardDiff.DerivativeConfig(a!, y, 0.0);
julia> ForwardDiff.derivative(b!, y, 0.0, cfg) # cfg belongs to a!, no complaint
2-element Vector{Float64}:
-0.0
-0.0
gradient does raise InvalidTagException in the analogous situation. This reproduces with a real y on master, so it is unrelated to complex support.
The immediate cause is that every non-fallback checktag method requires x::AbstractArray:
checktag(::Type{Tag{FT,VT}}, f::F, x::AbstractArray{V}) where {FT,VT,F,V} = throw(InvalidTagException{...}())
checktag(::Type{Tag{F,V}}, f::F, x::AbstractArray{V}) where {F,V} = true
while derivative/derivative! call checktag(T, f!, x) with a scalar x. Dispatch lands on the catch-all checktag(z, f, x) = true, so the check argument of derivative(f!, y, x, cfg, Val{true}()) has no effect.
Adding scalar counterparts of those two methods fixes this particular case, but the more interesting question is whether the permissive checktag(z, f, x) = true default should stay. As it stands, any signature that does not match a specific method silently opts out of checking, which is how this gap went unnoticed -- the failure mode is "no error", not "no method". Defaulting to rejection and explicitly accepting only validated tags would make such gaps loud instead of silent.
Two things to note for anyone attempting that:
- The return value is currently discarded -- every call site is
CHK && checktag(...), andchecktagworks purely by throwing. So flipping the default tofalseon its own changes nothing; the call sites would have to throw on afalseresult. Nothingneeds to be accepted explicitly, since anothingtag is documented as usable with any target function. Custom tag types currently pass via the same fallback ("custom tag: you're on your own"), so rejecting by default would be breaking for them unless they opt in by definingchecktagfor their tag type -- arguably the point, but worth a deprecation path.
- 主要言語
- Julia
- スター
- 1k
- フォーク
- 162
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
JuliaDiff/ForwardDiff.jl のほかの issue
-
missing floatmin, floatmax, and issubnormal for Dual対応中かも @devmotion が 18 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
JuliaDiff/ForwardDiff.jl#852 · コメント 6 件 ·
-
`fma` and `muladd` ignore NaN-safe mode対応中かも @devmotion が 4 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
JuliaDiff/ForwardDiff.jl#860 ·
-
Enable NaN-safe mode by default対応中かも @devmotion が 5 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
JuliaDiff/ForwardDiff.jl#857 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
JuliaDiff/ForwardDiff.jl#854 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 75/100
JuliaDiff/ForwardDiff.jl#849 ·
JuliaDiff/ForwardDiff.jl の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
WaterLily-jl/WaterLily.jl#367 ·
メンテナーはふだん 1 日以内に返信
-
R_to_gamma and R_to_v are wrong for |Z| != 1 (e.g. heavy ions)対応中かも @DavidSagan が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
bmad-sim/BeamTracking.jl#366 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
SciML/PETScDiffEq.jl#277 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 半日 初心者へのやさしさ 82/100
-
SavedSubsystem with an integer save_idxs maps the index the wrong way round対応中かも @ChrisRackauckas が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SciML/SciMLBase.jl#1643 ·
メンテナーはふだん 2 日以内に返信