`test_rrule`: also check output tangents with thunked fields
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- testing
調査の方向性
Start with test_rrule and the existing check_thunked_output_tangent option, which currently calls the pullback with only the outer output tangent thunked. Reproduce the failure by wrapping each field of a Tangent output in a thunk and calling the pullback, as in the findnz example. Done means the new check runs for Tangent, Tuple and NamedTuple outputs, and that the unthunked and thunked results match. Decide with a maintainer whether to reuse the existing flag or add a new one.
索引モデルが issue の本文から書いたものです。
説明
check_thunked_output_tangent=true only checks the pullback with the whole output tangent thunked, i.e. pullback(@thunk(ȳ)). But AD systems also pass structural tangents whose fields are thunks. For example, Zygote's tuple getindex adjoint keeps thunks, so for f(x)[i] the rule receives Tangent{Any}((ZeroTangent(), …, thunk, …)).
Rules that handle the outer thunk correctly can still fail on this. In JuliaDiff/ChainRules.jl#843, the findnz rule passed test_rrule, but with Zygote it failed:
using SparseArrays, Zygote
Zygote.gradient(A -> sum(findnz(A)[3]), sprand(5, 5, 0.4))
# MethodError: no method matching sparse(::Vector{Int64}, ::Vector{Int64}, ::InplaceableThunk{...}, ::Int64, ::Int64)
The pullback destructured _, _, V̄ = unthunk(Δ). Destructuring a Tangent does not unthunk its fields, unlike getindex/getproperty (see JuliaDiff/ChainRulesCore.jl#712).
Proposal: when the output tangent ȳ is a Tangent, or a Tuple/NamedTuple that is converted to one, test_rrule should additionally call the pullback with every field wrapped in a thunk, e.g. Tangent{P}(map(x -> @thunk(x), backing(ȳ))...), and compare the result with the unthunked cotangents. This could reuse the existing check_thunked_output_tangent flag or get a new one.
- 主要言語
- Julia
- スター
- 50
- フォーク
- 18
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
JuliaDiff/ChainRulesTestUtils.jl のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
JuliaDiff/ChainRulesTestUtils.jl#148 · リアクション 1 件 ·
-
use DocThemeIndigoオープンdocumentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
mutation
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
JuliaDiff/ChainRulesTestUtils.jl の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
oscar-system/GAP.jl#1455 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
JuliaAI/MLJTransforms.jl#85 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
SciML/OrdinaryDiffEq.jl#4875 ·
メンテナーはふだん 4 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
SciML/NonlinearSolve.jl#1372 ·
メンテナーはふだん 1 日以内に返信