Skip to content

Worktree feature torsion decomposition#1

Open
eightmm wants to merge 4 commits intomainfrom
worktree-feature-torsion-decomposition
Open

Worktree feature torsion decomposition#1
eightmm wants to merge 4 commits intomainfrom
worktree-feature-torsion-decomposition

Conversation

@eightmm
Copy link
Owner

@eightmm eightmm commented Mar 6, 2026

No description provided.

eightmm and others added 4 commits March 6, 2026 13:52
Model changes:
- Add output_mode='torsion' to ProteinLigandFlowMatching
- Translation/rotation heads: mean-pooled ligand features → EquivariantMLP → 3D
- Torsion head: src/dst node scalar concat → MLP → 1 scalar per rotatable bond
- Zero-initialized outputs with learnable scales for stable training

Data changes:
- Dataset returns torsion_data with translation, rotation, torsion_changes,
  rotatable_edges, mask_rotate (computed on-the-fly or from pre-computed data)

Loss:
- Component-wise weighted MSE (translation, rotation, torsion)
- Circular loss for torsion angles (wrap to [-pi, pi])
- Optional coordinate reconstruction loss (end-to-end supervision)

Sampling:
- sample_trajectory_torsion: Euler ODE in decomposed space
- Apply order: Torsion → Translation → Rotation (DiffDock convention)
- Rodrigues rotation for both torsion and rigid body rotation

Config:
- configs/train_torsion.yaml with torsion-specific loss weights

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Training:
- train_step dispatches to _train_step_torsion or _train_step_cartesian
  based on config output_mode
- Torsion mode: samples timestep, interpolates coordinates, predicts
  decomposed velocities, computes component-wise loss
- WandB logs torsion-specific metrics (loss_trans, loss_rot, loss_tor)
- Progress bar shows component losses in torsion mode

Validation:
- Uses sample_trajectory_torsion for ODE integration in torsion mode
- Falls back to cartesian Euler/RK4 for cartesian mode
- Uses generate_timestep_schedule from sampling.py (DRY)

Data:
- collate_flowfix_batch now handles torsion_data collation
- _collate_torsion_data: concatenates variable-length rotatable bonds,
  offsets atom indices per molecule, expands mask_rotate to batch size

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Revert all torsion changes from original files (flowmatching.py,
dataset.py, losses.py, sampling.py, train.py, model_builder.py)
and create clean separate files instead:

New files:
- src/models/flowmatching_torsion.py
    ProteinLigandFlowMatchingTorsion inherits base model,
    adds translation/rotation/torsion output heads
- src/data/dataset_torsion.py
    FlowFixTorsionDataset inherits FlowFixDataset,
    collate_torsion_batch handles variable-length rotatable bonds
- src/utils/losses_torsion.py
    compute_se3_torsion_loss with circular torsion loss,
    coord reconstruction via Rodrigues rotation
- src/utils/sampling_torsion.py
    sample_trajectory_torsion for Euler ODE in decomposed space
- train_torsion.py
    FlowFixTorsionTrainer - standalone torsion training script

Original files unchanged - cartesian mode works exactly as before.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ison

- Remove 29 dead files: unused utils (train.py, loss_utils.py, metrics.py, plot.py),
  legacy configs (overfit_*, rectified_flow*), debug scripts, and SLURM scripts
- Remove unused joint model files (config, SLURM script, test)
- Reorganize inference results into output/cartesian_v4_baseline/
- Restructure reports/ into cartesian/ and torsion/ subdirectories
- Add torsion architecture doc and results placeholder
- Update all references from train_joint.yaml to train.yaml
- Fix mermaid diagrams: use TB layout for complex diagrams

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant