Repository navigation
perf(archive): the unbounded archive merges offered rows when read, with the same rows - #360
Merged
Merged
Conversation
…ith the same rows An unbounded external archive filtered and deduplicated its whole contents once per generation, so long runs spent most of their time on it (RCM25, 112 000 rows: 85 s of archive in 200 000 evaluations). Once its contents are clean (feasible, finite, mutually non-dominated, deduplicated with a zero objective tolerance), UnboundedArchive now keeps the rows each call of add() offers and merges them in one update, with moocore's non-dominated filter when moocore is installed, when contents(), constraint_values() or update() needs them, or when the kept rows outnumber twice the archive. One merge gives the rows, in the order, of one update per call: a clean archive keeps the feasible non-dominated rows in the order they were offered, and the first of equal ones. Before the first feasible row, and for rows with non-finite feasible objectives, the archive updates at once. The states' archive_X and archive_F are now ArchiveRows descriptors that merge the archive on first read, and the algorithms offer each generation with record_archive_rows(). A run that reads its archive only at the end filters it once: 0.28 s instead of 85 s on RCM25, 0.16 s instead of 11.5 s on RCM08, 0.1 s instead of 5 s on CRE21. SMPSO, which reads its leaders every step, keeps updating at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
VAMOS documentation previewhttps://pr-360-vamos-docs-preview.vamos-optimization.workers.dev Built from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An unbounded external archive refiltered and deduplicated its whole contents once per generation. On long runs that dominated the run time: over the 200 000 evaluations of an NSGA-II run, the archive alone took 85 s on RCM25 (112 000 archived rows). Profiling showed the time going to
np.unique's sort, moocore'sis_nondominatedover the whole archive, and the copies of the contents. jMetal's archive, which inserts one row at a time, took 620 s on the same stream.UnboundedArchivenow keeps the rows it is offered and merges them in one update when they are needed. The result is the same rows in the same order, so no run changes.Changes
RowBuffer(newcomponents/archive_buffer.py, mixed into_BaseArchive).add(X, F, G)offers rows asupdatedoes, without computing the contents.bufferedarchive keeps them while its contents are clean (mutually non-dominated, finite, feasible when it holds constraint values, deduplicated with a zero objective tolerance) and the offered feasible objectives are finite.contents(),constraint_values()orupdate()needs them, or when they outnumbermax(PENDING_ROWS, 2 * size), so memory stays bounded and the merges are amortized.addupdates at once, as before: before the first feasible row, for rows with non-finite feasible objectives, with a positive objective tolerance or decision deduplication, and for bounded archives.covers_last_inputandunchanged_by_last_inputkeep their meaning, which MOEA/D's update shortcut reads.UnboundedArchive(buffered=True)is the default;buffered=Falsekeeps the eager behaviour.archive_Xandarchive_FofAlgorithmStateandNSGAIIStateareArchiveRowsdescriptors.record_archive_rows()offers a generation's rows and marks both fields stale, and the first read merges the archive once. An assignment while stale merges first, so the other field stays current.record_archive_rows; MOEA/D and SPEA2 already went throughupdate_archive, which now uses it.population_archivemode and hypervolume termination read the archive every generation, so they merge every generation: exact, and no slower than before.archive_core.pygives the buffering methods to the new module, which keeps it within the monolith guard's budget.Why one merge gives the same rows
A clean archive's update keeps the feasible non-dominated rows of the archive plus the new rows, in the order they were offered, and the first of equal ones. Rejecting a row because an archived row dominates it, and later dropping that archived row, is transitive: the final set is the non-dominated subset of everything offered, whatever the batches.
Feasibility is the only order-dependent step, through the "least violated rows" rule while no feasible row exists. That is why rows are kept only once the archive holds feasible rows.
Checks
tests/engine/test_buffered_archive.py(42 tests):PENDING_ROWS = 64forces several merges, and the archive is read in between. Buffered and eager archives give equal contents, order and constraint values.XandF, bit for bit, as with the eager path. On ZDT1 the test also checks that rows were kept for a later merge.AlgorithmStatesubclass reads its archive fields throughArchiveRows; first reads, assignments while stale, and bounded archives updating at once.tests/engine/test_moead_archive_update.py: its row counter now countsaddas well asupdate.Recorded streams of 200 000 evaluations (NSGA-II, population 100, as an algorithm offers them):
These come from the stream benchmark used to build the CRE and RCM reference fronts, where the archive dominated the campaign's time.
Validation
Run on Windows with Python 3.12, following
AGENTS.md:tools/typecheck.py --scope strictand--scope fullgive 0 diagnostics with ratchet new=0, in a.[dev]-only environment.tools/health.py: all health checks passed, the monolith guard included after the split;mkdocs build --strict: passes;tools/check_agent_docs.py: passes.git diff --checkpass.pytest -m "not slow" -n 6: 10 882 passed, 2 failed.tests/experiment/test_cli_ablation.py::test_cli_ablation_runs_and_writes_variantsis pre-existing: it fails the same way under xdist on Windows on untouchedmain, and passes alone.Changelog entry
[Unreleased] — Changed
UnboundedArchive(buffered=False)keeps the eager updates.🤖 Generated with Claude Code