Torus Flow Matching is a generative model for protein design that focuses on dihedral angles, leveraging the toroidal geometry of these angles. This approach is part of the broader FoldFlow framework and introduces a specialized flow matching technique tailored for the torus manifold.
To use the Torus Flow Matching model, follow these steps to set up the environment: python=3.10
git clone https://github.com/AMark-CS/ChiFlow.git
cd ChiFlow
conda env create -f environment.yaml
conda activate chiflow
pip install -e .To quickly test the Torus Flow Matching model, you can train it on a single protein. This example uses the 2f60 protein:
python runner/train.py local=example model_type=torusThis should converge in approximately 10-20 minutes on a V100 GPU.
For training on the full dataset, ensure the dataset is preprocessed and available. Update the configuration file to specify the dataset paths:
model_type: torus
data:
cluster_path: ./data/processed_pdb/clusters-by-entity-30.txtThen, run the training script:
python runner/train.py model_type=torusTo perform inference using the Torus Flow Matching model, specify the checkpoint path in the configuration file:
inference:
model_type: torus
weights_path: path/to/torus_checkpoint.pthRun the inference script:
python runner/inference.pyYou can also override configurations directly from the command line:
python runner/inference.py inference.weights_path=path/to/new_ckpt.pth inference.model_type=torusAnd the output will be put in the batch_test folder.
This guide explains how to configure and use the torus mode in ChiFlow inference.
ChiFlow now supports configurable torus mode that allows you to choose between:
- Torus Mode (
torus_mode: true): Uses high-dimensional torus flow + NERF for backbone generation - Standard Mode (
torus_mode: false): Uses standard SE(3) flow matching
Add these parameters to your inference.yaml configuration:
inference:
# Enable/disable torus flow mode
torus_mode: true
# Number of sampling steps for torus flow (only used when torus_mode: true)
torus_num_steps: 100# Use: python runner/inference.py --config-name inference_torus_example
inference:
name: chiflow_torus_example
torus_mode: true
torus_num_steps: 100
# ... other settings# Use: python runner/inference.py --config-name inference_standard_example
inference:
name: chiflow_standard_example
torus_mode: false
torus_num_steps: 50 # Ignored when torus_mode is false
# ... other settings# Run inference with torus mode enabled
python runner/inference.py --config-name inference_torus_example# Run inference with standard flow matching
python runner/inference.py --config-name inference_standard_exampleYou can also override the configuration from command line:
# Enable torus mode
python runner/inference.py inference.torus_mode=true inference.torus_num_steps=200
# Disable torus mode
python runner/inference.py inference.torus_mode=false- Uses high-dimensional torus flow matching
- Generates backbone coordinates directly using NERF
- Better for capturing torsional angle distributions
- Configurable sampling steps via
torus_num_steps
- Uses traditional SE(3) flow matching
- Works with existing flow matcher infrastructure
- More stable for certain protein families
- Uses standard
flow.num_tparameter
- ChiFlow Model (
model_name: chiflow): Supports both modes - Other Models: Automatically use standard mode regardless of
torus_modesetting
The system will log which mode is being used:
INFO: Using torus mode for ChiFlow sampling with 100 steps
INFO: Using standard flow matching mode for ChiFlow
INFO: Using SE(3) flow matching mode
- Torus mode not working: Ensure
model_name: chiflowin your model config - Configuration not applied: Check that parameters are under
inference:section - Import errors: Make sure ChiFlow model is properly installed
- Torus mode may be slower but can generate more diverse structures
- Standard mode is faster and more stable for most use cases
- Adjust
torus_num_stepsbased on your quality vs speed requirements