JuliaDiff / JuliaDiff/ChainRulesCore.jl

Why is composite + primal test allocating 48 bytes rather than 32?

Open
#146 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Looks fine (on julia 1.4)

julia> bk
(x = 1, y = 0.5)

julia> @btime Foo($(bk)...)
  7.639 ns (1 allocation: 32 bytes)
Foo(1, 0.5)

julia> ChainRulesCore.construct(Foo, bk)
Foo(1, 0.5)

julia> @btime ChainRulesCore.construct($Foo, $bk)
  7.502 ns (1 allocation: 32 bytes)

But the tests:

https://github.com/JuliaDiff/ChainRulesCore.jl/blob/1be9bc4b5985896b0549cd278681bc41d06869ec/test/differentials/composite.jl#L180-L182

Originally posted in https://github.com/_render_node/MDIzOlB1bGxSZXF1ZXN0UmV2aWV3VGhyZWFkMjQ3NDY4MTg1OnYy/pull_request_review_threads/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 reproducing the allocation benchmark under Julia 1.4, then inspect test/differentials/composite.jl around lines 180-182. Compare the test's construction path with the shown Foo and ChainRulesCore.construct benchmarks. Done means identifying the reason for the 48-byte result and making the test's expectation accurately reflect the supported behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.