This README is the authoritative server-side training guide for AFGen. Run all commands from the repository root.
The proposed framework has one training stages:
Molecular generation and downstream evaluation, including molecular property assessment and binding-affinity evaluation, are performed after training and are not additional training stages.
| Item | SFT |
|---|---|
| Entry configuration | config/train_gptvirus_sft.py |
| Architecture | 24 layers, 16 heads, hidden size 1024 Inherited from the pre-trained model |
| Context length | |
| 512 | |
| 1026 | |
| Parameter count | |
| Approximately 316.64M | |
| Same architecture as the pre-trained model | |
| Default training length | |
| 600,000 iterations | |
| 100,000 iterations per dataset | |
| Checkpoint directory | |
| model_ckpt/pretrain/ | |
| model_ckpt/sft/<dataset_name>/ |
For a new server deployment:
git clone https://github.com/kesunbin/AFGen_2607.git
cd AFGen_2607
conda create -n afgen python=3.12 -y
conda activate afgen
python -m pip install --upgrade pip
# Install the project dependencies, including PyTorch and ESM.
python -m pip install -r requirements.txt
# Check dependency consistency.
python -m pip check
# Verify that PyTorch can access the GPU.
python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA available:', torch.cuda.is_available()); print('GPU count:', torch.cuda.device_count())"
For GPU training, ensure that the installed PyTorch build is compatible
with the server's NVIDIA driver. The CUDA availability check should
return True.
If the repository is already present on the server:
cd AFGen_2607
git pull --ff-only origin main
conda activate afgen
# Install any updated dependencies.
python -m pip install -r requirements.txt
Training logs and loss tracking:
Training progress is printed to the console. When submitted through
run_slurm.sh, standard output and error logs are saved to
logs/slurm-<job_id>.out and logs/slurm-<job_id>.err.
Loss history and loss curves are saved in the checkpoint directory
(default: checkpoints_cross_attention/):
loss_history.csvloss_curve.pngWeights & Biases logging is not currently integrated, so no
wandb login or WANDB_MODE configuration is required.
Prepare a CSV file containing protein–ligand pairs and their affinity labels. Each row represents one protein–ligand pair.
The following column names are required and case-sensitive:
| Column | Description |
|---|---|
sequence | Protein amino acid sequence. |
SMILES | Ligand represented as a SMILES string. |
pchembl_value_Mean | Numeric affinity label on the pChEMBL scale. |
Ensure that protein sequences are non-empty, SMILES strings are valid, and affinity labels are numeric. Missing or non-numeric affinity labels and SMILES strings that cannot be converted to SELFIES are skipped during loading.
Place the prepared CSV file on the training server and specify its absolute path before launching training:
conda activate afgen
# Replace this placeholder with the actual dataset path.
export ALPHACOMPOUND_CSV_PATH="/absolute/path/to/train.csv"
# Verify that the dataset file is accessible.
test -r "$ALPHACOMPOUND_CSV_PATH" && echo "Dataset file is readable."
The training code converts SMILES strings to SELFIES automatically; no separate tokenization or binary data preparation step is required.
By default, protein sequences are truncated to 512 residues, and tokenized molecular sequences are truncated to 128 tokens.
The dataset is split by protein sequence into training, validation, and test subsets, using approximately 80%, 10%, and 10% of the unique protein sequences, respectively, with a default random seed of 42. Grouping uses the truncated protein sequences, so identical truncated sequences remain in the same subset. The proportions of individual protein–ligand pairs may differ.
For single-node training with 8 GPUs, all processes read the same CSV file. No manual division into eight data files is required.
Optional structure input:
To provide protein structures, include a structure_path column
containing paths to existing structure files. Absolute paths are
recommended. Omit this column for sequence-only training.
This README is the authoritative server-side training guide for AFGen. Run all commands from the repository root.
The proposed framework has one training stages:
Molecular generation and downstream evaluation, including molecular property assessment and binding-affinity evaluation, are performed after training and are not additional training stages.
| Item | SFT |
|---|---|
| Entry configuration | config/train_gptvirus_sft.py |
| Architecture | 24 layers, 16 heads, hidden size 1024 Inherited from the pre-trained model |
| Context length | |
| 512 | |
| 1026 | |
| Parameter count | |
| Approximately 316.64M | |
| Same architecture as the pre-trained model | |
| Default training length | |
| 600,000 iterations | |
| 100,000 iterations per dataset | |
| Checkpoint directory | |
| model_ckpt/pretrain/ | |
| model_ckpt/sft/<dataset_name>/ |
For a new server deployment:
git clone https://github.com/kesunbin/AFGen_2607.git
cd AFGen_2607
conda create -n afgen python=3.12 -y
conda activate afgen
python -m pip install --upgrade pip
# Install the project dependencies, including PyTorch and ESM.
python -m pip install -r requirements.txt
# Check dependency consistency.
python -m pip check
# Verify that PyTorch can access the GPU.
python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA available:', torch.cuda.is_available()); print('GPU count:', torch.cuda.device_count())"
For GPU training, ensure that the installed PyTorch build is compatible
with the server's NVIDIA driver. The CUDA availability check should
return True.
If the repository is already present on the server:
cd AFGen_2607
git pull --ff-only origin main
conda activate afgen
# Install any updated dependencies.
python -m pip install -r requirements.txt
Training logs and loss tracking:
Training progress is printed to the console. When submitted through
run_slurm.sh, standard output and error logs are saved to
logs/slurm-<job_id>.out and logs/slurm-<job_id>.err.
Loss history and loss curves are saved in the checkpoint directory
(default: checkpoints_cross_attention/):
loss_history.csvloss_curve.pngWeights & Biases logging is not currently integrated, so no
wandb login or WANDB_MODE configuration is required.
Prepare a CSV file containing protein–ligand pairs and their affinity labels. Each row represents one protein–ligand pair.
The following column names are required and case-sensitive:
| Column | Description |
|---|---|
sequence | Protein amino acid sequence. |
SMILES | Ligand represented as a SMILES string. |
pchembl_value_Mean | Numeric affinity label on the pChEMBL scale. |
Ensure that protein sequences are non-empty, SMILES strings are valid, and affinity labels are numeric. Missing or non-numeric affinity labels and SMILES strings that cannot be converted to SELFIES are skipped during loading.
Place the prepared CSV file on the training server and specify its absolute path before launching training:
conda activate afgen
# Replace this placeholder with the actual dataset path.
export ALPHACOMPOUND_CSV_PATH="/absolute/path/to/train.csv"
# Verify that the dataset file is accessible.
test -r "$ALPHACOMPOUND_CSV_PATH" && echo "Dataset file is readable."
The training code converts SMILES strings to SELFIES automatically; no separate tokenization or binary data preparation step is required.
By default, protein sequences are truncated to 512 residues, and tokenized molecular sequences are truncated to 128 tokens.
The dataset is split by protein sequence into training, validation, and test subsets, using approximately 80%, 10%, and 10% of the unique protein sequences, respectively, with a default random seed of 42. Grouping uses the truncated protein sequences, so identical truncated sequences remain in the same subset. The proportions of individual protein–ligand pairs may differ.
For single-node training with 8 GPUs, all processes read the same CSV file. No manual division into eight data files is required.
Optional structure input:
To provide protein structures, include a structure_path column
containing paths to existing structure files. Absolute paths are
recommended. Omit this column for sequence-only training.