Skip to content

perf: Skip VRAM estimation, reduce I/O and formatting in test mode 2+ #1183

@Jammy2211

Description

@Jammy2211

Overview

With PYAUTO_WORKSPACE_SMALL_DATASETS=1 and PYAUTO_DISABLE_CRITICAL_CAUSTICS=1 (shipped in PyAutoLabs/autolens_workspace#34), smoke test scripts still take ~40-50s each under PYAUTOFIT_TEST_MODE=2. Profiling shows the remaining time is dominated by PyAutoFit-level operations: VRAM estimation (16s), pre-fit file I/O (10s), model.info formatting (7s), and result deserialization (5s). Addressing these should bring total runtime under 10s per script.

Plan

  • Skip print_vram_use() when PYAUTOFIT_TEST_MODE >= 2 — avoids expensive JAX JIT compilation + memory analysis
  • Reduce file I/O in _fit_bypass_test_mode() — skip saving samples, results, and visualization in test mode
  • Speed up or skip model.info formatting for large models in test mode
  • Speed up result_info_from() — skip expensive sigma quantile calculations in test mode
Detailed implementation plan

Affected Repositories

  • PyAutoFit (primary)

Work Classification

Library

Branch Survey

Repository Current Branch Dirty?
PyAutoFit main_build clean

Suggested branch: feature/smoke-test-fast-pyautofit

Implementation Steps

  1. Skip VRAM estimation in test mode — In autofit/non_linear/analysis/analysis.py:319, add early return in print_vram_use() when test_mode_level() >= 2. Saves ~16s per script.

  2. Reduce file I/O in test mode bypass — In autofit/non_linear/search/abstract_search.py:790, the _fit_bypass_test_mode() method calls save_samples_summary(), save_samples(), save_results(), save_results_combined(), and paths.completed(). Skip save_samples(), save_results(), and save_results_combined() in test mode 2+ (keep save_samples_summary for result access). Saves ~8-10s.

  3. Speed up model.info — In autofit/mapper/prior_model/abstract.py:1775, the info property iterates all path/prior tuples, calls find_groups(), and formats via TextFormatter. For MGE models with ~40 gaussians this takes 7s. Options: cache the property, or return a minimal stub when test_mode_level() >= 2.

  4. Speed up result_info_from — In autofit/text/text_util.py:53, result_info_from() calls samples_text.summary() twice (sigma=3.0, sigma=1.0). The values_at_sigma() computation is expensive. Skip in test mode 2+.

Key Files

  • autofit/non_linear/analysis/analysis.py:319print_vram_use()
  • autofit/non_linear/search/abstract_search.py:790_fit_bypass_test_mode()
  • autofit/mapper/prior_model/abstract.py:1775info property
  • autofit/non_linear/result.py:85result.info
  • autofit/text/text_util.py:53result_info_from()
  • autofit/text/samples_text.py:15summary()
  • autofit/non_linear/test_mode.pytest_mode_level()

Original Prompt

Click to expand starting prompt

Continuation of the smoke test speed-up work. The first phase shipped env vars
for small datasets and disabled critical curves (autolens_workspace#34). This
phase targets the remaining PyAutoFit-level bottlenecks identified by profiling.

With PYAUTO_WORKSPACE_SMALL_DATASETS=1 and PYAUTO_DISABLE_CRITICAL_CAUSTICS=1,
the imaging and interferometer modeling scripts still take ~40-50s each under
PYAUTOFIT_TEST_MODE=2. The remaining time is dominated by:

  1. VRAM estimation: ~16s — analysis.print_vram_use() does full JAX JIT
    compilation + memory analysis. Should be skipped when PYAUTOFIT_TEST_MODE >= 2.

  2. search.fit pre-fit I/O: ~10s — _fit_bypass_test_mode() writes model.info,
    visualization, saves samples, saves results. Much of this can be skipped in
    test mode 2+.

  3. model.info formatting: ~7s — The info property on MGE models with ~40
    gaussians takes 7s to format. Can be cached or stubbed in test mode.

  4. Result access: ~5s — max_log_likelihood_instance takes ~5s to
    deserialize. The result_info_from() function calls expensive
    samples_text.summary() twice.

Target: get both scripts under 10s total with all env vars set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions