Skip to content

Added a --use_cuda_bfloat16 option to the boltz predict command. #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/boltz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ def cli() -> None:
is_flag=True,
help="Whether to not use potentials for steering. Default is False.",
)
@click.option(
"--use_cuda_bfloat16",
is_flag=True,
help="Whether to run Boltz model in bfloat16 format when using CUDA instead of float32 to reduce memory use and allow prediction of 40% larger structures. Prediction accuracy may be reduced. Has no effect if CUDA is not used. Default is False.",
)
def predict(
data: str,
out_dir: str,
Expand All @@ -625,6 +630,7 @@ def predict(
msa_server_url: str = "https://api.colabfold.com",
msa_pairing_strategy: str = "greedy",
no_potentials: bool = False,
use_cuda_bfloat16: bool = False,
) -> None:
"""Run predictions with Boltz-1."""
# If cpu, write a friendly warning
Expand Down Expand Up @@ -761,13 +767,18 @@ def predict(
precision=32,
)

# Compute predictions
trainer.predict(
model_module,
datamodule=data_module,
return_predictions=False,
)
def compute_predictions():
trainer.predict(
model_module,
datamodule=data_module,
return_predictions=False,
)

if use_cuda_bfloat16:
with torch.autocast(device_type='cuda', dtype=torch.bfloat16):
compute_predictions()
else:
compute_predictions()

if __name__ == "__main__":
cli()