Skip to content

[codex] Optimize profile sigma and dense radiance storage#83

Merged
bout3fiddy merged 17 commits into
mainfrom
codex/memory-optimisation-t1-t2
Jun 15, 2026
Merged

[codex] Optimize profile sigma and dense radiance storage#83
bout3fiddy merged 17 commits into
mainfrom
codex/memory-optimisation-t1-t2

Conversation

@bout3fiddy

@bout3fiddy bout3fiddy commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix profile-line reuse for retrieval pressure-state changes.
  • Convert exact-route support-profile sigma storage from 64 B AoS rows to a wavelength-major []f64 total-sigma column.
  • Split dense radiance prefetch storage into radiance-only []f64 plus optional Jacobian vectors so no-Jacobian gathers read only radiance data.
  • Update retained cache/layout and spectrum tests for indexing, cache reuse, radiance-only gathers, and Jacobian-capable shape checks.

Validation

  • zig build test-fast
  • zig build test
  • uv run scripts/linting/check-zig-styleguide.py ...
  • uv run benchmark/run_benchmark_fast.py
  • prek run --all-files

Fast benchmark residuals were unchanged versus the parent baseline; timing moved within canary noise on the forward paths.


Note

Medium Risk
Changes core session-cache invalidation and dense radiance/Jacobian memory layout on every forward and OE iteration; incorrect reuse or indexing would show up as subtle spectroscopy or Jacobian errors rather than obvious crashes.

Overview
Session cache and forward hot path: Profile-line reuse stamps no longer hash full LayerGrid support placement, so retrieval iterations that only change aerosol pressure can keep reusing spectroscopy rows instead of invalidating the cache. Support-profile line sigma is stored as a wavelength-major []f64 total column instead of 64-byte ProfileSupportLineValue rows, and dense radiance prefetch is split into []f64 radiance plus optional Jacobian vectors so no-Jacobian gathers avoid loading Jacobian-sized structs.

Python/Zig input boundary: The packaged O2 A reference scene is defined in Python (default_o2a_scene() / o2a_default.py); Zig drops built-in default scene rendering and the C exports zds_prepare_default_o2a and zds_default_o2a_input_json. Native JSON encoding maps inert NaN to null via native_json_value; route constants like stream count live in json.zig instead of a Zig defaults module.

Tooling and docs (secondary): ./verify is documented as canonical CI; pytest markers and dev deps are added; wheel smoke scripts point at test_wheel_install_smoke.py; cost-timing Zig target is renamed to cost-timing-forward-analysis. Retained benchmark and performance README numbers are refreshed.

Reviewed by Cursor Bugbot for commit f256914. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a structural README for src/input describing the Scene type, the two
build paths (defaultScene, parseSceneJson), and validation. Replace the
remaining 'case' naming residue in the input modules with 'scene' to match
the renamed domain object, keeping comment-banner alignment.
Add a structural README for src/setup explaining what the stage computes:
the vertical layer grid, gas absorption inputs, scattering tables, and the
solar/instrument tables, grouped by the role each plays in the forward model.
Replace the remaining 'case' naming residue in the setup modules with 'scene',
keeping comment-banner alignment.
Reword the loose 'transport solver'/'each solve' prose to name the radiative
transfer or rtm/ directly, leaving the genuine rtm/solve.zig filename and the
real linear-algebra solves elsewhere untouched. Also remove a stray </content>
tag left at the end of the file.
@bout3fiddy
bout3fiddy marked this pull request as ready for review June 15, 2026 09:57

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f58874b. Configure here.

Comment thread src/cache/profile_line_memory.zig Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f58874bc57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cache/profile_line_memory.zig Outdated
Comment thread verify

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fa91c273f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verify
Comment thread scripts/smoke-linux-wheel-docker.sh Outdated
@bout3fiddy
bout3fiddy merged commit 0ed756a into main Jun 15, 2026
10 checks passed
@bout3fiddy
bout3fiddy deleted the codex/memory-optimisation-t1-t2 branch June 15, 2026 12:42
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