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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# ============================================
# Protenix 推理完整配置
# 基于 configs_base.py + configs_data.py + configs_inference.py
# 保持原有层级结构
# ============================================

inference:
  # ============================================
  # configs_inference.py: 推理基础配置
  # ============================================
  verbose: false
  seeds: [101]
  dump_dir: "./output_unified"
  need_atom_confidence: false
  sorted_by_ranking_score: true
  input_json_path: "./examples/7r6r.json"
  load_checkpoint_path: "./weight/model_v0.5.0.pt"
  num_workers: 16
  use_msa: true

  # ============================================
  # configs_base.py: basic_configs - 基础配置
  # ============================================
  project: "protenix"
  run_name: "run_001"
  base_dir: "./outputs"
  # 训练控制
  eval_interval: 1000
  log_interval: 100
  checkpoint_interval: -1
  eval_first: false
  iters_to_accumulate: 1
  eval_only: false
  load_ema_checkpoint_path: ""
  load_strict: true
  load_params_only: true
  skip_load_step: false
  skip_load_optimizer: false
  skip_load_scheduler: false
  train_confidence_only: false
  # 日志与跟踪
  use_wandb: true
  wandb_id: ""
  # 随机种子与确定性
  seed: 42
  deterministic: false
  deterministic_seed: false
  # EMA 设置
  ema_decay: -1.0
  eval_ema_only: false
  ema_mutable_param_keywords: [""]

  # ============================================
  # configs_base.py: data_configs - 数据配置
  # ============================================
  train_crop_size: 256
  test_max_n_token: -1
  train_lig_atom_rename: false
  train_shuffle_mols: false
  train_shuffle_sym_ids: false
  test_lig_atom_rename: false
  test_shuffle_mols: false
  test_shuffle_sym_ids: false

  # ============================================
  # configs_base.py: optim_configs - 优化器配置
  # ============================================
  lr: 0.0018
  lr_scheduler: "af3"
  warmup_steps: 10
  max_steps: 100000
  min_lr_ratio: 0.1
  decay_every_n_steps: 50000
  grad_clip_norm: 10
  # Adam 优化器
  adam:
    beta1: 0.9
    beta2: 0.95
    weight_decay: 1.0e-8
    lr: 0.0018
    use_adamw: false
  # AF3 学习率调度器
  af3_lr_scheduler:
    warmup_steps: 10
    decay_every_n_steps: 50000
    decay_factor: 0.95
    lr: 0.0018

  # ============================================
  # configs_base.py: model_configs - 模型基础配置
  # ============================================
  c_s: 384
  c_z: 128
  c_s_inputs: 449
  c_atom: 128
  c_atompair: 16
  c_token: 384
  n_blocks: 48
  max_atoms_per_token: 24
  no_bins: 64
  sigma_data: 16.0
  diffusion_batch_size: 48
  diffusion_chunk_size: 4
  blocks_per_ckpt: 1
  # 内核开关
  use_memory_efficient_kernel: false
  use_deepspeed_evo_attention: false
  use_flash: false
  use_lma: false
  use_xformer: false
  find_unused_parameters: false
  # 数据类型与损失
  dtype: "bf16"
  loss_metrics_sparse_enable: true
  # AMP 跳过配置
  skip_amp:
    sample_diffusion: true
    confidence_head: true
    sample_diffusion_training: true
    loss: true
  # 推理设置
  infer_setting:
    chunk_size: 64
    sample_diffusion_chunk_size: 1
    lddt_metrics_sparse_enable: true
    lddt_metrics_chunk_size: 1
  # 训练噪声采样器
  train_noise_sampler:
    p_mean: -1.2
    p_std: 1.5
    sigma_data: 16.0
  # 推理噪声调度器
  inference_noise_scheduler:
    s_max: 160.0
    s_min: 0.0004
    rho: 7
    sigma_data: 16.0
  # 扩散采样配置
  sample_diffusion:
    gamma0: 0.8
    gamma_min: 1.0
    noise_scale_lambda: 1.003
    step_scale_eta: 1.5
    N_step: 200
    N_sample: 5
    N_step_mini_rollout: 20
    N_sample_mini_rollout: 1

  # ============================================
  # configs_base.py: model_configs.model - 模型结构配置
  # ============================================
  model:
    N_model_seed: 1
    N_cycle: 4
    condition_embedding_drop_rate: 0.0
    confidence_embedding_drop_rate: 0.0
    input_embedder:
      c_atom: 128
      c_atompair: 16
      c_token: 384
    relative_position_encoding:
      r_max: 32
      s_max: 2
      c_z: 128
    template_embedder:
      c: 64
      c_z: 128
      n_blocks: 0
      dropout: 0.25
      blocks_per_ckpt: 1
    msa_module:
      c_m: 64
      c_z: 128
      c_s_inputs: 449
      n_blocks: 4
      msa_dropout: 0.15
      pair_dropout: 0.25
      blocks_per_ckpt: 1
      msa_chunk_size: 2048
    pairformer:
      n_blocks: 48
      c_z: 128
      c_s: 384
      n_heads: 16
      dropout: 0.25
      blocks_per_ckpt: 1
    diffusion_module:
      use_fine_grained_checkpoint: true
      sigma_data: 16.0
      c_token: 768
      c_atom: 128
      c_atompair: 16
      c_z: 128
      c_s: 384
      c_s_inputs: 449
      blocks_per_ckpt: 1
      atom_encoder:
        n_blocks: 3
        n_heads: 4
      transformer:
        n_blocks: 24
        n_heads: 16
      atom_decoder:
        n_blocks: 3
        n_heads: 4
    confidence_head:
      c_z: 128
      c_s: 384
      c_s_inputs: 449
      n_blocks: 4
      max_atoms_per_token: 24
      pairformer_dropout: 0.0
      blocks_per_ckpt: 1
      distance_bin_start: 3.25
      distance_bin_end: 52.0
      distance_bin_step: 1.25
      stop_gradient: true
    distogram_head:
      c_z: 128
      no_bins: 64

  # ============================================
  # configs_base.py: perm_configs - 置换配置
  # ============================================
  chain_permutation:
    train:
      mini_rollout: true
      diffusion_sample: false
    test:
      diffusion_sample: true
    permute_by_pocket: true
    configs:
      use_center_rmsd: false
      find_gt_anchor_first: false
      accept_it_as_it_is: false
      enumerate_all_anchor_pairs: false
      selection_metric: "aligned_rmsd"

  atom_permutation:
    train:
      mini_rollout: true
      diffusion_sample: false
    test:
      diffusion_sample: true
    permute_by_pocket: true
    global_align_wo_symmetric_atom: false

  # ============================================
  # configs_base.py: loss_configs - 损失函数配置
  # ============================================
  loss:
    diffusion_lddt_chunk_size: 1
    diffusion_bond_chunk_size: 1
    diffusion_chunk_size_outer: -1
    diffusion_sparse_loss_enable: true
    diffusion_lddt_loss_dense: true
    resolution:
      min: 0.1
      max: 4.0
    weight:
      alpha_confidence: 1.0e-4
      alpha_pae: 0.0
      alpha_except_pae: 1.0
      alpha_diffusion: 4.0
      alpha_distogram: 3.0e-2
      alpha_bond: 0.0
      smooth_lddt: 1.0
    plddt:
      min_bin: 0
      max_bin: 1.0
      no_bins: 50
      normalize: true
      eps: 1.0e-6
    pde:
      min_bin: 0
      max_bin: 32
      no_bins: 64
      eps: 1.0e-6
    resolved:
      eps: 1.0e-6
    pae:
      min_bin: 0
      max_bin: 32
      no_bins: 64
      eps: 1.0e-6
    diffusion:
      mse:
        weight_mse: 0.333333
        weight_dna: 5.0
        weight_rna: 5.0
        weight_ligand: 10.0
        eps: 1.0e-6
      bond:
        eps: 1.0e-6
      smooth_lddt:
        eps: 1.0e-6
    distogram:
      min_bin: 2.3125
      max_bin: 21.6875
      no_bins: 64
      eps: 1.0e-6

  # ============================================
  # configs_base.py: loss_configs.metrics - 评估指标
  # ============================================
  metrics:
    lddt:
      eps: 1.0e-6
    complex_ranker_keys: ["plddt", "gpde", "ranking_score"]
    chain_ranker_keys: ["chain_ptm", "chain_plddt"]
    interface_ranker_keys: ["chain_pair_iptm", "chain_pair_iptm_global", "chain_pair_plddt"]
    clash:
      af3_clash_threshold: 1.1
      vdw_clash_threshold: 0.75

  # ============================================
  # configs_data.py: data_configs - 数据加载配置
  # ============================================
  # 注意:msa 和 template 必须放在 data 下供模型读取
  # ============================================
  data:
    # CCD 组件文件
    ccd_components_file: "${DATA_ROOT_DIR}/components.v20240608.cif"
    ccd_components_rdkit_mol_file: "${DATA_ROOT_DIR}/components.v20240608.cif.rdkit_mol.pkl"

    # 数据加载器配置
    num_dl_workers: 16
    epoch_size: 10000
    train_ref_pos_augment: true
    test_ref_pos_augment: true

    # 训练数据集
    train_sets: ["weightedPDB_before2109_wopb_nometalc_0925"]
    train_sampler:
      train_sample_weights: [1.0]
      sampler_type: "weighted"

    # 测试数据集
    test_sets: ["recentPDB_1536_sample384_0925"]

    # ============================================
    # weightedPDB 训练数据集配置
    # ============================================
    weightedPDB_before2109_wopb_nometalc_0925:
      base_info:
        mmcif_dir: "${DATA_ROOT_DIR}/mmcif"
        bioassembly_dict_dir: "${DATA_ROOT_DIR}/mmcif_bioassembly"
        indices_fpath: "${DATA_ROOT_DIR}/indices/weightedPDB_indices_before_2021-09-30_wo_posebusters_resolution_below_9.csv.gz"
        pdb_list: ""
        random_sample_if_failed: true
        max_n_token: -1
        use_reference_chains_only: false
        exclusion:
          mol_1_type: ["ions"]
          mol_2_type: ["ions"]
      sampler_configs:
        sampler_type: "weighted"
        beta_dict:
          chain: 0.5
          interface: 1
        alpha_dict:
          prot: 3
          nuc: 3
          ligand: 1
        force_recompute_weight: true
      cropping_configs:
        method_weights: [0.2, 0.4, 0.4]
        crop_size: 256
      sample_weight: 0.5
      limits: -1
      lig_atom_rename: false
      shuffle_mols: false
      shuffle_sym_ids: false

    # ============================================
    # recentPDB 测试数据集配置
    # ============================================
    recentPDB_1536_sample384_0925:
      base_info:
        mmcif_dir: "${DATA_ROOT_DIR}/mmcif"
        bioassembly_dict_dir: "${DATA_ROOT_DIR}/recentPDB_bioassembly"
        indices_fpath: "${DATA_ROOT_DIR}/indices/recentPDB_low_homology_maxtoken1536.csv"
        pdb_list: "${DATA_ROOT_DIR}/indices/recentPDB_low_homology_maxtoken1024_sample384_pdb_id.txt"
        max_n_token: -1
        sort_by_n_token: false
        group_by_pdb_id: true
        find_eval_chain_interface: true
      sampler_configs:
        sampler_type: "uniform"
      cropping_configs:
        method_weights: [0.0, 0.0, 1.0]
        crop_size: -1
      lig_atom_rename: false
      shuffle_mols: false
      shuffle_sym_ids: false

    # ============================================
    # posebusters 数据集配置
    # ============================================
    posebusters_0925:
      base_info:
        mmcif_dir: "${DATA_ROOT_DIR}/posebusters_mmcif"
        bioassembly_dict_dir: "${DATA_ROOT_DIR}/posebusters_bioassembly"
        indices_fpath: "${DATA_ROOT_DIR}/indices/posebusters_indices_mainchain_interface.csv"
        pdb_list: ""
        find_pocket: true
        find_all_pockets: false
        max_n_token: -1
      sampler_configs:
        sampler_type: "uniform"
      cropping_configs:
        method_weights: [0.0, 0.0, 1.0]
        crop_size: -1
      lig_atom_rename: false
      shuffle_mols: false
      shuffle_sym_ids: false

    # ============================================
    # MSA 配置 (configs_data.py 中的 data_configs.msa)
    # ============================================
    msa:
      enable: true
      enable_rna_msa: false
      prot:
        pairing_db: "uniref100"
        non_pairing_db: "mmseqs_other"
        pdb_mmseqs_dir: "${DATA_ROOT_DIR}/mmcif_msa"
        seq_to_pdb_idx_path: "${DATA_ROOT_DIR}/seq_to_pdb_index.json"
        indexing_method: "sequence"
      rna:
        seq_to_pdb_idx_path: ""
        rna_msa_dir: ""
        indexing_method: "sequence"
      strategy: "random"
      merge_method: "dense_max"
      min_size:
        train: 1
        test: 1
      max_size:
        train: 16384
        test: 16384
      sample_cutoff:
        train: 16384
        test: 16384

    # ============================================
    # Template 配置 (configs_data.py 中的 data_configs.template)
    # ============================================
    template:
      enable: false
  
    extra:
      use_pipeline: true
      use_msa: true
      use_structure: true
      msa_dirs:
        - path: ${oc.env:PWD}/examples/7r6r/msa/1
          format_hint: a3m
      model_name: protenix_infer_adapter
      use_adapter: true