Skip to content

Preserve thin-layer canopy transmission increments in Float32 - #244

Merged
sunitisanghavi merged 7 commits into
fix/canopy-projection-quadraturefrom
fix/canopy-transmission-precision
Nov 7, 2026
Merged

sunitisanghavi merged 7 commits into
fix/canopy-projection-quadraturefrom
fix/canopy-transmission-precision

Conversation

@cfranken

@cfranken cfranken commented Nov 7, 2026

Copy link
Copy Markdown
Member

Thin canopy elemental layers can lose their diagonal transmission increments in Float32. Repeated doubling then amplifies that rounding into spurious absorption or gain; making the seed thinner can make the result worse. This change retains Δ = T-I and the solar attenuation increment from expm1 throughout canopy doubling, reconstructing transmission only at the end. No phase matrices, fluxes or absorption are rescaled.

The canopy wrapper now exposes typed elemental-thickness controls (CanopyNumericalParameters, including TOML/YAML parsing) and uses a 1e-5 threshold with no precision floor by default. The increment solve uses canopy-local pivoted LU on CPU and the existing fused geometric-series solve on supported GPU sizes, with new fused source/operator updates and the existing large-matrix fallback. Additional non-solar source slots are explicitly rejected: distributed fluorescence needs its own source construction, not the solar attenuation recurrence.

This PR is stacked on #243, with base fix/canopy-projection-quadrature; its diff contains only the precision work. It requires the now-registered CanopyOptics v0.2.2, including the Float32 specular azimuth/grazing fixes. Retarget to main after #243 merges.

Validation on Julia 1.12.6:

  • Full Pkg.test against released CanopyOptics v0.2.2: 25,756 passed, 16 conditional skips; CUDA masked, four Julia threads, one BLAS thread.
  • Focused final implementation: 3,988 CPU and 3,810 CUDA checks on an NVIDIA L40S, with scalar device indexing disabled. Covers Stokes I/IQU/IQUV, Fourier orders 0–2, multiple spectral points, diffuse/specular optics, nadir incidence, zero-thickness layers, fused/fallback modes and independent dense adding equations for signed noncommuting matrices.
  • Production conservative canopy: 64-stream direct photon-budget errors approximately 1.2e-6 in Float32 and 3.2e-6 in Float64. Finite angular quadrature remains: the 16-stream case retains about 1.8e-4 error, so the 1e-4 acceptance target applies at 32/64 streams.
  • Taplo lint/format and git diff --check passed.

Warmed kernel measurements and raw CSVs are in docs/dev_notes/canopy_increment_doubling.md. Final fused Float32 updates improve the initial increment implementation (8 streams, IQUV, 64 spectral points: 5.54 → 2.58 ms), but Float64 IQUV regresses (8.92 → 10.68 ms). This is a numerical-accuracy fix, not a universal speedup; timings exclude phase construction, seeding, transfers and compilation. Metal and arbitrary dual-number differentiation remain unvalidated, and the change adds no canopy analytic Jacobians.

Copilot AI balanced review requested due to automatic review settings November 7, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sunitisanghavi
sunitisanghavi merged commit de00372 into fix/canopy-projection-quadrature Nov 7, 2026
30 checks passed
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.

3 participants