Skip to content

Add an RFD4-Proteina LoRA training example - #15155

Open
kierandidi wants to merge 12 commits into
huggingface:mainfrom
kierandidi:rfd4-proteina-lora-example
Open

kierandidi wants to merge 12 commits into
huggingface:mainfrom
kierandidi:rfd4-proteina-lora-example

Conversation

@kierandidi

@kierandidi kierandidi commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15162

Adds a LoRA training example for RFD4-Proteina, with an Accelerate script, README and requirements. It trains the denoiser on annotated CIFs while keeping the autoencoder frozen, and saves adapters through the standard Diffusers LoRA helpers.

The recipe uses rank 32 / alpha 64 and flow-matching losses for backbone coordinates and local latents. It leaves out the native trainer's auxiliary sequence and insertion losses. CIF preparation is cached, and unusable structures are filtered before distributed sharding.

Cyclic peptide check

Trained on 255 CPSea complexes for 1,000 steps on two H200s, starting from weights matched to the updated native release. We tested the PD-1 cyclic peptide inputs with the same 16 seeds per chemistry at steps 0, 500 and 1,000. PD-1 was excluded from fine-tuning.

PD-1 contacts and training loss

Median contacts (heavy-atom pairs within 5 Å) rose from 187.5→229.5, 150.5→262 and 160.5→220 for head-to-tail, disulfide and isopeptide designs. Contacts per peptide atom also increased. Shading shows 95% seed-bootstrap intervals; loss uses EMA α=0.02 over faint raw values.

This is one target and one training run. Head-to-tail closure stayed at 16/16, but disulfide fell from 12/16 to 6/16 and isopeptide from 5/16 to 1/16. More contacts alone don't establish better binding or overall design quality.

@github-actions github-actions Bot added examples size/L PR with diff > 200 LOC labels Oct 30, 2026
Trains PEFT adapters on the denoiser with the released recipe, saved in the format RFD4ProteinaPipeline.load_lora_weights reads.
@kierandidi
kierandidi force-pushed the rfd4-proteina-lora-example branch from d23d344 to 024d284 Compare October 30, 2026 12:34
@github-actions

Copy link
Copy Markdown
Contributor

Hi @kierandidi, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Fixes #1234) to the PR description so the issue is linked. See the contribution guide for more details. If this PR intentionally does not fix a tracked issue, a maintainer can add the no-issue-needed label to silence this reminder.

Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice.

Once the PR links an issue (or gets the no-issue-needed label), you can ignore this message — it stays here as a comment, but it no longer applies.

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Some minor feedback.

In general, we should try to follow the patterns already establised in the existing training scripts for LoRA, when it comes to loading and saving adapters.

Could you also show us the results from a successful run?

Comment thread examples/rfd4_proteina/README.md Resolved
Save the adapter the way the current LoRA examples do: the PEFT state dict
goes out unconverted, and `_collate_lora_metadata` records rank, alpha and
target modules alongside it.

Resolve `--resume_from_checkpoint` against `--output_dir`, so naming a
checkpoint works as well as passing its path.
@github-actions github-actions Bot added tests and removed fixes-issue labels Nov 8, 2026
@github-actions github-actions Bot removed the tests label Nov 8, 2026

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some further comments.

Can we also see some validation examples where LoRA training provided an advantage?

Comment thread examples/rfd4_proteina/README.md Resolved
Comment thread examples/rfd4_proteina/README.md Resolved
Train on 40 of the fifty published structures and score the remaining ten
with the adapter toggled on and off over identical noise draws. Held-out
flow-matching loss falls 11%, on every held-out structure.
@linoytsaban

linoytsaban commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

@kierandidi This is cool!
A few things we support in other LoRA training examples that I noticed are missing here and I think would be great for usability:

  • push_to_hub - a flag to automatically push the trained checkpoint(s) to a hub repo (e.g. here)
  • model card - an automated .md file that contains all the relevant details of the trained LoRA - inference snippet, base model, dataset used etc. Especially relevant when push_to_hub is enabled but can be helpful for locally saved LoRAs as well
  • dataset_name - I assume its already the plan, but once the datasets PR goes through it would be great to add that as well e.g. like we have in here.

cc @sayakpaul as well

Every run now writes a model card next to the adapter, naming the base
checkpoint and the structures trained on, with a snippet that generates from
the result. `--push_to_hub`, `--hub_model_id` and `--hub_token` upload the
adapter and that card at the end of training, as the other LoRA examples do.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples no-issue-needed for PRs that do not require link to an issue size/L PR with diff > 200 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No LoRA fine-tuning example for RFD4-Proteina

5 participants