feat: background thread for on-the-fly visualization#1212
Merged
Conversation
Run perform_quick_update on a daemon thread so the sampler is not blocked while matplotlib renders plots. Uses a latest-only queue pattern — if a new best-fit arrives before the previous visualization finishes, the stale request is silently replaced. JAX arrays are conditionally converted to numpy before handing to the worker thread. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Run
perform_quick_updateon a background daemon thread so the sampler is not blocked while matplotlib renders and saves plots. Uses a latest-only queue — new best-fits silently replace stale pending requests. Opt-in viaquick_update_background: trueingeneral.yaml.API Changes
BackgroundQuickUpdateclass inautofit.non_linear.quick_updatesupports_background_updateandsupports_jax_visualizationproperties onAnalysisbackground_quick_updateparameter toFitness.__init__quick_update_backgroundconfig option underupdates:ingeneral.yamlNo removals or breaking changes. See full details below.
Test Plan
Full API Changes (for automation & release notes)
Added
autofit.non_linear.quick_update.BackgroundQuickUpdate— daemon thread worker for background visualizationautofit.non_linear.quick_update._convert_jax_to_numpy(instance)— deep-copy with JAX→numpy conversionAnalysis.supports_background_updateproperty (defaultFalse)Analysis.supports_jax_visualizationproperty (defaultFalse)Fitness.__init__(..., background_quick_update=False)parameterFitness.shutdown_quick_update()methodgeneral.yaml→updates.quick_update_background(defaultfalse)Migration
Closes #1211
🤖 Generated with Claude Code