Skip to content

perf: cache total counts and avoid temporaries in Template._pred - #1149

Merged
henryiii merged 1 commit into
developfrom
perf/cost-caching-cleanup
Aug 6, 2026
Merged

perf: cache total counts and avoid temporaries in Template._pred#1149
henryiii merged 1 commit into
developfrom
perf/cost-caching-cleanup

Conversation

@henryiii

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Split out of #1137. No behavior change.

  • BinnedCost caches the total number of entries of the unmasked bins in _update_cache. BinnedNLL._pred and _grad summed the counts on every call.
  • Template._pred added a full array of 1e-300 per component. A scalar add gives the same variance floor without the temporaries.
  • Replaces abc.abstractproperty, deprecated since Python 3.3, with property over abstractmethod.

Touches the same region of BinnedNLL._grad as #1137, so a trivial conflict is possible depending on merge order.

Reported in #1132.

- BinnedCost caches the total number of entries of the unmasked bins in
  _update_cache. BinnedNLL._pred and _grad summed the counts on every
  call.
- Template._pred added a full array of 1e-300 per component. A scalar
  add gives the same variance floor without the temporaries.
- Replace abc.abstractproperty, deprecated since Python 3.3, with
  property over abstractmethod.

Assisted-by: ClaudeCode:claude-opus-5

@ikrommyd ikrommyd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@henryiii
henryiii merged commit 624c914 into develop Aug 6, 2026
9 checks passed
@henryiii
henryiii deleted the perf/cost-caching-cleanup branch August 6, 2026 12:50
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.

2 participants