Skip to content

Stabilize sliding-window manifold weights#4385

Merged
FlorianPfaff merged 3 commits into
mainfrom
agent/stabilize-sliding-window-weights-20260714
Jul 14, 2026
Merged

Stabilize sliding-window manifold weights#4385
FlorianPfaff merged 3 commits into
mainfrom
agent/stabilize-sliding-window-weights-20260714

Conversation

@FlorianPfaff

@FlorianPfaff FlorianPfaff commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • reject non-finite window_weights during SlidingWindowManifoldMeanSmoother construction
  • normalize each active window without overflowing its sum
  • avoid JAX/XLA reciprocal underflow for maximum finite weights
  • preserve relative weights and add end-to-end regression coverage through smooth()

Root cause

The original implementation normalized weights directly with:

weights / sum(weights)

For individually finite values such as [max_float, max_float / 2], the sum overflows. The first stabilization attempt instead used:

weights / max(weights)

That works with NumPy, PyTorch, and older JAX versions, but the CI-pinned JAX 0.10.2 lowers division by float32.max through reciprocal multiplication. The reciprocal underflows to zero, so both scaled weights become zero and the subsequent normalization produces NaNs. All three JAX matrix jobs failed when the downstream Dirac distribution rejected those non-finite weights; NumPy and PyTorch remained green.

Fix

Validate that every configured weight is finite. For each active window, divide twice by the square root of its largest positive weight before normalizing:

scale_root = sqrt(max(weights))
scaled = (weights / scale_root) / scale_root
normalized = scaled / sum(scaled)

Each divisor remains representable, avoiding JAX's extreme reciprocal underflow while retaining the original weight ratios.

Validation

  • reproduced the failure with the CI-pinned JAX 0.10.2: [max_float, max_float / 2] / max_float became [0, 0]
  • verified the two-step scaling on JAX 0.10.2, NumPy, PyTorch, and JAX 0.9
  • verified maximum finite 2:1 weights normalize to approximately [2/3, 1/3]
  • verified trailing-window smoothing of [0, 3] returns approximately [0, 1]
  • verified NaN and infinities are rejected

The full GitHub Actions matrix is running on the updated branch.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 13.14s
✅ JSON prettier 7 0 0 0 0.62s
✅ JSON v8r 7 0 0 2.52s
✅ MARKDOWN markdownlint 68 0 0 0 1.07s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.34s
✅ PYTHON black 1490 182 0 0 56.36s
✅ PYTHON isort 1490 328 0 0 1.53s
✅ REPOSITORY betterleaks yes no no 1.61s
✅ REPOSITORY checkov yes no no 40.73s
✅ REPOSITORY gitleaks yes no no 8.32s
✅ REPOSITORY git_diff yes no no 0.26s
✅ REPOSITORY secretlint yes no no 38.13s
✅ REPOSITORY syft yes no no 3.43s
✅ REPOSITORY trivy-sbom yes no no 4.07s
✅ REPOSITORY trufflehog yes no no 21.27s
✅ YAML prettier 11 0 0 0 0.38s
✅ YAML v8r 11 0 0 6.58s
✅ YAML yamllint 11 0 0 0.32s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff FlorianPfaff marked this pull request as ready for review July 14, 2026 14:52
@FlorianPfaff FlorianPfaff merged commit 54fda79 into main Jul 14, 2026
26 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.

1 participant