Skip to content

fix(map-elites): reject non-finite fitness and descriptors - #295

Open
lll-hhh wants to merge 1 commit into
ANative-Lab:mainfrom
lll-hhh:fix/map-elites-finite-metrics
Open

lll-hhh wants to merge 1 commit into
ANative-Lab:mainfrom
lll-hhh:fix/map-elites-finite-metrics

Conversation

@lll-hhh

@lll-hhh lll-hhh commented Oct 29, 2026

Copy link
Copy Markdown

Fixes #294.

MAP-Elites currently admits non-finite fitness into its archive. With evaluator scores [NaN, 1.0] in one cell, the real optimization loop returns best fitness NaN and acceptance history [True, False]: the finite improvement cannot replace the invalid elite. Infinite feature descriptors are also silently clipped into boundary cells.

Extend the existing numeric validation to reject non-finite fitness and descriptors with field-specific ValueErrors before archive admission or binning. NaN descriptors already fail inside integer conversion; they now receive the same clear field-specific validation error. The existing selection, mutation, finite signed fitness, and finite out-of-range descriptor clipping behavior is preserved.

Validation on Windows / Python 3.11.7:

  • python -m pytest tests/src/optimizers --ignore=tests/src/optimizers/test_sew_workflow_scheme.py -q: 30 passed. The new file directly runs the actual optimizer, without model calls, network services, or mocked optimizer methods. It covers scalar/dictionary non-finite fitness, non-finite descriptors, signed finite scores, finite clipping boundaries, ties, and subsequent improvements. On unchanged main (f3d1ea5), the targeted MAP-Elites command yields 9 failed, 17 passed; patched yields 26 passed. Eight cases previously admitted invalid values; the NaN-descriptor case checks the clearer diagnostic.
  • The new test file passes Ruff; git diff --check passes. The edited production file has the same 29 pre-existing Ruff diagnostics on base and patched code, with no added diagnostics; these concern existing imports/type annotations and are not reformatted in this bug fix.
  • Full-suite collection was attempted on both unchanged and patched trees. Both stop at the same 15 collection errors in this local environment, including optional RAG/workflow dependencies. Thus a full-suite pass is not claimed. test_sew_workflow_scheme.py is one of those collection failures, which is why the affected optimizer group above excludes it.

Setup: isolated virtual environment with uv pip install -e '.[dev,tools,optimizers]' 'mcp<2'. The local MCP compatibility constraint is needed for FastMCP 2's McpError import with the currently resolved packages; no dependency files are changed by this PR. No GPU runs, live LLM calls, or optimization-quality gains are claimed.

This patch, issue, and verification were prepared with AI assistance. No independent human review is asserted.

This branch has not been deployed

No deployments
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.

MAP-Elites admits non-finite fitness and can freeze elite replacement

1 participant