Repository navigation
Shorten the gradient_routes docstring - #937
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwC7ixq96xKm28ZGGUH98w
There was a problem hiding this comment.
The PR only rewords the gradient_routes docstring in src/adjoints/adjoints.jl. The rewording is shorter, but it drops the note that the method needs ADTypes and DifferentiationInterface. The title also promises a comparison report that the diff does not contain.
Detail
The diff touches one file and changes only the docstring. The title says it will "report the redesign's comparison", but no report, benchmark output or doc page is added. Either the description is inaccurate or that part of the change is missing from the head. The docstring edit has no code or test effect. I did not check whether the doctest or the extension is affected, because CI covers both.
About this review
Automated first pass by seabbs-review-bot (Claude sonnet), triggered by: first pass. Not a human review. Comment @seabbs-review-bot to ask for another pass: @seabbs any time, the author's agent once it has pushed changes. Add the no-review label to opt this PR out. Ping @seabbs with any questions.
| Before any time is taken, each `step_pullback` must pass the `step` | ||
| component of [`ComposableRecurrences.PieceInterface`](@ref) and | ||
| [`ComposableRecurrences.test_adjoint`](@ref), where `backend` has a method. | ||
| The gradients of the routes must then agree at `rtol`, and a failed check |
There was a problem hiding this comment.
suggestion Restore the note that the method needs ADTypes and DifferentiationInterface loaded.
Why and how to fix
gradient_routes is a bare function gradient_routes end (line 519), so the method only exists once those two packages are loaded. The removed paragraph "The method is defined when ADTypes and DifferentiationInterface are loaded." was the only prose that said so. The using line in the example now carries that fact implicitly. A reader who calls it without them gets a MethodError and no pointer to the cause. Put the sentence back after the check paragraph. It is one line, so the docstring stays short.
There was a problem hiding this comment.
|
|
||
| The method is defined when `ADTypes` and `DifferentiationInterface` are | ||
| loaded. | ||
| Before any time is taken, each `step_pullback` must pass the `step` |
There was a problem hiding this comment.
suggestion Say what the step check is run at, and reword the ambiguous test_adjoint clause.
Why and how to fix
The old text said each step_pullback is checked against step "at the first outputs and the starting state". The new text drops this, so the reader cannot tell which inputs the check uses. "must pass the step component of PieceInterface and test_adjoint, where backend has a method" is also unclear. It is not obvious that the clause qualifies only test_adjoint. Suggested wording: "Before any time is taken, each step_pullback must agree with the step component of PieceInterface at the first outputs and the starting state. It must also pass test_adjoint where backend has a method."
There was a problem hiding this comment.
Done: the paragraph says the step check runs at the first outputs and the starting state, and test_adjoint has its own clause.
Generated by Claude Code
| Before any time is taken, each `step_pullback` must pass the `step` | ||
| component of [`ComposableRecurrences.PieceInterface`](@ref) and | ||
| [`ComposableRecurrences.test_adjoint`](@ref), where `backend` has a method. | ||
| The gradients of the routes must then agree at `rtol`, and a failed check |
There was a problem hiding this comment.
note Confirm whether the comparison report named in the title is meant to be in this PR.
Why and how to fix
The title says "report the redesign's comparison", but the only change is the docstring. If a report, benchmark output or docs page was intended, it is missing from the head. If not, change the title and description to match what the diff does.
There was a problem hiding this comment.
The report is the PR description only, by design: the result files and figures are kept on the branch claude/benchmark-results so that main holds no history of runs. The title now names only the code change.
Generated by Claude Code
Follow-up to #926.
The only change to
mainis a shortergradient_routesdocstring: what it computes with its formula, the routes, the checks in two sentences, arguments, returns and one example.The rest of this description reports the comparison #926 was built to make.
Its result files and figures are not in this PR: they are on the branch
claude/benchmark-results, somainholds no history of runs.Redesign against the earlier
mainbenchmark/ab.jl, candidate f1d5fd6 (the head of #926) against base 7b6a4ee (mainbefore #907).Seven cases of the
citier at T 200, L 20, six targets, three rounds, one process at a time on a 4-core cloud VM with nothing else running.The full report and its rows are in
benchmark/results/ab-7b6a4ee-f1d5fd6/onclaude/benchmark-results.rulearm, the operator as users call it, is outside its band on any target.overviewunderNoAdjoint: 1.39× against a ±21% band, in all three rounds.Two fresh processes of the same commit differ by 3% to 8% at the median and by up to 1.8×.
This run cannot see a change under about 20%; the same command on a quiet desktop will give a narrower band.
Candidate time over base time,
rulearm, median of three rounds (below one the redesign is faster; every cell is within noise):The package against hand-written code
Time of the package's
rulearm over the named arm's, in the candidate (below one the package is faster).(n)marks a ratio within the noise of that ratio between the two base runs.loop,accumulateandcopy loopare hand-written loops,handrulea hand-written loop with hand-written Mooncake rules, andNoAdjointplain AD of the operator.The band of these ratios is wide, ×1.2 to ×1.6 by target, because the allocating baselines differ most between processes.
A ratio such as 0.27 for
conv_fixedon the primal is marked(n)because therulearm of the base ran 1.7× slower in one of its six processes.On the reverse modes the rule is 2 to 30 times faster than a hand-written loop, apart from the 30-step random walk where the two are level, and 1.4 to 7 times faster than plain AD of the operator.
It is level with the two hand-written Mooncake rules, 0.75× and 1.17×, both within noise.
On the forward modes the rule and
NoAdjointrun the same code and are level.Figures
benchmark/figures.jlwrote five figures todocs/src/assets/benchmarks/onclaude/benchmark-results, for the performance page, which the docs session owns:revisions.svg: candidate over base for eachrulecell, on its A/A band.hand_written.svg: the package over each hand-written arm.rule_gain.svg: the rule over plain AD on the reverse modes.routes.svg:gradient_routeson the modifier ofbenchmark/docs_modifier.jl:step_pullback, local derivative and plain AD.devices.svg: the rule's passes against the number of strata onArray,JLArrayand OpenCL through pocl.Their only inputs are two small files,
ab.tsv(30 kB) androutes.tsv, so a docs build can draw them withjulia --project=docs benchmark/figures.jl DIRafter fetching those files from the results branch.Device numbers
From
benchmark/results/routes.tsv, the rule's forward and reverse pass at T 200, L 20, in µs:There is no GPU on the machine or in CI.
JLArrays run device code as Julia on the host and pocl compiles the same kernels for the CPU, so these times show the fixed cost of launching kernels and the scaling in strata.
They say nothing about the speed on a GPU, which is not measured.
First suite run
julia benchmark/suite/run.jl --store=benchmark/results/suiteat commit 4874575, two repeats, five targets (Enzyme forward left out because of the crash below), the same seven cases, 48 minutes.The run and its
history.htmlare underbenchmark/results/suite/onclaude/benchmark-results.Fastest time of the
rulearm over the two repeats:Noise band between the two repeats: ±17% to ±27% by target.
Not run, and known limits
citier were timed, to keep three rounds within about four hours.accumulatebaseline ofstrata_mixingordelay_fixed.It has eight cells from the rows written before each crash; the crash is in a baseline, not in package code, and is not investigated here.
mainwas not run: the two are the same source since the merge.localarm is absent from these cases: under the pure step it runs only for cases whose modifiers have their ownstep_pullback.claude/benchmark-results, this session's own branch, and not on abenchmark-resultsbranch: this session's task lets it push only to its own branch, so creating that branch is left to the owner.Generated by Claude Code