feat(it-opt): latent-injection adapter scaffold (step 1)#313
feat(it-opt): latent-injection adapter scaffold (step 1)#313smallfishabc wants to merge 1 commit into
Conversation
Add LatentAdaptedWrapper, a swappable transform on a model's single representation (post-trunk latent `s`) at the featurize/step boundary — the step-1 scaffold for AlphaSAXS-style latent injection / IT-optimization. - Wraps the FlowModelWrapper protocol so samplers, scalers, and eval are unchanged; identity transform (k=1, b=0) is behaviourally a no-op. - Model-agnostic via AttrLatentIO (single attr name: `s` for Boltz, `s_trunk` for Protenix/RF3) — no model packages imported. - Injected latent detached during sampling to preserve existing coordinate-guidance gradients. - Adds unit tests and design docs (roadmap + solution diagrams). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
manzuoni-astera
left a comment
There was a problem hiding this comment.
Thanks for keeping this as a narrowly scoped step-1 scaffold. Treating the optimizer, sampler feature hook, Protenix detach handling, Boltz2 cache recomputation, and real experimental transform as intentional follow-up work, the basic read/transform/write seam looks reasonable.
Before this is marked ready, I think the scaffold contract needs a few corrections:
-
LatentAdaptedWrapperis not currently drop-in for the actual guidance entry point._run_guidancedispatches preprocessing frommodel_wrapper.__class__.__name__and will rejectLatentAdaptedWrapperas unknown (guidance_script_utils.py:444-486). Pure guidance also readsmodel_wrapper.modeldirectly at line 541, while diagnostics and MSA reporting use other concrete-wrapper attributes. The one-line factory wrapping shown in the diagram would therefore fail before sampling. Please either make orchestration decorator-aware or deliberately proxy/unwrap the required model identity and attributes, with a pipeline-level test. -
A wrong
single_attrsilently becomes a no-op (latent_adapter.py:85-88, 172-174), and the test currently enshrines that behavior. Because this string is required configuration, I would prefer a clear error, or an explicit opt-inallow_missingmode, so field drift cannot masquerade as successful adaptation. -
The mock
step()ignores conditioning, so the tests prove tensor replacement but not that rewritten conditioning affects the delegated step. A conditioning-sensitive mock should cover identity equivalence and non-identity propagation.
CI unit tests and typechecks pass across all environments, but lint currently fails with 39 introduced Ruff errors. GPU jobs are awaiting environment approval. With those scaffold-level issues addressed, the deferred model-specific work can reasonably remain in follow-ups.
What
Step-1 scaffold for integrating inference-time optimization (IT-opt) into Sampleworks, ported from the
it_opt/reference forks (Protenix/Boltz/AF3).Adds
LatentAdaptedWrapper— a small, swappable transform on a model's single representation (the post-trunk latents) inserted at thefeaturize→stepconditioning boundary. Currently a deliberately trivial affinek*s + b("pseudo-MLP") so the plumbing and tests are validated before any real module lands.Design
LatentAdaptedWrapper, which itself satisfies theFlowModelWrapperprotocol — samplers, scalers, and eval consume the protocol, so nothing downstream changes. With the identity transform (k=1, b=0) it is behaviourally identical to the model it wraps.AttrLatentIO(sfor Boltz,s_trunkfor Protenix/RF3). No model packages are imported; a 4th/5th model is one more string, not new code.Included
src/sampleworks/models/latent_adapter.py+tests/models/test_latent_adapter.pydocs/latent_adapter/— implementation roadmap,latent_space_optimization.md, and solution diagramsStatus / next steps
Draft — this is the scaffold only. Follow-ups track the migration-notes sequencing (Tier 3 safe cleanups → Tier 1 optimizer-lifetime correctness fix, A/B'd on backbone-RMSD → Tier 2 compute win). Real experimental-signal transform (step 2) comes after this seam is validated.
🤖 Generated with Claude Code