Layers for boltzgen stacked upon other protein models.#49
Open
Layers for boltzgen stacked upon other protein models.#49
Conversation
Migrate reusable protein layers into src/protein/ with CPU-only
implementations and dispatch hooks for GPU acceleration via OnionTile:
- Rigid body types, residue constants, OpenFold utils/features
- LayerNormFirst, LinearFirst with layernorm_first_forward dispatch
- RotaryEmbedding with rotary_pos_emb_forward dispatch
- ESMFoldAttention, ESMMultiheadAttention with flash_attention_forward dispatch
- Triangle{Attention,Multiplication} with combine_projections_forward dispatch
- StructureModule (ESMFoldIPA, AngleResnet, BackboneUpdate)
- ESMFoldEmbedConfig, LayerNormMLP, FoldingTrunk, RelativePosition
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace batched_mul attention with flash attention dispatch hooks (flash_attention_forward, flash_attention_bias_forward) that OnionTile overrides with cuTile kernels. Generalize rotary embeddings to N-D via rotary_pos_emb_forward hook. Add combine_projections_forward hook for cuTENSOR triangle contraction. Optimize TriangleAttention mask=nothing path with direct flash bias format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Routes GPU arrays to ONIONop KernelAbstractions kernels, enabling GPU-accelerated inference on any GPU backend without OnionTile. Handles triangle attention batch broadcasting via repeat expansion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use ONIONop.within_gradient to conditionally choose in-place (inference) vs out-of-place (training) ops in 5 AnyGPUArray layer overrides. Fix in-place mutations in LinearFirst (.+=) and TriangleMultiplicativeUpdate (@.) that broke Zygote on all backends. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…14_pos Wrap non-differentiable constant lookups (NNlib.gather, one_hot_last, convert) in @ignore_derivatives so Zygote treats them as opaque constants instead of tracing through integer indexing that produces corrupted/zero tangents. Gradients for sum(positions) now flow correctly through rot/trans: - C2 test: 0% → 98% nonzero grads - Test B (full trunk): 0% → 96.7% nonzero grads - FD check: 6/6 pass, cosine similarity 1.0, max |AD-FD| ~1e-12 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add PointProjectionMultimer, MultimerInvariantPointAttention, and InvariantPointAttention (alias for ESMFoldIPA) to share IPA code between ESMFold and Alphafold2. Includes GPU-accelerated _flash_ipa_core helper with within_gradient AD guards. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Return scalar one() when dropout is zero (inference mode) - Use rand!(similar(...)) instead of rand() for training path - Prevents CPU/GPU mixing in PairformerNoSeqLayer dropout Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Float32 copies PairWeightedAveraging: replace map-over-S loop with single batched_mul (42x speedup at S=100 N=120, eliminates MSA overhead entirely). Remove wasteful Float32.(x)/T.(x) round-trip tensor copies across all layers (attention, triangular, miniformer, pairformer, OPM, PWA). Data is already Float32 — these were pure memcpy waste. Added eltype assertions to catch mismatches early instead. All 9 GPU REPL API tests pass at 200 steps with clean geometry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Simplify _bg_scaled_dot_product_attention to combine bias + mask and dispatch through flash_attention_bias_forward, which routes to the best available backend (CPU → ONIONop/KA → OnionTile/cuTile). OnionTile now handles non-pow2 head dims transparently via padding_mode=Zero. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #49 +/- ##
==========================================
- Coverage 30.79% 8.35% -22.44%
==========================================
Files 43 73 +30
Lines 867 3219 +2352
==========================================
+ Hits 267 269 +2
- Misses 600 2950 +2350 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
@pangramlabs slop? |
Use zeros_like (AD-safe, @ignore_derivatives) instead of fill!(similar(...)) for zero-padding in _flash_ipa_core. Add within_gradient check for pair aggregation to use out-of-place cat (AD path) vs in-place .= (inference). This fixes AF2 gradient tests on Julia 1.12 where Zygote couldn't differentiate through the in-place operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes the "optimized" branch pr.