diff --git a/HISTORY.md b/HISTORY.md index c2f0f10..063d84c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # History +1.2.4 (2026-04-24) +------------------ +* Support `mps` (MacOS) with `phold autotune` + 1.2.4 (2026-04-22) ------------------ * Bugfix to ensure ProstT5 confidence outputs are correctly output when annotating multiple contigs/genomes with `phold run` or `phold predict` diff --git a/pyproject.toml b/pyproject.toml index 2fb18f8..eb9e953 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires = ["setuptools>=61.0", "wheel>=0.37.1"] [project] # https://packaging.python.org/en/latest/specifications/declaring-project-metadata/ name = "phold" -version = "1.2.4" # change VERSION too +version = "1.2.5" # change VERSION too description = "Phage Annotations using Protein Structures" readme = "README.md" requires-python = ">=3.8, <4" diff --git a/src/phold/features/autotune.py b/src/phold/features/autotune.py index 10a42ec..5bf6bd6 100644 --- a/src/phold/features/autotune.py +++ b/src/phold/features/autotune.py @@ -44,6 +44,14 @@ def sample_probe_sequences(seqs, n=5000, seed=0): return sampled + +def device_synchronize(device: torch.device): + if device.type == "cuda": + torch.cuda.synchronize(device) + elif device.type == "mps": + torch.mps.synchronize() + # CPU and others: no-op + def autotune_batching_real_data( model_dir, model_name, @@ -67,6 +75,7 @@ def autotune_batching_real_data( if cpu is True: device = torch.device("cpu") + logger.error("You are running phold autotune with CPU, which is not supported. Please use --batch_size 1") else: # check for NVIDIA/cuda if torch.cuda.is_available(): @@ -76,6 +85,7 @@ def autotune_batching_real_data( device = torch.device("mps") else: device = torch.device("cpu") + logger.error("You are running phold autotune with CPU, which is not supported. Please use --batch_size 1") while bs <= max_bs: @@ -108,11 +118,12 @@ def autotune_batching_real_data( inputs = {k: v.to(device) for k, v in inputs.items()} # timing - torch.cuda.synchronize() + device_synchronize(device) t0 = time.perf_counter() with torch.no_grad(): _ = model(**inputs) - torch.cuda.synchronize() + device_synchronize(device) + total_time += time.perf_counter() - t0 diff --git a/src/phold/features/predict_3Di.py b/src/phold/features/predict_3Di.py index 0439261..e7fbcc6 100644 --- a/src/phold/features/predict_3Di.py +++ b/src/phold/features/predict_3Di.py @@ -141,9 +141,8 @@ def get_T5_model( localfile = False logger.info("ProstT5 not found. Downloading ProstT5 from Hugging Face") try: - # suppress warning and progress bar + # suppress warning logging.set_verbosity_error() - utils.logging.disable_progress_bar() model = T5EncoderModel.from_pretrained( model_name, cache_dir=f"{model_dir}/", @@ -155,9 +154,7 @@ def get_T5_model( logger.warning("Download from Hugging Face failed. Trying backup from Zenodo.") logdir = f"{model_dir}/logdir" download_zenodo_prostT5(model_dir, logdir, threads) - logging.set_verbosity_error() - utils.logging.disable_progress_bar() model = T5EncoderModel.from_pretrained( model_name, diff --git a/src/phold/utils/VERSION b/src/phold/utils/VERSION index b966e81..3a1f10e 100644 --- a/src/phold/utils/VERSION +++ b/src/phold/utils/VERSION @@ -1 +1 @@ -1.2.4 \ No newline at end of file +1.2.5 \ No newline at end of file