Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Fix from #44 to work with CUDA arrays Does Not Work in Latest Version

未关闭
#93 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
julia
领域
hpc

调研方向

使用 Julia 1.11.3、TaylorDiff v0.3.1 和 CUDA v5.6.1 重现 MWE,然后检查 TaylorDiff 的 derivative.jl 中 make_seed 和 derivatives 附近的代码。将当前行为与 PR #44 进行比较,并确定为什么 CUDA 广播会到达不受支持的动态调用。当所示的方向导数能够使用 CuArray 输入正常工作时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Issue: Regression – Fix from #44 Does Not Work in Latest Version

Description

The fix implemented in PR #44 appears to no longer work in the latest version of TaylorDiff.jl.

This MWE:

v, direction = CuArray([0f0, 0f0]), CuArray([1.0f0, 0.0f0])
derivative(x -> sum(exp.(x)), v, direction, 2) # directional derivative

gives:

ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#gpu_broadcast_kernel_linear#38")(::KernelAbstractions.CompilerMetadata{…}, ::CuDeviceVector{…}, ::Base.Broadcast.Broadcasted{…}) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to make_seed)
Stacktrace:
 [1] _broadcast_getindex_evalf
   @ ./broadcast.jl:678
 [2] _broadcast_getindex
   @ ./broadcast.jl:651
 [3] getindex
   @ ./broadcast.jl:610
 [4] macro expansion
   @ ~/.julia/packages/GPUArrays/Mot2g/src/host/broadcast.jl:54
 [5] gpu_broadcast_kernel_linear
   @ ~/.julia/packages/KernelAbstractions/mD0Rj/src/macros.jl:97
 [6] gpu_broadcast_kernel_linear
   @ ./none:0
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.jl
Stacktrace:
  [1] check_ir(job::GPUCompiler.CompilerJob{GPUCompiler.PTXCompilerTarget, CUDA.CUDACompilerParams}, args::LLVM.Module)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/validation.jl:167
  [2] macro expansion
    @ ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:382 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/TimerOutputs/6KVfH/src/TimerOutput.jl:253 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:381 [inlined]
  [5]
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/utils.jl:108
  [6] emit_llvm
    @ ~/.julia/packages/GPUCompiler/Nxf8r/src/utils.jl:106 [inlined]
  [7]
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:100
  [8] codegen
    @ ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:82 [inlined]
  [9] compile(target::Symbol, job::GPUCompiler.CompilerJob; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:79
 [10] compile
    @ ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:74 [inlined]
 [11] #1147
    @ ~/.julia/packages/CUDA/1kIOw/src/compiler/compilation.jl:250 [inlined]
 [12] JuliaContext(f::CUDA.var"#1147#1150"{GPUCompiler.CompilerJob{…}}; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:34
 [13] JuliaContext(f::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/driver.jl:25
 [14] compile(job::GPUCompiler.CompilerJob)
    @ CUDA ~/.julia/packages/CUDA/1kIOw/src/compiler/compilation.jl:249
 [15] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(CUDA.compile), linker::typeof(CUDA.link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/execution.jl:237
 [16] cached_compilation(cache::Dict{…}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{…}, compiler::Function, linker::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Nxf8r/src/execution.jl:151
 [17] macro expansion
    @ ~/.julia/packages/CUDA/1kIOw/src/compiler/execution.jl:380 [inlined]
 [18] macro expansion
    @ ./lock.jl:273 [inlined]
 [19] cufunction(f::GPUArrays.var"#gpu_broadcast_kernel_linear#38", tt::Type{…}; kwargs::@Kwargs{…})
    @ CUDA ~/.julia/packages/CUDA/1kIOw/src/compiler/execution.jl:375
 [20] macro expansion
    @ ~/.julia/packages/CUDA/1kIOw/src/compiler/execution.jl:112 [inlined]
 [21] (::KernelAbstractions.Kernel{…})(::CuArray{…}, ::Vararg{…}; ndrange::Tuple{…}, workgroupsize::Nothing)
    @ CUDA.CUDAKernels ~/.julia/packages/CUDA/1kIOw/src/CUDAKernels.jl:103
 [22] _copyto!
    @ ~/.julia/packages/GPUArrays/Mot2g/src/host/broadcast.jl:71 [inlined]
 [23] copyto!
    @ ~/.julia/packages/GPUArrays/Mot2g/src/host/broadcast.jl:44 [inlined]
 [24] copy
    @ ~/.julia/packages/GPUArrays/Mot2g/src/host/broadcast.jl:29 [inlined]
 [25] materialize
    @ ./broadcast.jl:872 [inlined]
 [26] broadcast(::typeof(TaylorDiff.make_seed), ::CuArray{…}, ::CuArray{…}, ::Int64)
    @ Base.Broadcast ./broadcast.jl:810
 [27] make_seed
    @ ~/.julia/packages/TaylorDiff/hFSFr/src/derivative.jl:5 [inlined]
 [28] derivatives
    @ ~/.julia/packages/TaylorDiff/hFSFr/src/derivative.jl:41 [inlined]
 [29] derivative(f::Function, x::CuArray{Float32, 1, CUDA.DeviceMemory}, l::CuArray{Float32, 1, CUDA.DeviceMemory}, p::Int64)
    @ TaylorDiff ~/.julia/packages/TaylorDiff/hFSFr/src/derivative.jl:17
 [30] top-level scope
    @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

Additional Information
Julia Version: 1.11.3
TaylorDiff Version: v0.3.1
Zygote Version: v0.6.75
CUDA Version v5.6.1

主要语言
Julia
星标
83
派生
12
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaDiff/TaylorDiff.jl 的其他 Issue

查看 JuliaDiff/TaylorDiff.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。