Skip to content

Call the device kernel bodies from the host loops of the imports and movement pullbacks - #994

Merged
seabbs-bot merged 2 commits into
mainfrom
claude/host-loops-share-bodies
Dec 2, 2026
Merged

seabbs-bot merged 2 commits into
mainfrom
claude/host-loops-share-bodies

Conversation

@seabbs-bot

Copy link
Copy Markdown
Collaborator

Part of #959 (finding 3).

The host pullback of an Allocate with imports restated, line for line, the per-group body the device kernel runs (_import_back!) and the frame around it (_device_imports_pullback!).
The two Redistribute pullbacks restated two per-stratum bodies (_redistribute_back_body!, _movement_swap!).
Each host loop now calls the shared body, as the forward steps of the same modifiers already do.

  • src/modifiers/allocate.jl: one _imports_pullback! holds the frame; the host and device methods pass it their pass over the groups. The host method still holds no device code.
  • src/modifiers/builtin.jl: the two host loops call the bodies.

19 lines added, 57 removed.
No public name changes; the arithmetic and its order are unchanged.
The bodies index under @inbounds where the host loops did not; the loops run over eachindex(v, v̄, s̄), so the indices are in bounds either way.

What was run

  • Unit items of test/unit/allocate.jl, builtin_modifiers.jl, pool_moves.jl: 1361 pass.
  • Unit items of test/unit/device_rules.jl (1063 pass) and gpu_arrays.jl (524 pass), on JLArrays.
  • Unit items of test/unit/adjoints.jl: 600 pass.
  • Interleaved harness (benchmark/ab.jl, 3 rounds, 1 s per cell) against origin/main at 89b8989, Mooncake reverse and Enzyme reverse:
tier cases cells faster slower within noise
ci bvd_patch, bvd_patches_call 18 0 0 18
realistic bvd_zones, zone_allocate 44 0 0 44

The rule arm, minimum-time ratio of candidate to base, median over rounds:

target case sizes ratio
Mooncake reverse bvd_patch S5 0.94
Mooncake reverse bvd_patches_call S1, S5 1.04, 0.99
Mooncake reverse bvd_zones 4 sizes 0.98 to 1.00
Mooncake reverse zone_allocate 4 sizes 0.87 to 0.98
Enzyme reverse bvd_patch S5 1.05
Enzyme reverse bvd_patches_call S1, S5 1.04, 1.00
Enzyme reverse bvd_zones 4 sizes 0.96 to 1.05
Enzyme reverse zone_allocate 4 sizes 1.00 to 1.03

The noise bands were ±15% to ±21% for Mooncake on the ci tier and wider elsewhere (±18% to ±57%), so these say "no change seen", not "equal".

What was not run

The full unit suite, the AD job items under test/ad, the Runic check, JET, the docs build, and any real GPU.
CI covers the first five.

Other work in flight

None of #922, #928, #954 or #955 touches src/modifiers/allocate.jl or src/modifiers/builtin.jl.


Generated by Claude Code

…movement pullbacks

The host pullback of an Allocate with imports restated the per-group body
the device kernel runs, and the frame around it; the Redistribute pullbacks
restated two per-stratum bodies. Each host loop now calls the shared body.

Claude-Session: https://claude.ai/code/session_01WwC7iyvV6w2KCcCWrZ46QL
@seabbs-bot
seabbs-bot requested a review from seabbs as a code owner December 2, 2026 12:07
seabbs-review-bot[bot]

This comment was marked as resolved.

@seabbs-review-bot seabbs-review-bot Bot added the llm-reviewed Reviewed by seabbs-review-bot label Dec 2, 2026
@seabbs-bot
seabbs-bot merged commit 52d2b0c into main Dec 2, 2026
17 of 27 checks passed
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Try this Pull Request!

Option 1: Julia Package Manager

Open Julia and type:

import Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/EpiAware/ComposableRecurrences.jl", rev="claude/host-loops-share-bodies")
using ComposableRecurrences

Option 2: Local Checkout

If you have the repo locally:

git checkout claude/host-loops-share-bodies
julia --project=. -e "using Pkg; Pkg.instantiate()"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-reviewed Reviewed by seabbs-review-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants