leminhhung0101 commited on
Commit
d12deb1
·
verified ·
1 Parent(s): ae2d5eb

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +920 -0
README.md ADDED
@@ -0,0 +1,920 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EviRNA-NOVA
2
+
3
+ **EviRNA-NOVA** is a multimodal RNA 3D structure prediction research pipeline that combines nucleotide sequence information, RibonanzaNet2 representations, MSA-derived features, secondary-structure/base-pair priors, a Pairformer-style backbone, and flow-based coordinate generation.
4
+
5
+ The current codebase is designed primarily for:
6
+
7
+ - Stanford RNA 3D Folding–style datasets.
8
+ - Multi-stage training on NVIDIA T4/L4 GPUs.
9
+ - Checkpoint-based training continuation.
10
+ - Standalone inference on a new RNA test folder.
11
+ - Generation of multiple 3D conformers for each RNA.
12
+
13
+ > **Status:** Research / experimental. This is not a clinical model or a validated RNA structure tool for high-stakes biological decision-making.
14
+
15
+ ---
16
+
17
+ ## 1. Model Objective
18
+
19
+ The main input is an RNA sequence:
20
+
21
+ ```text
22
+ AUGCGGAUACCGUAAGCU...
23
+ ```
24
+
25
+ EviRNA-NOVA builds multiple evidence sources:
26
+
27
+ ```text
28
+ RNA sequence
29
+ │
30
+ ├── Sequence embedding
31
+ ├── RibonanzaNet2 single features
32
+ ├── RibonanzaNet2 pair features
33
+ ├── MSA features
34
+ ├── Secondary-structure / base-pair priors
35
+ └── Template evidence (when available)
36
+ │
37
+ ▼
38
+ Dynamic Evidence Router
39
+ │
40
+ ▼
41
+ Pairformer
42
+ │
43
+ ▼
44
+ Geometry heads
45
+ │
46
+ ▼
47
+ E(3)-aware / flow module
48
+ │
49
+ ▼
50
+ 3D coordinates
51
+ ```
52
+
53
+ The final output is one or more RNA structures:
54
+
55
+ ```text
56
+ [N, 3]
57
+ ```
58
+
59
+ where `N` is the number of nucleotides and the three dimensions correspond to `x, y, z` coordinates.
60
+
61
+ ---
62
+
63
+ ## 2. High-Level Architecture
64
+
65
+ ### 2.1 Sequence Branch
66
+
67
+ The RNA sequence is encoded into nucleotide indices and residue-level embeddings.
68
+
69
+ Main nucleotide symbols:
70
+
71
+ ```text
72
+ A
73
+ C
74
+ G
75
+ U
76
+ N / unknown
77
+ ```
78
+
79
+ The sequence branch provides residue representations and basic pair priors.
80
+
81
+ ---
82
+
83
+ ### 2.2 RibonanzaNet2 Branch
84
+
85
+ RibonanzaNet2 is used as a frozen feature extractor.
86
+
87
+ For an RNA of length `N`, the pipeline produces:
88
+
89
+ ```text
90
+ single feature : [N, D_single]
91
+ pair feature : [N, N, D_pair]
92
+ ```
93
+
94
+ The current NOVA configuration typically uses projected dimensions:
95
+
96
+ ```text
97
+ D_single = 128
98
+ D_pair = 16
99
+ ```
100
+
101
+ RibonanzaNet2 features must be generated for the actual new RNA sequences during inference. They must not be replaced with random or reused features from unrelated targets.
102
+
103
+ ---
104
+
105
+ ### 2.3 MSA Branch
106
+
107
+ If the test folder contains:
108
+
109
+ ```text
110
+ MSA/
111
+ ```
112
+
113
+ the pipeline can use multiple sequence alignments to construct:
114
+
115
+ - nucleotide frequencies,
116
+ - conservation statistics,
117
+ - entropy,
118
+ - co-variation / pair compatibility,
119
+ - base-pair compatibility.
120
+
121
+ If no MSA is available, the inference-only pipeline can use a **query-only fallback** so that the model can still run.
122
+
123
+ ---
124
+
125
+ ### 2.4 Secondary-Structure / Base-Pair Evidence
126
+
127
+ The pipeline constructs priors such as:
128
+
129
+ ```text
130
+ A-U
131
+ U-A
132
+ G-C
133
+ C-G
134
+ G-U
135
+ U-G
136
+ ```
137
+
138
+ These can be combined with MSA compatibility and an external base-pair map when available.
139
+
140
+ This information becomes an independent evidence source for each nucleotide pair `(i, j)`.
141
+
142
+ ---
143
+
144
+ ### 2.5 Dynamic Evidence Trust / Router
145
+
146
+ The model does not simply concatenate all modalities.
147
+
148
+ For each nucleotide pair `(i, j)`, the router learns weights for evidence sources such as:
149
+
150
+ ```text
151
+ Sequence
152
+ RibonanzaNet2
153
+ MSA
154
+ Template
155
+ Secondary structure
156
+ ```
157
+
158
+ Conceptually:
159
+
160
+ \[
161
+ z_{ij} = \sum_k w^{(k)}_{ij} E^{(k)}_{ij}
162
+ \]
163
+
164
+ with:
165
+
166
+ \[
167
+ \sum_k w^{(k)}_{ij} = 1
168
+ \]
169
+
170
+ This allows the model to dynamically change how much it trusts each modality for different nucleotide pairs.
171
+
172
+ ---
173
+
174
+ ## 3. Pairformer Backbone
175
+
176
+ The fused pair representation is processed through multiple Pairformer blocks.
177
+
178
+ The backbone may include:
179
+
180
+ - pair transitions,
181
+ - triangle-style updates,
182
+ - axial attention,
183
+ - node-to-pair and pair-to-node interactions,
184
+ - recycling.
185
+
186
+ A typical Tesla T4 profile is approximately:
187
+
188
+ ```text
189
+ d_node ≈ 160
190
+ d_pair ≈ 96
191
+ pair blocks ≈ 8
192
+ recycles ≈ 2
193
+ ```
194
+
195
+ Larger profiles can use wider representations and more blocks on stronger GPUs.
196
+
197
+ ---
198
+
199
+ ## 4. Geometry Heads
200
+
201
+ The Pairformer representation is supervised through several geometry-related tasks:
202
+
203
+ ```text
204
+ distance
205
+ distogram
206
+ contact
207
+ base-pair
208
+ stacking
209
+ orientation
210
+ pair confidence
211
+ ```
212
+
213
+ For example, the predicted pairwise distance is:
214
+
215
+ \[
216
+ \hat d_{ij}
217
+ \]
218
+
219
+ and the ground-truth distance is:
220
+
221
+ \[
222
+ d_{ij} = \|x_i - x_j\|
223
+ \]
224
+
225
+ The distogram head predicts a probability distribution over distance bins rather than only a single continuous value.
226
+
227
+ ---
228
+
229
+ ## 5. Coordinate Generation with Flow
230
+
231
+ NOVA uses a flow-style coordinate generation module.
232
+
233
+ During training:
234
+
235
+ ```text
236
+ native coordinates x1
237
+ +
238
+ starting/noisy coordinates x0
239
+ ↓
240
+ intermediate xt
241
+ ↓
242
+ predict velocity
243
+ ↓
244
+ flow loss
245
+ ```
246
+
247
+ A simple interpolation is:
248
+
249
+ \[
250
+ x_t = (1-t)x_0 + tx_1
251
+ \]
252
+
253
+ with target velocity:
254
+
255
+ \[
256
+ v^* = x_1 - x_0
257
+ \]
258
+
259
+ The model learns:
260
+
261
+ \[
262
+ v_\theta(x_t,t)
263
+ \]
264
+
265
+ to move a noisy or initial structure toward the target RNA structure.
266
+
267
+ ---
268
+
269
+ ## 6. Training Curriculum
270
+
271
+ The default training curriculum contains five stages:
272
+
273
+ | Stage | Epochs | Purpose |
274
+ |---|---:|---|
275
+ | `S1_geometry_warmup` | 8 | Geometry / Pairformer warm-up |
276
+ | `S2_flow_warmup` | 6 | Flow training |
277
+ | `S3_joint_geometry_flow` | 16 | Joint geometry + flow |
278
+ | `S4_teacher_distillation` | 8 | Teacher/KD stage when a teacher is available |
279
+ | `S5_temporal_safe_finetune` | 10 | Final fine-tuning |
280
+
281
+ Default total:
282
+
283
+ ```text
284
+ 48 epochs
285
+ ```
286
+
287
+ If the code is launched with `--epochs N`, the curriculum may be proportionally rescaled.
288
+
289
+ ---
290
+
291
+ ## 7. Mixed Precision and Numerical Stability
292
+
293
+ The implementation is designed to avoid several common mixed-precision failures on Tesla T4 GPUs.
294
+
295
+ ### Neural Layers
296
+
297
+ ```text
298
+ FP16 / AMP
299
+ ```
300
+
301
+ is used for Transformer, Pairformer, and MLP operations to reduce memory usage.
302
+
303
+ ### Geometry-Sensitive Operations
304
+
305
+ The following operations are forced to FP32:
306
+
307
+ ```text
308
+ SVD
309
+ Kabsch alignment
310
+ torch.cdist
311
+ coordinate geometry
312
+ distance-target construction
313
+ ```
314
+
315
+ This avoids failures such as:
316
+
317
+ ```text
318
+ svd_cuda_gesvdjBatched not implemented for 'Half'
319
+ ```
320
+
321
+ Confidence-related binary classification uses:
322
+
323
+ ```python
324
+ binary_cross_entropy_with_logits
325
+ ```
326
+
327
+ instead of applying BCE directly to a sigmoid output inside autocast.
328
+
329
+ ---
330
+
331
+ ## 8. Gradient Checkpointing
332
+
333
+ Pairformer blocks support activation checkpointing to reduce VRAM usage.
334
+
335
+ An important checkpointing issue was addressed in later versions: checkpoint closures should not capture loop variables such as `blk` through a lambda.
336
+
337
+ Avoid:
338
+
339
+ ```python
340
+ checkpoint(lambda x, z: blk(x, z, ...), ...)
341
+ ```
342
+
343
+ when the captured block may change before backward recomputation.
344
+
345
+ The implementation instead checkpoints the actual module/block directly so that forward and backward recomputation use the same graph.
346
+
347
+ ---
348
+
349
+ ## 9. Training Data
350
+
351
+ The training pipeline was originally designed around files such as:
352
+
353
+ ```text
354
+ train_sequences.csv
355
+ train_labels.csv
356
+ validation_sequences.csv
357
+ validation_labels.csv
358
+ MSA/
359
+ PDB_RNA/
360
+ extra/
361
+ ```
362
+
363
+ The split policy is:
364
+
365
+ 1. Split at the original RNA target level first.
366
+ 2. Do not crop before splitting.
367
+ 3. Long RNAs are cropped/windowed only after they belong to FIT or CALIB.
368
+ 4. Crops from the same source RNA must not appear in both FIT and CALIB.
369
+
370
+ This is intended to reduce data leakage.
371
+
372
+ ---
373
+
374
+ ## 10. Long-RNA Handling
375
+
376
+ Pairwise representations become expensive as sequence length grows because memory scales approximately with:
377
+
378
+ \[
379
+ O(N^2)
380
+ \]
381
+
382
+ Training commonly uses:
383
+
384
+ ```text
385
+ crop_len = 256
386
+ crop_stride = 192
387
+ ```
388
+
389
+ For inference, long RNAs can be processed using a windowed strategy:
390
+
391
+ 1. Generate new RibonanzaNet2 features for the RNA.
392
+ 2. Split NOVA inference into overlapping windows.
393
+ 3. Generate coordinates for each window.
394
+ 4. Align overlapping regions using Kabsch alignment.
395
+ 5. Stitch the windows into a full-length structure.
396
+
397
+ ---
398
+
399
+ # 11. Standalone Inference on a New Folder
400
+
401
+ Recommended inference scripts include:
402
+
403
+ ```text
404
+ EviRNA_NOVA_INFERENCE_ONLY_NEW_FOLDER_V19.py
405
+ ```
406
+
407
+ or the direct-path variant:
408
+
409
+ ```text
410
+ EviRNA_NOVA_INFERENCE_DIRECT_PATHS_V20.py
411
+ ```
412
+
413
+ Inference-only execution does **not** require:
414
+
415
+ ```text
416
+ NOVA_history.csv
417
+ split_fit_targets.csv
418
+ split_calib_targets.csv
419
+ curriculum_fit_windows.csv
420
+ curriculum_calib_windows.csv
421
+ training evidence_cache.pkl
422
+ optimizer state
423
+ scheduler state
424
+ ```
425
+
426
+ Only the following are required:
427
+
428
+ ```text
429
+ 1. new test folder
430
+ 2. NOVA checkpoint
431
+ 3. RibonanzaNet2 checkpoint
432
+ 4. output directory / GPU runtime
433
+ ```
434
+
435
+ ---
436
+
437
+ ## 12. New Test Folder
438
+
439
+ Minimum structure:
440
+
441
+ ```text
442
+ MY_NEW_TEST/
443
+ └── test_sequences.csv
444
+ ```
445
+
446
+ Recommended structure:
447
+
448
+ ```text
449
+ MY_NEW_TEST/
450
+ ├── test_sequences.csv
451
+ ├── MSA/
452
+ │ ├── RNA001.a3m
453
+ │ ├── RNA002.a3m
454
+ │ └── ...
455
+ ├── BP/ # optional
456
+ └── sample_submission.csv # optional
457
+ ```
458
+
459
+ ### Example `test_sequences.csv`
460
+
461
+ ```csv
462
+ target_id,sequence
463
+ RNA001,GGGAAACCCUUUGGG
464
+ RNA002,AUGCGGAUACCGUAAGCU
465
+ RNA003,GGCUAUAGCUCAGUUGGU
466
+ ```
467
+
468
+ ---
469
+
470
+ ## 13. NOVA Checkpoint
471
+
472
+ The trained model checkpoint is typically named:
473
+
474
+ ```text
475
+ NOVA_last.pt
476
+ ```
477
+
478
+ or:
479
+
480
+ ```text
481
+ NOVA_best.pt
482
+ ```
483
+
484
+ For inference, the checkpoint should contain at least:
485
+
486
+ ```text
487
+ state_dict
488
+ nova_cfg
489
+ foundation_single_dim
490
+ foundation_pair_dim
491
+ ```
492
+
493
+ Additional fields such as:
494
+
495
+ ```text
496
+ optimizer_state
497
+ scheduler_state
498
+ scaler_state
499
+ stage
500
+ stage_epoch
501
+ ```
502
+
503
+ are useful for training continuation but are not required for inference.
504
+
505
+ ---
506
+
507
+ ## 14. RibonanzaNet2 Checkpoint
508
+
509
+ The NOVA checkpoint does not include the full RibonanzaNet2 model.
510
+
511
+ Inference on new RNA sequences therefore requires a separate RibonanzaNet2 checkpoint.
512
+
513
+ A compatible bundle may look like:
514
+
515
+ ```text
516
+ ribonanzanet2_checkpoint/
517
+ ├── Network.py
518
+ ├── pairwise.yaml
519
+ └── pytorch_model_fsdp.bin
520
+ ```
521
+
522
+ If Kaggle is offline, this bundle must be added as an input before inference.
523
+
524
+ ---
525
+
526
+ ## 15. Direct-Path Inference
527
+
528
+ The script:
529
+
530
+ ```text
531
+ EviRNA_NOVA_INFERENCE_DIRECT_PATHS_V20.py
532
+ ```
533
+
534
+ is designed so that the main paths are edited directly near the top of the file.
535
+
536
+ Example:
537
+
538
+ ```python
539
+ DIRECT_TEST_FOLDER = (
540
+ "/kaggle/input/datasets/USERNAME/MY_NEW_TEST"
541
+ )
542
+
543
+ DIRECT_NOVA_CHECKPOINT = (
544
+ "/kaggle/input/datasets/USERNAME/NOVA_MODEL/NOVA_last.pt"
545
+ )
546
+
547
+ DIRECT_RNET2_CHECKPOINT = (
548
+ "/kaggle/input/datasets/USERNAME/RIBONANZANET2/"
549
+ "ribonanzanet2_checkpoint"
550
+ )
551
+
552
+ DIRECT_OUT_DIR = (
553
+ "/kaggle/working/EVIRNA_NOVA_INFERENCE"
554
+ )
555
+ ```
556
+
557
+ Then run:
558
+
559
+ ```bash
560
+ !CUDA_VISIBLE_DEVICES=0 \
561
+ python EviRNA_NOVA_INFERENCE_DIRECT_PATHS_V20.py
562
+ ```
563
+
564
+ ---
565
+
566
+ ## 16. Inference Outputs
567
+
568
+ A typical output directory is:
569
+
570
+ ```text
571
+ EVIRNA_NOVA_INFERENCE/
572
+ │
573
+ ├── test_manifest.csv
574
+ │
575
+ ├── rnet2_features_new_test/
576
+ │ ├── RNA001.npz
577
+ │ ├── RNA002.npz
578
+ │ └── ...
579
+ │
580
+ ├── evidence_new_test.pkl
581
+ ├── prediction_top5.csv
582
+ ├── submission.csv
583
+ ├── prediction_summary.csv
584
+ ├── router_audit.csv
585
+ └── inference_manifest.json
586
+ ```
587
+
588
+ ### `prediction_top5.csv`
589
+
590
+ Each nucleotide can have five candidate coordinate sets:
591
+
592
+ ```text
593
+ ID
594
+ resname
595
+ resid
596
+ x_1 y_1 z_1
597
+ x_2 y_2 z_2
598
+ x_3 y_3 z_3
599
+ x_4 y_4 z_4
600
+ x_5 y_5 z_5
601
+ ```
602
+
603
+ ### `prediction_summary.csv`
604
+
605
+ This file may include:
606
+
607
+ ```text
608
+ target_id
609
+ length
610
+ inference_mode
611
+ number_of_windows
612
+ candidate_score_1
613
+ ...
614
+ candidate_score_5
615
+ ```
616
+
617
+ ### `router_audit.csv`
618
+
619
+ This file can be used to inspect evidence usage:
620
+
621
+ ```text
622
+ sequence
623
+ RibonanzaNet2
624
+ MSA
625
+ template
626
+ secondary_structure
627
+ ```
628
+
629
+ ---
630
+
631
+ ## 17. RibonanzaNet2 Cache for New Test Data
632
+
633
+ RibonanzaNet2 cache from an old dataset must not be reused for unrelated new RNA sequences.
634
+
635
+ The inference pipeline creates:
636
+
637
+ ```text
638
+ OUT_DIR/
639
+ └── rnet2_features_new_test/
640
+ ```
641
+
642
+ Each RNA receives a file such as:
643
+
644
+ ```text
645
+ RNA001.npz
646
+ ```
647
+
648
+ containing:
649
+
650
+ ```text
651
+ single
652
+ pair
653
+ ```
654
+
655
+ If inference is interrupted, valid feature files can be reused on the next run.
656
+
657
+ To force complete feature regeneration, enable the corresponding rebuild option, for example:
658
+
659
+ ```text
660
+ force_rnet2_rebuild = True
661
+ ```
662
+
663
+ ---
664
+
665
+ ## 18. One Tesla T4 GPU
666
+
667
+ Inference can be run with:
668
+
669
+ ```bash
670
+ CUDA_VISIBLE_DEVICES=0
671
+ ```
672
+
673
+ Recommended settings are approximately:
674
+
675
+ ```text
676
+ AMP ON
677
+ NOVA batch 1
678
+ Pairformer window 256
679
+ RNet2 adaptive chunk 128–192
680
+ Conformers 5
681
+ Flow steps 48
682
+ ```
683
+
684
+ Very long RNAs may still require aggressive chunking because pairwise representations scale quadratically with sequence length.
685
+
686
+ ---
687
+
688
+ ## 19. Multiple GPUs / L4
689
+
690
+ Two T4 GPUs do not behave as one unified 32 GB GPU.
691
+
692
+ A single RNA target is still limited by the VRAM of the GPU processing that target.
693
+
694
+ For many independent targets, inference can be sharded:
695
+
696
+ ```text
697
+ GPU0 -> targets 0,2,4,...
698
+ GPU1 -> targets 1,3,5,...
699
+ ```
700
+
701
+ For 4×L4 training, DistributedDataParallel is preferable to `nn.DataParallel`.
702
+
703
+ ---
704
+
705
+ ## 20. Supported Workflows
706
+
707
+ ### Fresh Training
708
+
709
+ ```text
710
+ data
711
+ → build evidence
712
+ → RibonanzaNet2
713
+ → S1-S5
714
+ → NOVA_best.pt
715
+ ```
716
+
717
+ ### Training Continuation
718
+
719
+ ```text
720
+ NOVA_last.pt
721
+ → restore model/optimizer/scheduler/scaler
722
+ → continue stage/epoch
723
+ ```
724
+
725
+ ### Inference Only
726
+
727
+ ```text
728
+ new test folder
729
+ → new RibonanzaNet2 features
730
+ → NOVA checkpoint
731
+ → 5 conformers
732
+ ```
733
+
734
+ If the goal is only to predict new RNA data, the inference-only script should be used instead of resume-training scripts.
735
+
736
+ ---
737
+
738
+ ## 21. Major Technical Issues Addressed
739
+
740
+ Several implementation issues were identified and fixed during development.
741
+
742
+ ### AMP BCE
743
+
744
+ Unsafe pattern:
745
+
746
+ ```python
747
+ binary_cross_entropy(sigmoid(logits), target)
748
+ ```
749
+
750
+ Preferred:
751
+
752
+ ```python
753
+ binary_cross_entropy_with_logits(logits, target)
754
+ ```
755
+
756
+ ---
757
+
758
+ ### CUDA SVD in FP16
759
+
760
+ Unsafe on some Tesla T4 configurations:
761
+
762
+ ```python
763
+ torch.linalg.svd(H_half)
764
+ ```
765
+
766
+ Preferred:
767
+
768
+ ```python
769
+ torch.linalg.svd(H.float())
770
+ ```
771
+
772
+ ---
773
+
774
+ ### NaN Coordinates
775
+
776
+ Multiplying invalid values by zero is not sufficient because:
777
+
778
+ ```text
779
+ NaN * 0 = NaN
780
+ ```
781
+
782
+ Coordinates must be sanitized before:
783
+
784
+ ```text
785
+ cdist
786
+ Kabsch
787
+ geometry losses
788
+ ```
789
+
790
+ ---
791
+
792
+ ### Checkpoint Closure Capture
793
+
794
+ Avoid checkpointing closures that may capture the wrong block:
795
+
796
+ ```python
797
+ checkpoint(lambda ...: blk(...))
798
+ ```
799
+
800
+ inside a changing loop.
801
+
802
+ ---
803
+
804
+ ### RibonanzaNet2 OOM
805
+
806
+ CUDA OOM must not be treated as an API mismatch.
807
+
808
+ Once the correct RibonanzaNet2 encoder API is identified, OOM should trigger:
809
+
810
+ ```text
811
+ re-raise / adaptive chunking
812
+ ```
813
+
814
+ rather than repeatedly trying unrelated call signatures.
815
+
816
+ ---
817
+
818
+ ## 22. Reproducibility
819
+
820
+ For reproducible inference, save:
821
+
822
+ ```text
823
+ NOVA checkpoint
824
+ RibonanzaNet2 checkpoint
825
+ inference script
826
+ test_sequences.csv
827
+ MSA files
828
+ random seed
829
+ PyTorch version
830
+ CUDA version
831
+ GPU name
832
+ prediction_summary.csv
833
+ inference_manifest.json
834
+ ```
835
+
836
+ ---
837
+
838
+ ## 23. Current Limitations
839
+
840
+ Current limitations include:
841
+
842
+ 1. Pair representations have high memory cost for long RNAs.
843
+ 2. Missing MSA/template evidence may reduce prediction quality.
844
+ 3. Window stitching is an approximation and is not equivalent to full global Pairformer inference.
845
+ 4. Candidate confidence/ranking is not a calibrated probability that a structure is correct.
846
+ 5. The pipeline is experimental and should be benchmarked carefully before strong scientific conclusions are drawn.
847
+ 6. If a model was trained with template evidence but inference is performed with no template information, this introduces distribution shift.
848
+ 7. RibonanzaNet2 preprocessing and feature dimensions must remain compatible with the NOVA checkpoint.
849
+
850
+ ---
851
+
852
+ ## 24. Recommended Inference Workflow
853
+
854
+ ```text
855
+ 1. Prepare test_sequences.csv
856
+ ↓
857
+ 2. Add MSA if available
858
+ ↓
859
+ 3. Load RibonanzaNet2
860
+ ↓
861
+ 4. Extract NEW RibonanzaNet2 features
862
+ ↓
863
+ 5. Build SS/BP evidence
864
+ ↓
865
+ 6. Load NOVA checkpoint
866
+ ↓
867
+ 7. Run direct or windowed inference
868
+ ↓
869
+ 8. Generate 5 conformers
870
+ ↓
871
+ 9. Rank/diversify conformers
872
+ ↓
873
+ 10. Save prediction_top5.csv
874
+ ```
875
+
876
+ ---
877
+
878
+ ## 25. Summary
879
+
880
+ EviRNA-NOVA can be summarized as:
881
+
882
+ \[
883
+ \boxed{
884
+ \text{Sequence}
885
+ +
886
+ \text{RibonanzaNet2}
887
+ +
888
+ \text{MSA}
889
+ +
890
+ \text{SS/BP}
891
+ +
892
+ \text{Template (optional)}
893
+ \rightarrow
894
+ \text{Dynamic Evidence Fusion}
895
+ \rightarrow
896
+ \text{Pairformer}
897
+ \rightarrow
898
+ \text{Geometry}
899
+ \rightarrow
900
+ \text{Flow}
901
+ \rightarrow
902
+ \text{RNA 3D}
903
+ }
904
+ \]
905
+
906
+ The core design goal is to combine multiple evidence sources rather than relying on a single modality, while producing multiple candidate RNA structures for top-k structural prediction.
907
+
908
+ ---
909
+
910
+ ## License / Citation
911
+
912
+ The current pipeline is an internal / experimental research implementation.
913
+
914
+ Before public release, the repository should include:
915
+
916
+ - a project license,
917
+ - citation information for the Stanford RNA 3D Folding dataset,
918
+ - citation and license information for RibonanzaNet2,
919
+ - citations for any external checkpoints or components used,
920
+ - a clear description of which parts are original EviRNA-NOVA contributions.