Skip to content

refactor(csp-batch): the post-processing of the reverse pass as routines, and a stage index in the driver (step 4, third part) - #137

Merged
elijahmathews merged 3 commits into
feat/hotpath-doc-tourfrom
feat/hotpath-04c-reverse-pass
Nov 19, 2026
Merged

elijahmathews merged 3 commits into
feat/hotpath-doc-tourfrom
feat/hotpath-04c-reverse-pass

Conversation

@elijahmathews

Copy link
Copy Markdown
Owner

Stack: the unification plan (doc/HOT_PATHS_PLAN.md), step 4 of 5, third part, after #136 (the tour). Merge order: ..., #135, #136, this.

What changes

  • batch_mass_cotangent: the mass output's cotangent in the reverse pass (the resident basis): wbl(k, m) gains mass_bar(m) times the model's blend of the basis' surviving masses, and with per-model metallicity and gradients the logzsol and afe rows gain the mass's derivative with respect to dz and da.
  • batch_sfh_gradients: the SFH parameters' gradients through the weights' tangents (sfh_weights_tangent, FP64 on the host, one model per thread).
  • A stage index at the top of compute_csp_batch: a comment that lists the stages (0 checks and plan, 1 setup, 2 SFH weights, 3 age sums, 4 nebular, 5 attenuation, 6 dust emission / IGM / AGN, 7 smoothing, 8 magnitudes, 9 the reverse pass) with the routine of each, so that reading the driver gives the map that doc/HOT_PATH_TOUR.md explains in plain terms.

The code of the driver is 759 lines (1037 at the start of step 4), 775 with the index. The plan (doc/HOT_PATHS_PLAN.md) gets the status.

Verification

  • CPU, both trees built with -fno-tree-vectorize (see refactor(csp-batch): the host-only blocks of the driver as routines (step 4, first part) #134): forward dumps 6 of 6 and gradient dumps 6 of 6 bit for bit (the resident basis, metallicity, [alpha/Fe], the IMF per model with the modification factors, a closed-form field). The gradient dumps exercise both new routines (the benchmark gives mass_bar and the SFH parameters' rows).
  • R9700 (both trees rebuilt from scratch, csp_batch.f90 in both compile logs): 45 forward dumps, 0 differ bit for bit.
  • Host FP64 and FP32 suites, the six R9700 device tests and the nvfortran 26.1 compile pass.
  • The stage index is a comment (checked: it builds).

🤖 Generated with Claude Code

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

elijahmathews and others added 2 commits November 18, 2026 23:10
…nes, and a stage index at the top of the driver (unification plan, step 4, third part)

batch_mass_cotangent (the mass output's cotangent) and batch_sfh_gradients (the SFH parameters through the weights' tangents) leave compute_csp_batch (809 to 759 lines of code); a comment at the top of the driver lists its stages with their routines. Bit-identical: CPU with -fno-tree-vectorize (forward and gradient dumps), 45 forward dumps on the R9700.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5
@elijahmathews
elijahmathews added this pull request to stack #114 November 19, 2026 11:58
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat/hotpath-doc-tour@1e6171e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/physics/opensps_csp_batch.f90 81.48% 0 Missing and 5 partials ⚠️

❌ Your patch check has failed because the patch coverage (81.48%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                   Coverage Diff                    @@
##             feat/hotpath-doc-tour     #137   +/-   ##
========================================================
  Coverage                         ?   74.93%           
========================================================
  Files                            ?       51           
  Lines                            ?    14479           
  Branches                         ?     6089           
========================================================
  Hits                             ?    10850           
  Misses                           ?     1482           
  Partials                         ?     2147           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@elijahmathews
elijahmathews marked this pull request as ready for review November 19, 2026 16:55
@elijahmathews
elijahmathews merged commit dc39742 into main Nov 19, 2026
28 of 30 checks passed
@elijahmathews
elijahmathews deleted the feat/hotpath-04c-reverse-pass branch November 19, 2026 17:49
elijahmathews added a commit that referenced this pull request Nov 19, 2026
…ey of that code (#138)

Stack: after #137. Documentation only.

The survey of the nebular code that the unification plan called for. The
family (about 2000 lines: `nebular_setup`, `add_nebular_batch`,
`nebular_kernels`, `nebular_continuum_tiled`, `cue_nebular`,
`cue_nebular_backward`, `backward_nebular`, `neb_run_block`, and the
line routines) is two physical models, each with a forward and a reverse
pass: the CLOUDY grids, and cue (Li et al. 2024, a neural-network
emulation of CLOUDY), plus the line profiles and the dust absorption of
the lines. They share the interface (`add_nebular_batch`) and the line
handling, not code, so there is no copy to merge; the plan records that,
and `doc/HOT_PATH_TOUR.md` gets a section with a table of the routines
(forward and reverse, per model) for a reader who has to find their way
in.

Every routine named was checked to exist.

🤖 Generated with [Claude Code](https://claude.ai/code)

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
elijahmathews added a commit that referenced this pull request Nov 19, 2026
…139)

Stack: after #138. Merge order: ..., #137, #138, this. A rename,
bit-identical.

## What changes

The flags of `compute_csp_batch` had names that did not say what they
mean (`imf` is "the SSPs come from the operators", not anything about
the IMF itself; `zw`, `zmode`, `naf`...). In `opensps_csp_batch.f90`
(the routines of the driver and the stage routines that receive them):

| Old | New | Meaning |
|---|---|---|
| `imf` | `use_operators` | the SSPs come from the operators (`ssp_ops`
given) |
| `zimf` | `operators_per_z` | one operator per metallicity of the
context |
| `zw` | `weights_over_z` | SSP weights over ages and metallicities
(`ssp_weights_z`) |
| `zmode` | `blend_z` | each model blends the resident bases at its own
`logzsol` |
| `naf` | `n_afe_planes` | [alpha/Fe] planes of the stack (1: none) |
| `zvar` | `z_varies` | the redshifts or `igm_factor` differ among the
models |
| `given_w` | `weights_given` | the SFH weights were supplied |
| `host_w` | `weights_on_host` | few models: the SFH weights computed on
the host |
| `host_m` | `sums_on_host` | few models: weights and per-model sums run
on the host |

223 occurrences; word-boundary replacement in this one file (checked:
the new names were unused, no keyword arguments or other modules use the
old names), 15 code lines and 9 comment blocks that grew past 132
columns reflowed (the comment blocks as whole paragraphs).
`doc/HOT_PATH_TOUR.md` gets a table of the flags and one of the driver's
main arrays (`weights`, `w2`, `yo`, `total`, `absorbed`, `tdiff`, `eml`,
`msum`..., the packed `ipk`/`rpk`/`lpk`/`rout` and the names that view
into them), and the plan the new names.

## Verification

- CPU, both trees built with `-fno-tree-vectorize` (see #134): forward
dumps 6 of 6 and gradient dumps 6 of 6 bit for bit.
- R9700 (both trees rebuilt from scratch, `csp_batch.f90` in both
compile logs): 45 forward dumps, 0 differ bit for bit.
- Host FP64 and FP32 suites, the six device tests and the nvfortran 26.1
compile pass.

🤖 Generated with [Claude Code](https://claude.ai/code)

https://claude.ai/code/session_01MXDRCs7ATQiqhT6RLPLXR5

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant