kesunbin/AFGen_2607

Python

0

5 commits

updated Sep 27, 2026

See the code

README

AFGen

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:

  1. Protein-conditioned fine-tuning: The integrated model is fine-tuned on protein–ligand pairs to learn the conditional mapping from target protein sequences to corresponding bioactive molecules.

Molecular generation and downstream evaluation, including molecular property assessment and binding-affinity evaluation, are performed after training and are not additional training stages.

1. Production configuration

ItemSFT
Entry configurationconfig/train_gptvirus_sft.py
Architecture24 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>/

2. Clone the repository and install the environment

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.csv
  • loss_curve.png

Weights & Biases logging is not currently integrated, so no wandb login or WANDB_MODE configuration is required.

3. Prepare the fine-tuning data

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:

ColumnDescription
sequenceProtein amino acid sequence.
SMILESLigand represented as a SMILES string.
pchembl_value_MeanNumeric 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.

kesunbin/AFGen_2607

Python

0

5 commits

updated Sep 27, 2026

See the code

README

AFGen

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:

  1. Protein-conditioned fine-tuning: The integrated model is fine-tuned on protein–ligand pairs to learn the conditional mapping from target protein sequences to corresponding bioactive molecules.

Molecular generation and downstream evaluation, including molecular property assessment and binding-affinity evaluation, are performed after training and are not additional training stages.

1. Production configuration

ItemSFT
Entry configurationconfig/train_gptvirus_sft.py
Architecture24 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>/

2. Clone the repository and install the environment

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.csv
  • loss_curve.png

Weights & Biases logging is not currently integrated, so no wandb login or WANDB_MODE configuration is required.

3. Prepare the fine-tuning data

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:

ColumnDescription
sequenceProtein amino acid sequence.
SMILESLigand represented as a SMILES string.
pchembl_value_MeanNumeric 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.