JuliaDiff / JuliaDiff/ChainRules.jl

Pullback for `tr` produces a CPU `Diagonal` causing downstream scalar indexing on GPUs

Open
#682 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue GPU
Dominant language
Julia
Stars
475
Forks
98
PR merge metrics
No merged PRs in 30d

Description

Functions like tr(A * B) will throw scalar indexing issues in the pullback for * when A and B are CuArrays. This is because the pullback for tr creates a Diagonal which will cause downstream matrix multiplies to hit the LinearAlgebra definition.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/rulesets/LinearAlgebra/dense.jl at the pullback for tr, then reproduce tr(A * B) with CuArray inputs to observe the scalar-indexing failure. Trace how the returned Diagonal reaches downstream matrix multiplication; done means the pullback works for GPU arrays without producing a CPU Diagonal or triggering scalar indexing.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.