Repository navigation
Add RFD4-Proteina - #15088
Add RFD4-Proteina#15088
Conversation
Adds the RFD4-Proteina pipeline with its transformer, autoencoder and per-modality schedulers, a LoRA loader mixin, a checkpoint conversion script, tests and documentation.
sayakpaul
left a comment
There was a problem hiding this comment.
Thanks! I left some comments most of which are centered around not trying to pass dicts to promote the use of tuples (to keep things explicitly visible to the callers and readers).
|
/diffusers-bot pytest tests/pipelines/rfd4_proteina/test_pipeline_rfd4_proteina.py tests/models/autoencoders/test_models_autoencoder_rfd4_proteina.py tests/models/transformers/test_models_transformer_rfd4_proteina.py |
|
✅ |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…ple inputs prepare_latents returns a tuple and the sampling loop works on named tensors. The pipeline output has bb_ca, local_latents and clean_* fields instead of dicts, and the callback tensors are named. The pipeline properties move below __init__, the transformer return annotation names its tuple, LoRA moves from the loaders page to the pipeline docs, and the pipeline tests spell out their helpers.
…ckpoint The transformer always recycles the trunk, updates the pair representation with triangle multiplication (without bias) and aligns the chirality feature, as the released checkpoint does. The converter now checks that a checkpoint has exactly these settings instead of carrying them as options.
… the autoencoder to its released features The scheduler test helper takes its options by name, and the usage and batching examples pass the five required inputs by name. The autoencoder's default encoder features now match the released checkpoint, and the decoder moves its allowed-residue table to the token types' device.
Restore the LoRA mixin on the loaders page, which utils/check_support_list.py requires for every LoRA loader mixin, and keep the mention in the pipeline docs. Compose the attention and torch.compile testers on the models, drop the model-level LoRA tests that the first pull request should not carry, and make the pipeline's backbone-noising step public as a lifecycle method.
|
Thanks, went through all of it and applied the same ideas across the rest of the PR, not just the lines you commented on (tensors instead of dicts, explicit names, only what the release needs). Details in the replies below. |
…ding The number of steps is fixed by the released recipe and is the length of recycle_depths. Inverse folding starts both modalities at time zero, so its latents are noise and the encoded input was only consuming random draws.
|
@sayakpaul @yiyixuxu everything from the review is addressed now (replies are in the threads, and they're resolved). Do things look fine, or is there anything else you need? |
yiyixuxu
left a comment
There was a problem hiding this comment.
thanks a lot for the PR!
we are very very impressed on how many changes got applied within such a short time frame.
super excited to welcome first protein model into diffusers! will merge once CI passes
What does this PR do?
Adds RFD4-Proteína, a flow-matching model from the Baker Lab and NVIDIA that designs protein sequences and all-atom structures together, conditioned on a binding target, enzyme motif, ligand or other molecular context.
RFD4ProteinaPipelinewithRFD4ProteinaTransformer(denoiser),RFD4ProteinaAutoencoder(vae) and twoRFD4ProteinaSchedulerinstances, one for the backbone and one for the local latentsnum_designs_per_promptfor several designs per inputRFD4ProteinaLoraLoaderMixin), group offloading, regional compilation and quantization supportThe pipeline takes prepared feature tensors. Annotated-CIF preparation and writing live in the separate
rfd4-proteina-preppackage, so the library has no structure-parsing dependency.Weights (private release preview): https://huggingface.co/nvidia/RFD4-Proteina-Diffusers
Example output and how to read it
What goes in
An annotated CIF file says, for every residue and atom, what is given (kept fixed) and what the model should generate.
prepare_ciffromrfd4-proteina-prepturns it into the tensors the pipeline takes. The task is chosen by the annotations, not by a pipeline argument: fixing a target and leaving a chain free designs a binder, fixing a few motif atoms designs a scaffold, fixing the backbone designs a sequence.What comes out
coords_nm(batch, tokens, 37, 3)atom_mask.residue_type(batch, tokens)-1for tokens the model did not generate.emit_mask(batch, tokens)atom_mask(batch, tokens, 37)A token is a residue for proteins and nucleic acids and a single atom for ligands.
write_cifcombines these tensors with the input annotations into the output CIF, so the given context and the generated parts end up in one file.How to read the figures
Each figure shows the C-alpha trace (one point per residue, joined along the chain) of the input on the left and the output on the right, in the same orientation. Grey is held fixed from the input, colour is generated by the model, and red dots are ligand or motif atoms. Where an input has no coordinates for something (a ligand identity, or nothing at all), the left panel says so.
What a reasonable result looks like
The checks below test two things: the output respects what was given, and the generated structure is physically sensible. All six are one sample with seed 42, BF16 and the 60-step recipe on one H200 (4 to 8 s each).
For every example, C-alpha spacing within a chain is about 3.8 Å (the inverse-folding input has one unresolved gap), and no two residues that are not neighbours in sequence have C-alpha atoms closer than 3.9 Å.
These checks show that the output is well formed and follows the conditioning. They do not show that a design binds, folds or is catalytically active. As with other generative design models, designs are meant to be filtered afterwards, for example by refolding the generated sequence with a structure predictor and comparing it with the generated structure.
Verification
make styleandmake fix-copiesare clean.Earlier review rounds from @sayakpaul and @yiyixuxu happened in a private staging PR and are addressed here.