Skip to content

Type 2M sentinel returns by all result-feeding inputs#727

Closed
haakon-e wants to merge 1 commit into
he/ad-compat-2m-p3from
he/sentinel-return-types
Closed

Type 2M sentinel returns by all result-feeding inputs#727
haakon-e wants to merge 1 commit into
he/ad-compat-2m-p3from
he/sentinel-return-types

Conversation

@haakon-e

@haakon-e haakon-e commented Jun 12, 2026

Copy link
Copy Markdown
Member

Functions that type early returns or sentinel values from a single argument (FT = eltype(q_tot)-style) return union-typed, heap-boxed results when a caller mixes plain floats with ForwardDiff Duals across arguments -- as any pointwise Jacobian of the tendencies does (frozen thermodynamic context, Dual species). JET reports nothing and the optimized IR contains no dynamic calls, since the box lives in the abstract return convention (found while chasing per-substep allocations in the Rosenbrock substepping work; tracked there as a value-dependent 32 B/substep).

Adds Utilities.promote_typeof and types rain_evaporation's early return by the promotion of all the arguments its rates derive from, with an @inferred regression test over both branches. Stacked on #725; further 2M/P3 cases from the same sweep land here as they are confirmed.

The early return (no rain, or supersaturated) was typed from
eltype(q_tot) alone while the main path's rates derive from all eight
numeric arguments. Callers mixing Dual-valued species with a
plain-float q_tot (any pointwise Jacobian) got a union-typed,
heap-boxed return — silently: JET reports nothing and the optimized IR
contains no dynamic calls, since the box comes from the abstract
return convention.

Adds Utilities.promote_typeof for the idiom: type sentinels and early
returns by the promotion of the arguments the result derives from.
@haakon-e

Copy link
Copy Markdown
Member Author

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.90%. Comparing base (bdd359d) to head (d5cabf8).

Additional details and impacted files
@@                 Coverage Diff                 @@
##           he/ad-compat-2m-p3     #727   +/-   ##
===================================================
  Coverage               92.90%   92.90%           
===================================================
  Files                      56       56           
  Lines                    2720     2721    +1     
===================================================
+ Hits                     2527     2528    +1     
  Misses                    193      193           
Components Coverage Δ
src 93.75% <100.00%> (+<0.01%) ⬆️
ext 69.47% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haakon-e

Copy link
Copy Markdown
Member Author

Folded into #725 (tiny fix + tests; not worth a separate PR in the stack).

@haakon-e haakon-e closed this Jun 12, 2026
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