JuliaDiff / JuliaDiff/ChainRulesCore.jl

Consider handling rrules for kwargs differently?

Open
#384 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
267
Forks
66
PR merge metrics
No merged PRs in 30d

Description

The lowering for a call like:

f(args...; kwargs...)

is

Core.kwfunc(f)(kwargs, args...)

By the usual rules of rrule invocation, the rrule for this call is:

rrule(Core.kwfunc(f), kwargs, args...)

However, this misses the rrules we define here, which instead expect:

Core.kwfunc(rrule)(kwargs, f, args...)

This is not forces every AD system to have special case rules for detecting kwcalls of this sort, which is non-trivial.
An alternative would be to make the rrule(Core.kwfunc(f), kwargs, args...) call primitive, though of course that would require changing the user-facing way to write rrules. This could then be fixed with a macro, but of course ChainRules currently does not use a macro for regular rrule/frule definitions... Neither alternative is particularly pleasant, but I figured I'd open this for discussion.

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 by tracing the lowering of calls shaped like f(args...; kwargs...) and compare it with the existing Core.kwfunc rrule definitions described in the issue. Review how regular rrule and frule definitions are represented, then determine which API behavior or lowering rule should change; the issue does not define a settled implementation or completion test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.