Skip to content

Commit 730a133

Browse files
authored
Merge pull request #1184 from rhayes777/feature/smoke-test-fast-pyautofit
perf: Skip VRAM, I/O, model.info in test mode 2+ and add PYAUTO_DISABLE_JAX
2 parents dd80a4c + 4780697 commit 730a133

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

autofit/mapper/prior_model/abstract.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,10 @@ def info(self) -> str:
17781778
parameter of the overall model.
17791779
This information is extracted from each priors *model_info* property.
17801780
"""
1781+
from autofit.non_linear.test_mode import test_mode_level
1782+
1783+
if test_mode_level() >= 2:
1784+
return f"Total Free Parameters = {self.prior_count}\n\n[test mode — info skipped]"
17811785

17821786
formatter = TextFormatter(line_length=info_whitespace())
17831787

autofit/non_linear/analysis/analysis.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class Analysis(ABC):
3535
def __init__(
3636
self, use_jax : bool = False, **kwargs
3737
):
38+
import os
39+
if os.environ.get("PYAUTO_DISABLE_JAX") == "1":
40+
use_jax = False
3841

3942
self._use_jax = use_jax
4043
self.kwargs = kwargs
@@ -325,6 +328,11 @@ def print_vram_use(self, model, batch_size : int) -> str:
325328
batch_size
326329
The batch size to profile, which is the number of model evaluations JAX will perform simultaneously.
327330
"""
331+
from autofit.non_linear.test_mode import test_mode_level
332+
333+
if test_mode_level() >= 2:
334+
return
335+
328336
if not self._use_jax:
329337
print("use_jax=False for this analysis, therefore does not use GPU and VRAM use cannot be profiled.")
330338
return

autofit/non_linear/search/abstract_search.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,13 @@ class represented by model M and gives a score for their fitness.
497497
analysis = analysis.modify_before_fit(paths=self.paths, model=model)
498498
model.unfreeze()
499499

500-
self.pre_fit_output(
501-
analysis=analysis,
502-
model=model,
503-
info=info,
504-
)
500+
mode = test_mode_level()
501+
if mode < 2:
502+
self.pre_fit_output(
503+
analysis=analysis,
504+
model=model,
505+
info=info,
506+
)
505507

506508
if not self.paths.is_complete:
507509
result = self.start_resume_fit(
@@ -514,13 +516,14 @@ class represented by model M and gives a score for their fitness.
514516
model=model,
515517
)
516518

517-
analysis = analysis.modify_after_fit(
518-
paths=self.paths, model=model, result=result
519-
)
519+
if mode < 2:
520+
analysis = analysis.modify_after_fit(
521+
paths=self.paths, model=model, result=result
522+
)
520523

521-
self.post_fit_output(
522-
search_internal=result.search_internal,
523-
)
524+
self.post_fit_output(
525+
search_internal=result.search_internal,
526+
)
524527

525528
gc.collect()
526529

@@ -856,8 +859,6 @@ def _fit_bypass_test_mode(
856859
)
857860

858861
samples_summary = samples.summary()
859-
self.paths.save_samples_summary(samples_summary=samples_summary)
860-
self.paths.save_samples(samples=samples)
861862

862863
result = analysis.make_result(
863864
samples_summary=samples_summary,
@@ -866,13 +867,8 @@ def _fit_bypass_test_mode(
866867
search_internal=None,
867868
)
868869

869-
analysis.save_results(paths=self.paths, result=result)
870-
analysis.save_results_combined(paths=self.paths, result=result)
871-
872870
model.unfreeze()
873871

874-
self.paths.completed()
875-
876872
return result
877873

878874
@staticmethod

autofit/text/text_util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def result_info_from(samples) -> str:
5555
Output the full model.results file, which include the most-likely model, most-probable model at 1 and 3
5656
sigma confidence and information on the maximum log likelihood.
5757
"""
58+
from autofit.non_linear.test_mode import test_mode_level
59+
60+
if test_mode_level() >= 2:
61+
return "[test mode — result info skipped]"
62+
5863
results = []
5964

6065
if hasattr(samples, "log_evidence"):

0 commit comments

Comments
 (0)