Incorrect Gradient Computation when Nesting Zygote over TaylorDiff Description
还没有人认领这个 Issue。
评估
调研方向
首先使用报告中的 Julia、TaylorDiff 和 Zygote 版本运行最小示例,重点关注嵌套在 Zygote.gradient 中的 TaylorDiff.derivative。跟踪这些入口点之间的交互,并为该示例添加回归测试。当计算出的梯度不再全为零,并且与预期的非零结果一致时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Bug Report: Incorrect Gradient Computation when Nesting Zygote over TaylorDiff
Description
When attempting to compute the gradient of a function that internally uses TaylorDiff for differentiation, Zygote returns incorrect results (all zeros).
Minimal Working Example
The following mwe demonstrates the issue:
import TaylorDiff
import Zygote
# Define a function
f(x) = sum(x .^ 2)
# Define function to return unit vectors
unit_vectors(x, i) = [j == i ? one(eltype(x)) : zero(eltype(x)) for j in 1:length(x)]
# Define input
x = Float64.(collect(1:5))
# Compute unit vectors for each direction to compute the gradient
e_vectors = [unit_vectors(x, i) for i in 1:length(x)]
# Define a function to compute gradient using TaylorDiff
∇f_taylor(f, x) = TaylorDiff.derivative.(Ref(f), Ref(x), e_vectors, Ref(Val(1)))
# Evaluate gradient
∇f_taylor(f, x) # Returns 5-element Vector{Float64}: 2.0 4.0 6.0 8.0 10.0 (correct)
# Define a simple function of the gradient with TaylorDiff
g_taylor(x) = sum(∇f_taylor(f, x))
# Evaluate gradient
g_taylor(x) # returns 30.0 (Correct)
# Compute gradient using Zygote
Zygote.gradient(g_taylor, x) # returns ([0.0, 0.0, 0.0, 0.0, 0.0],) (incorrect)
The function g_taylor(x) computes the sum of the gradient of f(x), which should return a nonzero result. Applying Zygote.gradient to g_taylor(x) should correctly compute the derivative.
Instead of returning the correct gradient, Zygote.gradient(g_taylor, x) returns all zeros.
Additional Information
Julia Version: 1.11.3
TaylorDiff Version: v0.3.1
Zygote Version: v0.6.75
- 主要语言
- Julia
- 星标
- 83
- 派生
- 12
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaDiff/TaylorDiff.jl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
JuliaDiff/TaylorDiff.jl#103 · 6 条评论 ·
-
难度 4/5 3-5 天 新手友好度 38/100
JuliaDiff/TaylorDiff.jl#102 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 38/100
JuliaDiff/TaylorDiff.jl#99 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
JuliaDiff/TaylorDiff.jl#95 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
JuliaDiff/TaylorDiff.jl#93 ·
查看 JuliaDiff/TaylorDiff.jl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
rfordatascience/tidytuesday#1098 ·
-
`SplitRungeKutta` time steppers never call `update_lagrangian_particle_state!`, so particle `tracked_fields` are never updated可能已有人在做 @ali-ramadhan 今天认领。 未关闭bug 🐞
难度 2/5 1-3 小时 新手友好度 76/100
CliMA/Oceananigans.jl#6381 ·
维护者通常 1 天内回复
-
ci system:windows test
难度 1/5 1 小时以内 新手友好度 76/100
维护者通常 1 天内回复
-
Single-column TKE example: boundary-layer depth description doesn't match Han & Bretherton (2019)未关闭
难度 1/5 1-3 小时 新手友好度 82/100
NumericalEarth/Breeze.jl#1143 ·
维护者通常 1 天内回复
-
format-check (Runic) is red on master: formatter drift on ~200 files可能已有人在做 @ChrisRackauckas-Claude 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
SciML/ModelingToolkit.jl#5337 · 1 条评论 ·
维护者通常 3 天内回复