Repository navigation
Keep Learner1D's loss infinite while a bound is still pending - #512
Merged
basnijholt merged 2 commits intoDec 5, 2026
Merged
Conversation
python-adaptive#271 made loss() infinite until the bounds are evaluated, so that a parallel run whose middle points come back first cannot reach its loss goal without them. Checking _missing_bounds() left out pending bounds, and in a runner both bounds are pending from the first ask, so the loss was finite in exactly that case: BlockingRunner returned above its goal and AsyncRunner cancelled the bounds. Treat a bound as missing until it is in data. Fixes python-adaptive#316
Keep real loss infinite until both bounds are evaluated. Use the original missing-bound check for expected loss so an in-flight bound does not starve sibling learners under loss-based balancing. Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
basnijholt
approved these changes
Dec 5, 2026
basnijholt
left a comment
Member
There was a problem hiding this comment.
Thanks for tracking this down and putting together such a clear explanation and reproduction!
I pushed one small follow-up commit to restrict the self.data check to real=True and keep _missing_bounds() for real=False. While reviewing, I noticed that forcing loss(real=False) to inf for pending bounds changed BalancingLearner(strategy="loss") scheduling so a child with an in-flight bound took all newly asked points and starved siblings whose bounds had already finished. I also added tests covering both bound completion orders, expected loss, and BalancingLearner.
Merging now!
3 of 7 tasks
basnijholt
pushed a commit
that referenced
this pull request
Dec 6, 2026
…513) Learner1D and Learner2D report an infinite loss until their bounds are evaluated, so a parallel run whose interior points come back first cannot reach a loss goal without them. LearnerND.loss() was the largest simplex loss of whatever had been told, so it was finite as soon as a few interior points triangulated, with every corner still pending: BlockingRunner returned above its goal and AsyncRunner returned without the corners and a loss below the goal. Return inf until bounds_are_done, which LearnerND has had all along without using it. Follow-up commit restricts the bounds_are_done gate to real=True and keeps _bounds_available for real=False (matching #512), with tests for real=False and BalancingLearner with pending corners. Assisted-by: MindRoom DevAgent (orchestrator: google/gemini-4-neon; implementer: openai/gpt-6.2-sol; reviewers: anthropic/claude-opus-5.5, openai/gpt-6.2-astra) <https://github.com/mindroom-ai/mindroom>
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.
Description
#271 made
Learner1D.loss()infinite until the bounds are evaluated, so that a parallel run whose middle points come back first cannot reach its loss goal without the bounds. A later commit in that PR switched the check fromself.__missing_boundstoself._missing_bounds(), which leaves out bounds that are pending (that list is whataskstill has to hand out). In a runner both bounds are pending from the firstask, so in exactly that case the loss was finite again: with the data from #316 and the left bound in flight,loss()is0.0015; with #271's own setup (ask(4), the two middle points told first) it is0.59while both bounds are still running.loss()now treats a bound as missing until it is indata, so a pending bound counts too. Readingdatadirectly also keeps clear of what the switch presumably fixed:__missing_boundsis only pruned inside_missing_bounds(), so it could still list bounds that had been told.loss(real=False)was already infinite in that state (the intervals next to a pending bound have an infinite combined loss), andaskstill uses_missing_bounds(), so it does not ask for a pending bound twice.What it changes for a run, with bounds that take 3 s and a middle that takes 20 ms,
loss_goal=0.05and 4 threads, 5 runs each:mainBlockingRunner: goal met when it returnsAsyncRunner: bounds evaluated at allOn
mainthe goal is reached on the middle alone.BlockingRunnerthen waits for the running bounds while it cleans up, so they land, but the loss it returns with is above the goal and the edges are under-sampled.AsyncRunnercancels them, so the learner is left without its bounds.New test
test_inf_loss_while_bounds_are_pendingintest_learner1d.py: afterask(4)and telling the two middle points,loss()andloss(real=False)are infinite, still infinite with one bound told, finite with both. Onmainit fails at the first check; checking only one bound fails it at the second.This settles the part of #316 that still happens: the issue's own snippet, with the left bound never asked, already gives
infsince #271.Fixes #316
Checklist
pre-commit run --all(first install usingpip install pre-commit)pytestpassedRun here (macOS, on
mainat 262ffe9):nox -e pytest_min_deps-3.12 pytest_all_deps-3.12 pytest_min_deps-3.13 pytest_all_deps-3.13 pytest_typeguard pytest_rust_backendall pass (3.11 and 3.14 are not installed here), andpre-commit run --all-filespasses, mypy included.Type of change