Scale Batch Inference with Ray
In this tutorial, you scale Boltz-2 batch inference across every visible GPU with Ray. You create a worklist of independent protein requests, configure one complete model replica per GPU, run the pipeline, and inspect completion, throughput, and confidence summaries.
The complete runnable script is available at
examples/quickstart/boltz2_ray.py. The sections
below explain its worklist, Ray configuration, and output.
Ray replicas process independent requests concurrently. They do not split one structure prediction across several GPUs.
Before You Begin
Complete the installation on a system with at least one supported GPU. Run the serial Quickstart first to verify the wheel, checkpoint, and metadata.
If you do not have a repository checkout, create quickstart_ray.py with the
following example. Both versions configure the Ray workers to import BioNeMo
Inference Runtime (BioIR) from the installed wheel rather than an editable
checkout.
Start at the top-level imports.
Understand the Worklist
The first part of quickstart_ray.py detects the visible GPUs and creates one
prediction request for each GPU:
This block creates the Ray worklist:
torch.cuda.device_count()determines how many complete model replicas the example can run and stops with an error when no GPU is visible.- Each
InputRequestcontains protein chainA1, the 1UBQ ubiquitin sequence, and an inline, query-only unpaired MSA. - Each request has a unique identifier, such as
1UBQ-1or1UBQ-2.__record_idbecomes the CIF filename. - The number of requests matches the number of replicas so the example verifies that each replica can complete one prediction.
Use a larger, representative worklist when measuring sustained throughput. Refer to Input Requests for other biomolecule types, MSAs, and templates.
Understand the Pipeline Configuration
The next block configures deterministic feature generation and one Ray engine actor per visible GPU:
The configuration controls the distributed prediction pipeline:
executor_backend="ray"sends rows through the Ray Data pipeline.EngineStageConfig(compute=replicas)creates one engine actor per visible GPU. Each actor reserves one GPU and loads one complete Boltz-2 model replica.num_sampling_steps=50shortens the diffusion stage for this example.random_seed=42seeds feature generation. The worker setup hook also seeds PyTorch before each worker loads its pipeline stage.WriterStageConfiguses an absolute path captured before the workers change directories and writes one CIF structure per request.should_continue_on_error=Falsestops the example if any request fails.
Refer to EngineProcessorConfig,
Runtime Args, and
Ray Multi-GPU Replicas for the available
controls.
Understand Ray Execution
The next block starts Ray, materializes the worklist, waits for every result, and shuts Ray down:
The script starts workers from /tmp so a mounted source checkout cannot
shadow the installed wheel. ray.init() disables the dashboard and verbose
driver logs, then runs seed_worker in each worker process.
ray.data.from_items(rows) creates the distributed dataset.
build_processor(config) assembles the Ray pipeline, and materialize() waits
for every request to complete. The finally block records elapsed worklist time
and shuts Ray down even if inference fails.
Understand the Results
The final block calculates whole-worklist throughput and builds a compact summary from one representative prediction:
The summary reports:
completed_structures— the number of successful outputs compared with the number of submitted requests.worklist_wall_s— the elapsed time for materializing the complete worklist.structures_per_hour— worklist throughput across all visible GPUs.structures_per_gpu_hour— aggregate throughput divided by the number of replicas.example— the output path and confidence metrics from the first result, without printing the complete pLDDT and PAE arrays.
Refer to Outputs for the complete output-row schema.
Run the Example
From the repository root, run the maintained example:
If you copied the example into a standalone file, run that file instead:
Example Output
The output path starts under the directory where you launch the script. Timing and scores can vary across GPUs, systems, and releases.
One NVIDIA H100 80 GB HBM3
This captured run used one 700 W H100:
Eight NVIDIA H200 NVL GPUs
This captured run used eight 600 W H200 NVL GPUs:
Treat these values as successful-run examples, not benchmarks. Each run uses
only one short request per GPU and includes pipeline and model setup in the
worklist time. The stable result is that completed_structures matches the
request count and every reported output path contains a non-empty CIF file.
Next Steps
- Configure stage resources and larger worklists in Ray Multi-GPU Replicas.
- Review controlled performance measurements in Benchmarks.
- Check supported accelerators in the Support Matrix.