Skip to content

fix(llm): validate and safely normalize ensemble weights - #570

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
Yushu-Li:fix/ensemble-weight-normalization
Oct 31, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
Yushu-Li:fix/ensemble-weight-normalization

Conversation

@Yushu-Li

Copy link
Copy Markdown
Contributor

I fixed ensemble weights becoming unusable during normalization. For example, two finite weights of 1e308 sum to infinity, so the current division turns both normalized weights into zero and model sampling fails. Negative weights can also silently become positive probabilities when every weight is negative.

The constructor now rejects non-finite or negative weights, and non-empty ensembles with no positive weight, before initializing model clients. If the sum of otherwise valid finite weights overflows, it rescales by the largest weight before normalizing. Ordinary normalization, zero-weight slots, the caller's configurations and empty placeholder ensembles keep their existing behavior.

Validation:

  • Seven new test methods cover equal/unequal overflowing sums, NaN/infinities, negative and all-zero weights, client initialization side effects, ordinary/integer/subnormal weights and empty placeholders.
  • The regression methods reproduce the failures on unchanged main; existing-behavior controls pass.
  • All 20 focused ensemble/judge tests passed.
  • Full local unittest suite: 985 passed.
  • Black checks and git diff --check passed.

I directed this contribution and used Codex assistance for reproduction, implementation, tests and code review. Verification used offline clients and unit-test fixtures; no paid provider calls were made.

@codelion
codelion merged commit 42a09fd into algorithmicsuperintelligence:main Oct 31, 2026
5 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.

2 participants