Add files using upload-large-folder tool
Browse files- checkpoints/askcos_retro_template_relevance/bkms_metabolic/SHA256SUMS +18 -0
- checkpoints/askcos_retro_template_relevance/bkms_metabolic/manifest.json +138 -0
- checkpoints/askcos_retro_template_relevance/bkms_metabolic/provenance.json +89 -0
- checkpoints/askcos_retro_template_relevance/bkms_metabolic/wrapper_config.json +37 -0
- checkpoints/askcos_retro_template_relevance/pistachio/SHA256SUMS +18 -0
- checkpoints/askcos_retro_template_relevance/pistachio/manifest.json +138 -0
- checkpoints/askcos_retro_template_relevance/pistachio/provenance.json +89 -0
- checkpoints/askcos_retro_template_relevance/pistachio/wrapper_config.json +37 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/SHA256SUMS +18 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/aux/mar_members.json +52 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/aux/model_args.json +20 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/aux/safetensors_conversion.json +12 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/benchmarks/metadata.json +32 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/manifest.json +138 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/provenance.json +89 -0
- checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/wrapper_config.json +37 -0
- checkpoints/askcos_retro_template_relevance/reaxys/SHA256SUMS +18 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/MAR-INF/MANIFEST.json +10 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/misc.py +45 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/models.py +119 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/templ_rel_handler.py +201 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/templ_rel_parser.py +72 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/utils.py +207 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_members.json +52 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/model_args.json +24 -0
- checkpoints/askcos_retro_template_relevance/reaxys/aux/safetensors_conversion.json +12 -0
- checkpoints/askcos_retro_template_relevance/reaxys/benchmarks/metadata.json +32 -0
- checkpoints/askcos_retro_template_relevance/reaxys/benchmarks/native/ref_routes_reaction_hashes.txt +0 -0
- checkpoints/askcos_retro_template_relevance/reaxys/manifest.json +139 -0
- checkpoints/askcos_retro_template_relevance/reaxys/provenance.json +89 -0
- checkpoints/askcos_retro_template_relevance/reaxys/wrapper_config.json +37 -0
- checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/SHA256SUMS +18 -0
- checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/manifest.json +139 -0
- checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/provenance.json +89 -0
- checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/wrapper_config.json +37 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/SHA256SUMS +18 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/MAR-INF/MANIFEST.json +10 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/misc.py +45 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/models.py +119 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/templ_rel_handler.py +201 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/templ_rel_parser.py +94 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/utils.py +250 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_members.json +52 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/model_args.json +40 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/safetensors_conversion.json +12 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/benchmarks/metadata.json +32 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/benchmarks/native/ref_routes_reaction_hashes.txt +0 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/manifest.json +138 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/provenance.json +89 -0
- checkpoints/askcos_retro_template_relevance/uspto_higher_level/wrapper_config.json +37 -0
checkpoints/askcos_retro_template_relevance/bkms_metabolic/SHA256SUMS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bf98f0614f6f04a8558f049d49a9074f269a3cfe01e2c68c4e4afd45d99a19f2 aux/MAR-INF/MANIFEST.json
|
| 2 |
+
f5bef6f645347b15a1bbff2e56117d1a58f56234bdd24d89e9a18bd7a0d193d5 aux/mar_files/misc.py
|
| 3 |
+
8ee17cac57f65d954a599f18bbcf9df069a1acb0be86064a21188d4f5c2171f5 aux/mar_files/models.py
|
| 4 |
+
b5d99468d88374391e7ce7a1766ee287b8fbb9f1dbac70743606d43dee4f9f59 aux/mar_files/templ_rel_handler.py
|
| 5 |
+
9a0d07ded45cd94abeeed5e8c1f30a1e590080b10b4bbc8314aa5e4cbc622d83 aux/mar_files/templ_rel_parser.py
|
| 6 |
+
67bee61a87662e2224bb85725bdf8de048ff4ebcc934fc8ed1cdfd61186e4a4b aux/mar_files/utils.py
|
| 7 |
+
669ee3ff21dd3aede541ab5af04775f4132aea497fa233e39ddf1c09a0c74cb8 aux/mar_members.json
|
| 8 |
+
040883d769a5a40d77f789aa1f99bef0eb970af96fe6822ff52251d09231ee86 aux/model_args.json
|
| 9 |
+
bc047b7afb7a1a3dbaf70225560fd396eee228f106ff12f615de80dea999f8b7 aux/safetensors_conversion.json
|
| 10 |
+
6ec004e43e4f37a105fa7844efb333d44c9c4f980d0988e1d96cd3b506d63578 aux/templates.jsonl
|
| 11 |
+
a10255a6abd89a35d2ea48a842839f403b4b1586805c3010c0d076e0ae23754d benchmarks/default_test.jsonl
|
| 12 |
+
108fc4f1bbc3d252f30f09884c19bf279b7c513c23e73e43d5956f995cb12c86 benchmarks/metadata.json
|
| 13 |
+
87d7e0013f97da27e4fd878b0598466ac07202fe131ac0f7dbdd2b423482751f benchmarks/native/ref_routes_reaction_hashes.txt
|
| 14 |
+
872533b44788754af3aa19918a04c2a508d30249d2c93eb480078cb638ad3389 benchmarks/native/selected_reactions.csv
|
| 15 |
+
0749d5b4956fa1a4095e4e2026ee60cbe98fb04069d0cc870d1128320f929947 manifest.json
|
| 16 |
+
63a249baa4c56dd64babc94333415fb5f384071a93f27241e5529e3efa8d9655 model.safetensors
|
| 17 |
+
62a6f0a265c631d03262154ad832803a1bc46b596254c5da106a511cbef53082 provenance.json
|
| 18 |
+
e2cebe6742a3ecffb2ffbf9f3889c3d082b3de876f5992150918bfd6d4bd4b72 wrapper_config.json
|
checkpoints/askcos_retro_template_relevance/bkms_metabolic/manifest.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auxiliary_files": [
|
| 3 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 4 |
+
"aux/mar_files/misc.py",
|
| 5 |
+
"aux/mar_files/models.py",
|
| 6 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 7 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 8 |
+
"aux/mar_files/utils.py",
|
| 9 |
+
"aux/mar_members.json",
|
| 10 |
+
"aux/model_args.json",
|
| 11 |
+
"aux/safetensors_conversion.json",
|
| 12 |
+
"aux/templates.jsonl",
|
| 13 |
+
"benchmarks/default_test.jsonl",
|
| 14 |
+
"benchmarks/metadata.json",
|
| 15 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 16 |
+
"benchmarks/native/selected_reactions.csv"
|
| 17 |
+
],
|
| 18 |
+
"benchmark_datasets": [
|
| 19 |
+
{
|
| 20 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 21 |
+
"dataset_id": "askcos_retro_template_relevance_bkms_metabolic_paroutes_reference_route_test",
|
| 22 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 23 |
+
"default": true,
|
| 24 |
+
"format": "jsonl",
|
| 25 |
+
"metadata_path": "benchmarks/metadata.json",
|
| 26 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 27 |
+
"native_source_paths": [
|
| 28 |
+
"benchmarks/native/selected_reactions.csv",
|
| 29 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt"
|
| 30 |
+
],
|
| 31 |
+
"notes": [
|
| 32 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 33 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 34 |
+
],
|
| 35 |
+
"num_examples": 56657,
|
| 36 |
+
"path": "benchmarks/default_test.jsonl",
|
| 37 |
+
"split": "test"
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"checkpoint_id": "bkms_metabolic",
|
| 41 |
+
"contained_artifact_bindings": [
|
| 42 |
+
{
|
| 43 |
+
"canonical_split_family": "askcos_bkms_metabolic_split_unspecified",
|
| 44 |
+
"dataset_ref": "askcos_bkms_metabolic_release",
|
| 45 |
+
"path": "modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 46 |
+
"stage": "released_torchserve_archive"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"conversion": {
|
| 50 |
+
"converted_at": "1970-01-01T00:00:00+00:00",
|
| 51 |
+
"notes": [
|
| 52 |
+
"The upstream ASKCOS TorchServe .mar was unpacked into native bundle assets.",
|
| 53 |
+
"Tensor weights are stored canonically as model.safetensors; non-tensor runtime assets are stored under aux/.",
|
| 54 |
+
"The original .mar archive is not required for wrapper inference."
|
| 55 |
+
],
|
| 56 |
+
"safetensors": {
|
| 57 |
+
"format": "safetensors",
|
| 58 |
+
"num_tensors": 4,
|
| 59 |
+
"path": "model.safetensors",
|
| 60 |
+
"roundtrip_tensor_equal": true,
|
| 61 |
+
"runtime_assets": {
|
| 62 |
+
"model_args": "aux/model_args.json",
|
| 63 |
+
"templates": "aux/templates.jsonl"
|
| 64 |
+
},
|
| 65 |
+
"source_member": "model_latest.pt",
|
| 66 |
+
"status": "converted"
|
| 67 |
+
},
|
| 68 |
+
"source_format": "torchserve_mar_embedded_checkpoint",
|
| 69 |
+
"status": "converted",
|
| 70 |
+
"tool_version": "initial"
|
| 71 |
+
},
|
| 72 |
+
"display_name": "bkms_metabolic",
|
| 73 |
+
"format_version": 1,
|
| 74 |
+
"generated_at": "1970-01-01T00:00:00+00:00",
|
| 75 |
+
"input_schema": {
|
| 76 |
+
"product_field": "smiles",
|
| 77 |
+
"request_format": {
|
| 78 |
+
"smiles": [
|
| 79 |
+
"product_smiles"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
"target_field": "reactants"
|
| 83 |
+
},
|
| 84 |
+
"model_id": "askcos_retro_template_relevance",
|
| 85 |
+
"model_role": "backward",
|
| 86 |
+
"normalized_checkpoint_id": "bkms_metabolic",
|
| 87 |
+
"package_layout": {
|
| 88 |
+
"aux_dir": "aux",
|
| 89 |
+
"benchmarks_dir": "benchmarks",
|
| 90 |
+
"weights_path": "model.safetensors"
|
| 91 |
+
},
|
| 92 |
+
"source_registry_refs": [
|
| 93 |
+
{
|
| 94 |
+
"checkpoint_id": "bkms_metabolic",
|
| 95 |
+
"model_id": "askcos_retro_template_relevance"
|
| 96 |
+
}
|
| 97 |
+
],
|
| 98 |
+
"split_provenance": [
|
| 99 |
+
{
|
| 100 |
+
"canonical_split_family": "askcos_bkms_metabolic_split_unspecified",
|
| 101 |
+
"dataset_ref": "askcos_bkms_metabolic_release",
|
| 102 |
+
"split_names": [],
|
| 103 |
+
"stage": "released_torchserve_archive"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"canonical_split_family": "askcos_bkms_metabolic_split_unspecified",
|
| 107 |
+
"dataset_ref": "askcos_bkms_metabolic_release",
|
| 108 |
+
"path": "modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 109 |
+
"stage": "released_torchserve_archive"
|
| 110 |
+
}
|
| 111 |
+
],
|
| 112 |
+
"task_direction": "retrosynthesis",
|
| 113 |
+
"training_dataset_refs": [
|
| 114 |
+
"askcos_bkms_metabolic_release"
|
| 115 |
+
],
|
| 116 |
+
"training_stage_bindings": [
|
| 117 |
+
{
|
| 118 |
+
"canonical_split_family": "askcos_bkms_metabolic_split_unspecified",
|
| 119 |
+
"dataset_ref": "askcos_bkms_metabolic_release",
|
| 120 |
+
"split_names": [],
|
| 121 |
+
"stage": "released_torchserve_archive"
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"canonical_split_family": "askcos_bkms_metabolic_split_unspecified",
|
| 125 |
+
"dataset_ref": "askcos_bkms_metabolic_release",
|
| 126 |
+
"path": "modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 127 |
+
"stage": "released_torchserve_archive"
|
| 128 |
+
}
|
| 129 |
+
],
|
| 130 |
+
"weights": {
|
| 131 |
+
"dtype_summary": "float tensors preserved from upstream checkpoint",
|
| 132 |
+
"framework": "safetensors",
|
| 133 |
+
"path": "model.safetensors",
|
| 134 |
+
"tensor_namespace": "askcos_template_relevance"
|
| 135 |
+
},
|
| 136 |
+
"wrapper_config": "wrapper_config.json",
|
| 137 |
+
"wrapper_family": "askcos_template_relevance"
|
| 138 |
+
}
|
checkpoints/askcos_retro_template_relevance/bkms_metabolic/provenance.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conversion_notes": [
|
| 3 |
+
"The ASKCOS TorchServe .mar source archive was unpacked; model.mar is not copied into the normalized package.",
|
| 4 |
+
"Embedded tensor weights were serialized to model.safetensors and verified by safetensors round-trip equality.",
|
| 5 |
+
"Required non-tensor runtime assets such as templates, vocabularies, model args, OpenNMT metadata, and Graph2SMILES source support files are copied under aux/.",
|
| 6 |
+
"Lightweight MAR metadata is retained under aux/ for provenance only."
|
| 7 |
+
],
|
| 8 |
+
"copied_sidecars": [
|
| 9 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 10 |
+
"aux/mar_files/misc.py",
|
| 11 |
+
"aux/mar_files/models.py",
|
| 12 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 13 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 14 |
+
"aux/mar_files/utils.py",
|
| 15 |
+
"aux/mar_members.json",
|
| 16 |
+
"aux/model_args.json",
|
| 17 |
+
"aux/safetensors_conversion.json",
|
| 18 |
+
"aux/templates.jsonl"
|
| 19 |
+
],
|
| 20 |
+
"inner_members": [
|
| 21 |
+
{
|
| 22 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 23 |
+
"member": "templates.jsonl",
|
| 24 |
+
"role": "template_library"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 28 |
+
"member": "misc.py",
|
| 29 |
+
"role": "archive_member"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 33 |
+
"member": "utils.py",
|
| 34 |
+
"role": "archive_member"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 38 |
+
"member": "models.py",
|
| 39 |
+
"role": "archive_member"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 43 |
+
"member": "model_latest.pt",
|
| 44 |
+
"role": "weights_source"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 48 |
+
"member": "templ_rel_parser.py",
|
| 49 |
+
"role": "archive_member"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 53 |
+
"member": "templ_rel_handler.py",
|
| 54 |
+
"role": "archive_member"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 58 |
+
"member": "MAR-INF/MANIFEST.json",
|
| 59 |
+
"role": "torchserve_manifest"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"normalized_checkpoint_id": "bkms_metabolic",
|
| 63 |
+
"source_artifacts": [
|
| 64 |
+
{
|
| 65 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 66 |
+
"kind": "local_repo_file",
|
| 67 |
+
"path": "datasets/modelos_ASKCOS/mars/bkms_metabolic.mar",
|
| 68 |
+
"role": "source_artifact",
|
| 69 |
+
"sha256": "67f22c093dfb8a6fa24952c2c7f1cf527e45c15a6557ae8c21a446a91eae51d2",
|
| 70 |
+
"size": 152935700
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 74 |
+
"kind": "local_repo_file",
|
| 75 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 76 |
+
"role": "source_artifact",
|
| 77 |
+
"sha256": "e88d26f86ce79d2c7d8f05d1a59e3b1b88bde69c3afb95d065c932ff058092be",
|
| 78 |
+
"size": 2374
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 82 |
+
"kind": "local_repo_file",
|
| 83 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 84 |
+
"role": "source_artifact",
|
| 85 |
+
"sha256": "c2351dd12f68b0f372b23183cf470fa643f73274f66e34dfc0dacd1ce1a9843e",
|
| 86 |
+
"size": 1234
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
checkpoints/askcos_retro_template_relevance/bkms_metabolic/wrapper_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture_class": "NeuralSym-style template relevance FFN",
|
| 3 |
+
"device_supported": [
|
| 4 |
+
"cpu",
|
| 5 |
+
"cuda"
|
| 6 |
+
],
|
| 7 |
+
"input_schema": {
|
| 8 |
+
"product_field": "smiles",
|
| 9 |
+
"request_format": {
|
| 10 |
+
"smiles": [
|
| 11 |
+
"product_smiles"
|
| 12 |
+
]
|
| 13 |
+
},
|
| 14 |
+
"target_field": "reactants"
|
| 15 |
+
},
|
| 16 |
+
"license": "mit",
|
| 17 |
+
"loader": {
|
| 18 |
+
"kind": "askcos_template_relevance_safetensors",
|
| 19 |
+
"model_args": "aux/model_args.json",
|
| 20 |
+
"model_version": "1.0",
|
| 21 |
+
"served_model_name": "bkms_metabolic",
|
| 22 |
+
"source_handler": "templ_rel_handler.py",
|
| 23 |
+
"state_dict_format": "safetensors",
|
| 24 |
+
"templates": "aux/templates.jsonl"
|
| 25 |
+
},
|
| 26 |
+
"package_layout": {
|
| 27 |
+
"aux_dir": "aux",
|
| 28 |
+
"weights_path": "model.safetensors"
|
| 29 |
+
},
|
| 30 |
+
"runtime_file_map": {
|
| 31 |
+
"aux/model_args.json": "aux/model_args.json",
|
| 32 |
+
"aux/templates.jsonl": "aux/templates.jsonl",
|
| 33 |
+
"model.safetensors": "model.safetensors"
|
| 34 |
+
},
|
| 35 |
+
"task_direction": "retrosynthesis",
|
| 36 |
+
"wrapper_family": "askcos_template_relevance"
|
| 37 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio/SHA256SUMS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
e04658a41a9c75a797dc18e2d141db8ed9e3ae37261eb6302b6b3e59993fb40a aux/MAR-INF/MANIFEST.json
|
| 2 |
+
f5bef6f645347b15a1bbff2e56117d1a58f56234bdd24d89e9a18bd7a0d193d5 aux/mar_files/misc.py
|
| 3 |
+
8ee17cac57f65d954a599f18bbcf9df069a1acb0be86064a21188d4f5c2171f5 aux/mar_files/models.py
|
| 4 |
+
b5d99468d88374391e7ce7a1766ee287b8fbb9f1dbac70743606d43dee4f9f59 aux/mar_files/templ_rel_handler.py
|
| 5 |
+
9a0d07ded45cd94abeeed5e8c1f30a1e590080b10b4bbc8314aa5e4cbc622d83 aux/mar_files/templ_rel_parser.py
|
| 6 |
+
67bee61a87662e2224bb85725bdf8de048ff4ebcc934fc8ed1cdfd61186e4a4b aux/mar_files/utils.py
|
| 7 |
+
21150e0de739e16d25ea2bff971b6658bc5791edeb23ac66dbb3a67bd4135191 aux/mar_members.json
|
| 8 |
+
8f52f6da6d2c8f9625d2254a2ef864524c966b6a166a5bcc0e00d1ff874f076e aux/model_args.json
|
| 9 |
+
bc047b7afb7a1a3dbaf70225560fd396eee228f106ff12f615de80dea999f8b7 aux/safetensors_conversion.json
|
| 10 |
+
1df1c91b2fef57dfcfa062139fb9067f02657dfcc1829c4daceef47d43610a2a aux/templates.jsonl
|
| 11 |
+
a10255a6abd89a35d2ea48a842839f403b4b1586805c3010c0d076e0ae23754d benchmarks/default_test.jsonl
|
| 12 |
+
68ddd00c0d52c9f10b97e4a4802f2a68f8dbc44e56a03946634a025279a1aa84 benchmarks/metadata.json
|
| 13 |
+
87d7e0013f97da27e4fd878b0598466ac07202fe131ac0f7dbdd2b423482751f benchmarks/native/ref_routes_reaction_hashes.txt
|
| 14 |
+
872533b44788754af3aa19918a04c2a508d30249d2c93eb480078cb638ad3389 benchmarks/native/selected_reactions.csv
|
| 15 |
+
cc17e3d9b2a4b0615a2f057fdaf48b77c6cd0df74b004963cd4f0289f5df0e1a manifest.json
|
| 16 |
+
7051c63a9ad64cb85ff00a43f5bfc65f2fe55f2165464b59a68c2415ed695115 model.safetensors
|
| 17 |
+
13ea4891403671d66358c56574e1d1d4bf023927c5167a63a30064864ed08cf6 provenance.json
|
| 18 |
+
b29f4070b36e8c8b5af44635efb8d6d8a59912d6d86836a2a97dba2c24cc3431 wrapper_config.json
|
checkpoints/askcos_retro_template_relevance/pistachio/manifest.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auxiliary_files": [
|
| 3 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 4 |
+
"aux/mar_files/misc.py",
|
| 5 |
+
"aux/mar_files/models.py",
|
| 6 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 7 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 8 |
+
"aux/mar_files/utils.py",
|
| 9 |
+
"aux/mar_members.json",
|
| 10 |
+
"aux/model_args.json",
|
| 11 |
+
"aux/safetensors_conversion.json",
|
| 12 |
+
"aux/templates.jsonl",
|
| 13 |
+
"benchmarks/default_test.jsonl",
|
| 14 |
+
"benchmarks/metadata.json",
|
| 15 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 16 |
+
"benchmarks/native/selected_reactions.csv"
|
| 17 |
+
],
|
| 18 |
+
"benchmark_datasets": [
|
| 19 |
+
{
|
| 20 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 21 |
+
"dataset_id": "askcos_retro_template_relevance_pistachio_paroutes_reference_route_test",
|
| 22 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 23 |
+
"default": true,
|
| 24 |
+
"format": "jsonl",
|
| 25 |
+
"metadata_path": "benchmarks/metadata.json",
|
| 26 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 27 |
+
"native_source_paths": [
|
| 28 |
+
"benchmarks/native/selected_reactions.csv",
|
| 29 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt"
|
| 30 |
+
],
|
| 31 |
+
"notes": [
|
| 32 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 33 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 34 |
+
],
|
| 35 |
+
"num_examples": 56657,
|
| 36 |
+
"path": "benchmarks/default_test.jsonl",
|
| 37 |
+
"split": "test"
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"checkpoint_id": "pistachio",
|
| 41 |
+
"contained_artifact_bindings": [
|
| 42 |
+
{
|
| 43 |
+
"canonical_split_family": "askcos_pistachio_split_unspecified",
|
| 44 |
+
"dataset_ref": "askcos_pistachio_release",
|
| 45 |
+
"path": "modelos_ASKCOS/mars/pistachio.mar",
|
| 46 |
+
"stage": "released_torchserve_archive"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"conversion": {
|
| 50 |
+
"converted_at": "1970-01-01T00:00:00+00:00",
|
| 51 |
+
"notes": [
|
| 52 |
+
"The upstream ASKCOS TorchServe .mar was unpacked into native bundle assets.",
|
| 53 |
+
"Tensor weights are stored canonically as model.safetensors; non-tensor runtime assets are stored under aux/.",
|
| 54 |
+
"The original .mar archive is not required for wrapper inference."
|
| 55 |
+
],
|
| 56 |
+
"safetensors": {
|
| 57 |
+
"format": "safetensors",
|
| 58 |
+
"num_tensors": 4,
|
| 59 |
+
"path": "model.safetensors",
|
| 60 |
+
"roundtrip_tensor_equal": true,
|
| 61 |
+
"runtime_assets": {
|
| 62 |
+
"model_args": "aux/model_args.json",
|
| 63 |
+
"templates": "aux/templates.jsonl"
|
| 64 |
+
},
|
| 65 |
+
"source_member": "model_latest.pt",
|
| 66 |
+
"status": "converted"
|
| 67 |
+
},
|
| 68 |
+
"source_format": "torchserve_mar_embedded_checkpoint",
|
| 69 |
+
"status": "converted",
|
| 70 |
+
"tool_version": "initial"
|
| 71 |
+
},
|
| 72 |
+
"display_name": "pistachio",
|
| 73 |
+
"format_version": 1,
|
| 74 |
+
"generated_at": "1970-01-01T00:00:00+00:00",
|
| 75 |
+
"input_schema": {
|
| 76 |
+
"product_field": "smiles",
|
| 77 |
+
"request_format": {
|
| 78 |
+
"smiles": [
|
| 79 |
+
"product_smiles"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
"target_field": "reactants"
|
| 83 |
+
},
|
| 84 |
+
"model_id": "askcos_retro_template_relevance",
|
| 85 |
+
"model_role": "backward",
|
| 86 |
+
"normalized_checkpoint_id": "pistachio",
|
| 87 |
+
"package_layout": {
|
| 88 |
+
"aux_dir": "aux",
|
| 89 |
+
"benchmarks_dir": "benchmarks",
|
| 90 |
+
"weights_path": "model.safetensors"
|
| 91 |
+
},
|
| 92 |
+
"source_registry_refs": [
|
| 93 |
+
{
|
| 94 |
+
"checkpoint_id": "pistachio",
|
| 95 |
+
"model_id": "askcos_retro_template_relevance"
|
| 96 |
+
}
|
| 97 |
+
],
|
| 98 |
+
"split_provenance": [
|
| 99 |
+
{
|
| 100 |
+
"canonical_split_family": "askcos_pistachio_split_unspecified",
|
| 101 |
+
"dataset_ref": "askcos_pistachio_release",
|
| 102 |
+
"split_names": [],
|
| 103 |
+
"stage": "released_torchserve_archive"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"canonical_split_family": "askcos_pistachio_split_unspecified",
|
| 107 |
+
"dataset_ref": "askcos_pistachio_release",
|
| 108 |
+
"path": "modelos_ASKCOS/mars/pistachio.mar",
|
| 109 |
+
"stage": "released_torchserve_archive"
|
| 110 |
+
}
|
| 111 |
+
],
|
| 112 |
+
"task_direction": "retrosynthesis",
|
| 113 |
+
"training_dataset_refs": [
|
| 114 |
+
"askcos_pistachio_release"
|
| 115 |
+
],
|
| 116 |
+
"training_stage_bindings": [
|
| 117 |
+
{
|
| 118 |
+
"canonical_split_family": "askcos_pistachio_split_unspecified",
|
| 119 |
+
"dataset_ref": "askcos_pistachio_release",
|
| 120 |
+
"split_names": [],
|
| 121 |
+
"stage": "released_torchserve_archive"
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"canonical_split_family": "askcos_pistachio_split_unspecified",
|
| 125 |
+
"dataset_ref": "askcos_pistachio_release",
|
| 126 |
+
"path": "modelos_ASKCOS/mars/pistachio.mar",
|
| 127 |
+
"stage": "released_torchserve_archive"
|
| 128 |
+
}
|
| 129 |
+
],
|
| 130 |
+
"weights": {
|
| 131 |
+
"dtype_summary": "float tensors preserved from upstream checkpoint",
|
| 132 |
+
"framework": "safetensors",
|
| 133 |
+
"path": "model.safetensors",
|
| 134 |
+
"tensor_namespace": "askcos_template_relevance"
|
| 135 |
+
},
|
| 136 |
+
"wrapper_config": "wrapper_config.json",
|
| 137 |
+
"wrapper_family": "askcos_template_relevance"
|
| 138 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio/provenance.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conversion_notes": [
|
| 3 |
+
"The ASKCOS TorchServe .mar source archive was unpacked; model.mar is not copied into the normalized package.",
|
| 4 |
+
"Embedded tensor weights were serialized to model.safetensors and verified by safetensors round-trip equality.",
|
| 5 |
+
"Required non-tensor runtime assets such as templates, vocabularies, model args, OpenNMT metadata, and Graph2SMILES source support files are copied under aux/.",
|
| 6 |
+
"Lightweight MAR metadata is retained under aux/ for provenance only."
|
| 7 |
+
],
|
| 8 |
+
"copied_sidecars": [
|
| 9 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 10 |
+
"aux/mar_files/misc.py",
|
| 11 |
+
"aux/mar_files/models.py",
|
| 12 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 13 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 14 |
+
"aux/mar_files/utils.py",
|
| 15 |
+
"aux/mar_members.json",
|
| 16 |
+
"aux/model_args.json",
|
| 17 |
+
"aux/safetensors_conversion.json",
|
| 18 |
+
"aux/templates.jsonl"
|
| 19 |
+
],
|
| 20 |
+
"inner_members": [
|
| 21 |
+
{
|
| 22 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 23 |
+
"member": "templates.jsonl",
|
| 24 |
+
"role": "template_library"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 28 |
+
"member": "misc.py",
|
| 29 |
+
"role": "archive_member"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 33 |
+
"member": "utils.py",
|
| 34 |
+
"role": "archive_member"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 38 |
+
"member": "models.py",
|
| 39 |
+
"role": "archive_member"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 43 |
+
"member": "model_latest.pt",
|
| 44 |
+
"role": "weights_source"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 48 |
+
"member": "templ_rel_parser.py",
|
| 49 |
+
"role": "archive_member"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 53 |
+
"member": "templ_rel_handler.py",
|
| 54 |
+
"role": "archive_member"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 58 |
+
"member": "MAR-INF/MANIFEST.json",
|
| 59 |
+
"role": "torchserve_manifest"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"normalized_checkpoint_id": "pistachio",
|
| 63 |
+
"source_artifacts": [
|
| 64 |
+
{
|
| 65 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 66 |
+
"kind": "local_repo_file",
|
| 67 |
+
"path": "datasets/modelos_ASKCOS/mars/pistachio.mar",
|
| 68 |
+
"role": "source_artifact",
|
| 69 |
+
"sha256": "9de0e67eda18a34a311d1f8311ae2d914503db92900232cec1eeeeb7d28ace9b",
|
| 70 |
+
"size": 800751502
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 74 |
+
"kind": "local_repo_file",
|
| 75 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 76 |
+
"role": "source_artifact",
|
| 77 |
+
"sha256": "e88d26f86ce79d2c7d8f05d1a59e3b1b88bde69c3afb95d065c932ff058092be",
|
| 78 |
+
"size": 2374
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 82 |
+
"kind": "local_repo_file",
|
| 83 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 84 |
+
"role": "source_artifact",
|
| 85 |
+
"sha256": "c2351dd12f68b0f372b23183cf470fa643f73274f66e34dfc0dacd1ce1a9843e",
|
| 86 |
+
"size": 1234
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio/wrapper_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture_class": "NeuralSym-style template relevance FFN",
|
| 3 |
+
"device_supported": [
|
| 4 |
+
"cpu",
|
| 5 |
+
"cuda"
|
| 6 |
+
],
|
| 7 |
+
"input_schema": {
|
| 8 |
+
"product_field": "smiles",
|
| 9 |
+
"request_format": {
|
| 10 |
+
"smiles": [
|
| 11 |
+
"product_smiles"
|
| 12 |
+
]
|
| 13 |
+
},
|
| 14 |
+
"target_field": "reactants"
|
| 15 |
+
},
|
| 16 |
+
"license": "mit",
|
| 17 |
+
"loader": {
|
| 18 |
+
"kind": "askcos_template_relevance_safetensors",
|
| 19 |
+
"model_args": "aux/model_args.json",
|
| 20 |
+
"model_version": "1.0",
|
| 21 |
+
"served_model_name": "pistachio",
|
| 22 |
+
"source_handler": "templ_rel_handler.py",
|
| 23 |
+
"state_dict_format": "safetensors",
|
| 24 |
+
"templates": "aux/templates.jsonl"
|
| 25 |
+
},
|
| 26 |
+
"package_layout": {
|
| 27 |
+
"aux_dir": "aux",
|
| 28 |
+
"weights_path": "model.safetensors"
|
| 29 |
+
},
|
| 30 |
+
"runtime_file_map": {
|
| 31 |
+
"aux/model_args.json": "aux/model_args.json",
|
| 32 |
+
"aux/templates.jsonl": "aux/templates.jsonl",
|
| 33 |
+
"model.safetensors": "model.safetensors"
|
| 34 |
+
},
|
| 35 |
+
"task_direction": "retrosynthesis",
|
| 36 |
+
"wrapper_family": "askcos_template_relevance"
|
| 37 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/SHA256SUMS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
4afef999655ed2ee022510e7211614c066414bdcb178bab2fb347af3726da5d8 aux/MAR-INF/MANIFEST.json
|
| 2 |
+
f5bef6f645347b15a1bbff2e56117d1a58f56234bdd24d89e9a18bd7a0d193d5 aux/mar_files/misc.py
|
| 3 |
+
8ee17cac57f65d954a599f18bbcf9df069a1acb0be86064a21188d4f5c2171f5 aux/mar_files/models.py
|
| 4 |
+
b5d99468d88374391e7ce7a1766ee287b8fbb9f1dbac70743606d43dee4f9f59 aux/mar_files/templ_rel_handler.py
|
| 5 |
+
9a0d07ded45cd94abeeed5e8c1f30a1e590080b10b4bbc8314aa5e4cbc622d83 aux/mar_files/templ_rel_parser.py
|
| 6 |
+
67bee61a87662e2224bb85725bdf8de048ff4ebcc934fc8ed1cdfd61186e4a4b aux/mar_files/utils.py
|
| 7 |
+
3247db61ca9acb4c96eeb103abc68f93981269ed23db0be3bf34ab5a69d6e58b aux/mar_members.json
|
| 8 |
+
cc62c4532aff590fd3ef222a3c1a6e9b3b70e10dd1f199d4f0dd405127c3bc02 aux/model_args.json
|
| 9 |
+
bc047b7afb7a1a3dbaf70225560fd396eee228f106ff12f615de80dea999f8b7 aux/safetensors_conversion.json
|
| 10 |
+
5fe58b0472aac4ea508d401116705e0f2795f8c43c8726486f98a06985f49edb aux/templates.jsonl
|
| 11 |
+
a10255a6abd89a35d2ea48a842839f403b4b1586805c3010c0d076e0ae23754d benchmarks/default_test.jsonl
|
| 12 |
+
818b98cb596a3712b8eb192612b6b524c217f653d90ec26a8df25e356cdfd8ad benchmarks/metadata.json
|
| 13 |
+
87d7e0013f97da27e4fd878b0598466ac07202fe131ac0f7dbdd2b423482751f benchmarks/native/ref_routes_reaction_hashes.txt
|
| 14 |
+
872533b44788754af3aa19918a04c2a508d30249d2c93eb480078cb638ad3389 benchmarks/native/selected_reactions.csv
|
| 15 |
+
04d1f5ab53afff49ee6e0934a588d1c1d7b12afdc53da571303f8973bbec760a manifest.json
|
| 16 |
+
d7d0e725423a089059964d9c34e7f6e301a9c8bc22d3f0be6f0976aabb5425aa model.safetensors
|
| 17 |
+
d068b06b4e1cf8feb80c34364ddd7b35006249e95b530959d983d73dc3efe6c8 provenance.json
|
| 18 |
+
67740d56186a83f70de1fba6f10f3eb7d8869f638fb18c8507c6c95e030a278a wrapper_config.json
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/aux/mar_members.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"members": [
|
| 3 |
+
{
|
| 4 |
+
"compress_size": 2553981,
|
| 5 |
+
"modified": "2023-07-07T04:16:08",
|
| 6 |
+
"path": "templates.jsonl",
|
| 7 |
+
"size": 17047890
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"compress_size": 441,
|
| 11 |
+
"modified": "2023-07-11T20:38:48",
|
| 12 |
+
"path": "misc.py",
|
| 13 |
+
"size": 1062
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"compress_size": 2113,
|
| 17 |
+
"modified": "2023-09-17T00:40:16",
|
| 18 |
+
"path": "utils.py",
|
| 19 |
+
"size": 6591
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"compress_size": 1249,
|
| 23 |
+
"modified": "2023-07-11T20:38:48",
|
| 24 |
+
"path": "models.py",
|
| 25 |
+
"size": 4027
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"compress_size": 128374269,
|
| 29 |
+
"modified": "2023-07-07T04:16:08",
|
| 30 |
+
"path": "model_latest.pt",
|
| 31 |
+
"size": 141616535
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"compress_size": 992,
|
| 35 |
+
"modified": "2023-09-16T23:59:50",
|
| 36 |
+
"path": "templ_rel_parser.py",
|
| 37 |
+
"size": 4119
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"compress_size": 2524,
|
| 41 |
+
"modified": "2023-09-17T00:43:56",
|
| 42 |
+
"path": "templ_rel_handler.py",
|
| 43 |
+
"size": 8685
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"compress_size": 151,
|
| 47 |
+
"modified": "2023-09-17T00:44:00",
|
| 48 |
+
"path": "MAR-INF/MANIFEST.json",
|
| 49 |
+
"size": 218
|
| 50 |
+
}
|
| 51 |
+
]
|
| 52 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/aux/model_args.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dropout": 0.1,
|
| 3 |
+
"fp_size": 2048,
|
| 4 |
+
"gating_activation": "sigmoid",
|
| 5 |
+
"hidden_activation": "relu",
|
| 6 |
+
"hidden_sizes": [
|
| 7 |
+
1024
|
| 8 |
+
],
|
| 9 |
+
"load_from": "",
|
| 10 |
+
"min_freq": 1,
|
| 11 |
+
"model_ckpt_new": "./tmp/legacy_v2/pistachio_ringbreaker.pt",
|
| 12 |
+
"model_folder_old": "./tmp/legacy_v1/pistachio_ringbreaker/1",
|
| 13 |
+
"n_params": 35403501,
|
| 14 |
+
"n_templates": 32493,
|
| 15 |
+
"num_cores": 4,
|
| 16 |
+
"radius": 2,
|
| 17 |
+
"skip_connection": "none",
|
| 18 |
+
"template_file_new": "./tmp/legacy_v2/retro.templates.pistachio_ringbreaker.jsonl",
|
| 19 |
+
"template_file_old": "./tmp/legacy_v1/retro.templates.pistachio_ringbreaker.json.gz"
|
| 20 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/aux/safetensors_conversion.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format": "safetensors",
|
| 3 |
+
"num_tensors": 4,
|
| 4 |
+
"path": "model.safetensors",
|
| 5 |
+
"roundtrip_tensor_equal": true,
|
| 6 |
+
"runtime_assets": {
|
| 7 |
+
"model_args": "aux/model_args.json",
|
| 8 |
+
"templates": "aux/templates.jsonl"
|
| 9 |
+
},
|
| 10 |
+
"source_member": "model_latest.pt",
|
| 11 |
+
"status": "converted"
|
| 12 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/benchmarks/metadata.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 3 |
+
"built_at": "1970-01-01T00:00:00+00:00",
|
| 4 |
+
"checkpoint_id": "pistachio_ringbreaker",
|
| 5 |
+
"dataset_id": "askcos_retro_template_relevance_pistachio_ringbreaker_paroutes_reference_route_test",
|
| 6 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 7 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 8 |
+
"native_sources": [
|
| 9 |
+
{
|
| 10 |
+
"notes": [
|
| 11 |
+
"Public PaRoutes selected_reactions.csv source table used to reconstruct the one-step reference-route reaction subset."
|
| 12 |
+
],
|
| 13 |
+
"origin": "copied_from_local_public_record",
|
| 14 |
+
"relative_path": "benchmarks/native/selected_reactions.csv",
|
| 15 |
+
"source_url": "https://zenodo.org/records/7341155/files/selected_reactions.csv?download=1"
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"notes": [
|
| 19 |
+
"Public PaRoutes hash list identifying the reference-route reactions used here as a redistribution-safe ASKCOS compatibility benchmark."
|
| 20 |
+
],
|
| 21 |
+
"origin": "copied_from_local_public_record",
|
| 22 |
+
"relative_path": "benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 23 |
+
"source_url": "https://zenodo.org/records/7341155/files/ref_routes_reaction_hashes.txt?download=1"
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"notes": [
|
| 27 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 28 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 29 |
+
],
|
| 30 |
+
"num_examples": 56657,
|
| 31 |
+
"split": "test"
|
| 32 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/manifest.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auxiliary_files": [
|
| 3 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 4 |
+
"aux/mar_files/misc.py",
|
| 5 |
+
"aux/mar_files/models.py",
|
| 6 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 7 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 8 |
+
"aux/mar_files/utils.py",
|
| 9 |
+
"aux/mar_members.json",
|
| 10 |
+
"aux/model_args.json",
|
| 11 |
+
"aux/safetensors_conversion.json",
|
| 12 |
+
"aux/templates.jsonl",
|
| 13 |
+
"benchmarks/default_test.jsonl",
|
| 14 |
+
"benchmarks/metadata.json",
|
| 15 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 16 |
+
"benchmarks/native/selected_reactions.csv"
|
| 17 |
+
],
|
| 18 |
+
"benchmark_datasets": [
|
| 19 |
+
{
|
| 20 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 21 |
+
"dataset_id": "askcos_retro_template_relevance_pistachio_ringbreaker_paroutes_reference_route_test",
|
| 22 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 23 |
+
"default": true,
|
| 24 |
+
"format": "jsonl",
|
| 25 |
+
"metadata_path": "benchmarks/metadata.json",
|
| 26 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 27 |
+
"native_source_paths": [
|
| 28 |
+
"benchmarks/native/selected_reactions.csv",
|
| 29 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt"
|
| 30 |
+
],
|
| 31 |
+
"notes": [
|
| 32 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 33 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 34 |
+
],
|
| 35 |
+
"num_examples": 56657,
|
| 36 |
+
"path": "benchmarks/default_test.jsonl",
|
| 37 |
+
"split": "test"
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"checkpoint_id": "pistachio_ringbreaker",
|
| 41 |
+
"contained_artifact_bindings": [
|
| 42 |
+
{
|
| 43 |
+
"canonical_split_family": "askcos_pistachio_ringbreaker_split_unspecified",
|
| 44 |
+
"dataset_ref": "askcos_pistachio_ringbreaker_release",
|
| 45 |
+
"path": "modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 46 |
+
"stage": "released_torchserve_archive"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"conversion": {
|
| 50 |
+
"converted_at": "1970-01-01T00:00:00+00:00",
|
| 51 |
+
"notes": [
|
| 52 |
+
"The upstream ASKCOS TorchServe .mar was unpacked into native bundle assets.",
|
| 53 |
+
"Tensor weights are stored canonically as model.safetensors; non-tensor runtime assets are stored under aux/.",
|
| 54 |
+
"The original .mar archive is not required for wrapper inference."
|
| 55 |
+
],
|
| 56 |
+
"safetensors": {
|
| 57 |
+
"format": "safetensors",
|
| 58 |
+
"num_tensors": 4,
|
| 59 |
+
"path": "model.safetensors",
|
| 60 |
+
"roundtrip_tensor_equal": true,
|
| 61 |
+
"runtime_assets": {
|
| 62 |
+
"model_args": "aux/model_args.json",
|
| 63 |
+
"templates": "aux/templates.jsonl"
|
| 64 |
+
},
|
| 65 |
+
"source_member": "model_latest.pt",
|
| 66 |
+
"status": "converted"
|
| 67 |
+
},
|
| 68 |
+
"source_format": "torchserve_mar_embedded_checkpoint",
|
| 69 |
+
"status": "converted",
|
| 70 |
+
"tool_version": "initial"
|
| 71 |
+
},
|
| 72 |
+
"display_name": "pistachio_ringbreaker",
|
| 73 |
+
"format_version": 1,
|
| 74 |
+
"generated_at": "1970-01-01T00:00:00+00:00",
|
| 75 |
+
"input_schema": {
|
| 76 |
+
"product_field": "smiles",
|
| 77 |
+
"request_format": {
|
| 78 |
+
"smiles": [
|
| 79 |
+
"product_smiles"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
"target_field": "reactants"
|
| 83 |
+
},
|
| 84 |
+
"model_id": "askcos_retro_template_relevance",
|
| 85 |
+
"model_role": "backward",
|
| 86 |
+
"normalized_checkpoint_id": "pistachio_ringbreaker",
|
| 87 |
+
"package_layout": {
|
| 88 |
+
"aux_dir": "aux",
|
| 89 |
+
"benchmarks_dir": "benchmarks",
|
| 90 |
+
"weights_path": "model.safetensors"
|
| 91 |
+
},
|
| 92 |
+
"source_registry_refs": [
|
| 93 |
+
{
|
| 94 |
+
"checkpoint_id": "pistachio_ringbreaker",
|
| 95 |
+
"model_id": "askcos_retro_template_relevance"
|
| 96 |
+
}
|
| 97 |
+
],
|
| 98 |
+
"split_provenance": [
|
| 99 |
+
{
|
| 100 |
+
"canonical_split_family": "askcos_pistachio_ringbreaker_split_unspecified",
|
| 101 |
+
"dataset_ref": "askcos_pistachio_ringbreaker_release",
|
| 102 |
+
"split_names": [],
|
| 103 |
+
"stage": "released_torchserve_archive"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"canonical_split_family": "askcos_pistachio_ringbreaker_split_unspecified",
|
| 107 |
+
"dataset_ref": "askcos_pistachio_ringbreaker_release",
|
| 108 |
+
"path": "modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 109 |
+
"stage": "released_torchserve_archive"
|
| 110 |
+
}
|
| 111 |
+
],
|
| 112 |
+
"task_direction": "retrosynthesis",
|
| 113 |
+
"training_dataset_refs": [
|
| 114 |
+
"askcos_pistachio_ringbreaker_release"
|
| 115 |
+
],
|
| 116 |
+
"training_stage_bindings": [
|
| 117 |
+
{
|
| 118 |
+
"canonical_split_family": "askcos_pistachio_ringbreaker_split_unspecified",
|
| 119 |
+
"dataset_ref": "askcos_pistachio_ringbreaker_release",
|
| 120 |
+
"split_names": [],
|
| 121 |
+
"stage": "released_torchserve_archive"
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"canonical_split_family": "askcos_pistachio_ringbreaker_split_unspecified",
|
| 125 |
+
"dataset_ref": "askcos_pistachio_ringbreaker_release",
|
| 126 |
+
"path": "modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 127 |
+
"stage": "released_torchserve_archive"
|
| 128 |
+
}
|
| 129 |
+
],
|
| 130 |
+
"weights": {
|
| 131 |
+
"dtype_summary": "float tensors preserved from upstream checkpoint",
|
| 132 |
+
"framework": "safetensors",
|
| 133 |
+
"path": "model.safetensors",
|
| 134 |
+
"tensor_namespace": "askcos_template_relevance"
|
| 135 |
+
},
|
| 136 |
+
"wrapper_config": "wrapper_config.json",
|
| 137 |
+
"wrapper_family": "askcos_template_relevance"
|
| 138 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/provenance.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conversion_notes": [
|
| 3 |
+
"The ASKCOS TorchServe .mar source archive was unpacked; model.mar is not copied into the normalized package.",
|
| 4 |
+
"Embedded tensor weights were serialized to model.safetensors and verified by safetensors round-trip equality.",
|
| 5 |
+
"Required non-tensor runtime assets such as templates, vocabularies, model args, OpenNMT metadata, and Graph2SMILES source support files are copied under aux/.",
|
| 6 |
+
"Lightweight MAR metadata is retained under aux/ for provenance only."
|
| 7 |
+
],
|
| 8 |
+
"copied_sidecars": [
|
| 9 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 10 |
+
"aux/mar_files/misc.py",
|
| 11 |
+
"aux/mar_files/models.py",
|
| 12 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 13 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 14 |
+
"aux/mar_files/utils.py",
|
| 15 |
+
"aux/mar_members.json",
|
| 16 |
+
"aux/model_args.json",
|
| 17 |
+
"aux/safetensors_conversion.json",
|
| 18 |
+
"aux/templates.jsonl"
|
| 19 |
+
],
|
| 20 |
+
"inner_members": [
|
| 21 |
+
{
|
| 22 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 23 |
+
"member": "templates.jsonl",
|
| 24 |
+
"role": "template_library"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 28 |
+
"member": "misc.py",
|
| 29 |
+
"role": "archive_member"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 33 |
+
"member": "utils.py",
|
| 34 |
+
"role": "archive_member"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 38 |
+
"member": "models.py",
|
| 39 |
+
"role": "archive_member"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 43 |
+
"member": "model_latest.pt",
|
| 44 |
+
"role": "weights_source"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 48 |
+
"member": "templ_rel_parser.py",
|
| 49 |
+
"role": "archive_member"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 53 |
+
"member": "templ_rel_handler.py",
|
| 54 |
+
"role": "archive_member"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 58 |
+
"member": "MAR-INF/MANIFEST.json",
|
| 59 |
+
"role": "torchserve_manifest"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"normalized_checkpoint_id": "pistachio_ringbreaker",
|
| 63 |
+
"source_artifacts": [
|
| 64 |
+
{
|
| 65 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 66 |
+
"kind": "local_repo_file",
|
| 67 |
+
"path": "datasets/modelos_ASKCOS/mars/pistachio_ringbreaker.mar",
|
| 68 |
+
"role": "source_artifact",
|
| 69 |
+
"sha256": "f9235d0a2df9730d8d119df01252d4f5f360bd999926112f6a37fbaa96e023ab",
|
| 70 |
+
"size": 130936578
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 74 |
+
"kind": "local_repo_file",
|
| 75 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 76 |
+
"role": "source_artifact",
|
| 77 |
+
"sha256": "e88d26f86ce79d2c7d8f05d1a59e3b1b88bde69c3afb95d065c932ff058092be",
|
| 78 |
+
"size": 2374
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 82 |
+
"kind": "local_repo_file",
|
| 83 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 84 |
+
"role": "source_artifact",
|
| 85 |
+
"sha256": "c2351dd12f68b0f372b23183cf470fa643f73274f66e34dfc0dacd1ce1a9843e",
|
| 86 |
+
"size": 1234
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
checkpoints/askcos_retro_template_relevance/pistachio_ringbreaker/wrapper_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture_class": "NeuralSym-style template relevance FFN",
|
| 3 |
+
"device_supported": [
|
| 4 |
+
"cpu",
|
| 5 |
+
"cuda"
|
| 6 |
+
],
|
| 7 |
+
"input_schema": {
|
| 8 |
+
"product_field": "smiles",
|
| 9 |
+
"request_format": {
|
| 10 |
+
"smiles": [
|
| 11 |
+
"product_smiles"
|
| 12 |
+
]
|
| 13 |
+
},
|
| 14 |
+
"target_field": "reactants"
|
| 15 |
+
},
|
| 16 |
+
"license": "mit",
|
| 17 |
+
"loader": {
|
| 18 |
+
"kind": "askcos_template_relevance_safetensors",
|
| 19 |
+
"model_args": "aux/model_args.json",
|
| 20 |
+
"model_version": "1.0",
|
| 21 |
+
"served_model_name": "pistachio_ringbreaker",
|
| 22 |
+
"source_handler": "templ_rel_handler.py",
|
| 23 |
+
"state_dict_format": "safetensors",
|
| 24 |
+
"templates": "aux/templates.jsonl"
|
| 25 |
+
},
|
| 26 |
+
"package_layout": {
|
| 27 |
+
"aux_dir": "aux",
|
| 28 |
+
"weights_path": "model.safetensors"
|
| 29 |
+
},
|
| 30 |
+
"runtime_file_map": {
|
| 31 |
+
"aux/model_args.json": "aux/model_args.json",
|
| 32 |
+
"aux/templates.jsonl": "aux/templates.jsonl",
|
| 33 |
+
"model.safetensors": "model.safetensors"
|
| 34 |
+
},
|
| 35 |
+
"task_direction": "retrosynthesis",
|
| 36 |
+
"wrapper_family": "askcos_template_relevance"
|
| 37 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/SHA256SUMS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ffa111d011edf3ba7b91976b6d659691efe28435e4df0673be5aff9cd0b79cc7 aux/MAR-INF/MANIFEST.json
|
| 2 |
+
f5bef6f645347b15a1bbff2e56117d1a58f56234bdd24d89e9a18bd7a0d193d5 aux/mar_files/misc.py
|
| 3 |
+
8ee17cac57f65d954a599f18bbcf9df069a1acb0be86064a21188d4f5c2171f5 aux/mar_files/models.py
|
| 4 |
+
b5d99468d88374391e7ce7a1766ee287b8fbb9f1dbac70743606d43dee4f9f59 aux/mar_files/templ_rel_handler.py
|
| 5 |
+
9a0d07ded45cd94abeeed5e8c1f30a1e590080b10b4bbc8314aa5e4cbc622d83 aux/mar_files/templ_rel_parser.py
|
| 6 |
+
67bee61a87662e2224bb85725bdf8de048ff4ebcc934fc8ed1cdfd61186e4a4b aux/mar_files/utils.py
|
| 7 |
+
ac56f2d92d520d3d9c03c0e2ab09051dcce5230549d2023b843767743d0ad72a aux/mar_members.json
|
| 8 |
+
3b1a4832e0e44c3bcb68483efa97a712dfcc926cacdae8b6aab87812e6d31b1e aux/model_args.json
|
| 9 |
+
3a9b5596e16ef91b405c674138426ebb61d32d2b308f59d4211c804791b66d36 aux/safetensors_conversion.json
|
| 10 |
+
6a7983b86edc7164ee4fccb814598cdc311049d9815e29e981462967f4670501 aux/templates.jsonl
|
| 11 |
+
a10255a6abd89a35d2ea48a842839f403b4b1586805c3010c0d076e0ae23754d benchmarks/default_test.jsonl
|
| 12 |
+
d04f29c0d724337f6491272215238fa1b1e4a06d8b351f9dc7e9b0657e999860 benchmarks/metadata.json
|
| 13 |
+
87d7e0013f97da27e4fd878b0598466ac07202fe131ac0f7dbdd2b423482751f benchmarks/native/ref_routes_reaction_hashes.txt
|
| 14 |
+
872533b44788754af3aa19918a04c2a508d30249d2c93eb480078cb638ad3389 benchmarks/native/selected_reactions.csv
|
| 15 |
+
c391d2a8e52552add8b48d9572559a17e939efabcc67d68ea8612f4399d58ae4 manifest.json
|
| 16 |
+
834cddcb66580a3c26377ee996f93f780e24530ca9076f518a3bd53714be412e model.safetensors
|
| 17 |
+
0f6d6b8b9e9786e20270075294013fd6128902546b5bbfbc7d0312c4dd95698e provenance.json
|
| 18 |
+
f3f242bafa0df363d26499bb4e72f3a401678e48f1667c4ed3628e058d87251d wrapper_config.json
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/MAR-INF/MANIFEST.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"archiverVersion": "0.3.1",
|
| 3 |
+
"createdOn": "17/09/2023 00:44:01",
|
| 4 |
+
"model": {
|
| 5 |
+
"handler": "templ_rel_handler.py",
|
| 6 |
+
"modelName": "reaxys",
|
| 7 |
+
"modelVersion": "1.0"
|
| 8 |
+
},
|
| 9 |
+
"runtime": "python"
|
| 10 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/misc.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class BlockPrint:
|
| 8 |
+
"""Context manager to suppress printing from subprocesses"""
|
| 9 |
+
def __enter__(self):
|
| 10 |
+
self._original_stdout = sys.stdout
|
| 11 |
+
sys.stdout = open(os.devnull, 'w')
|
| 12 |
+
|
| 13 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
| 14 |
+
sys.stdout.close()
|
| 15 |
+
sys.stdout = self._original_stdout
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def log_args(args, message: str):
|
| 19 |
+
log_rank_0(message)
|
| 20 |
+
for k, v in vars(args).items():
|
| 21 |
+
log_rank_0(f"**** {k} = *{v}*")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def log_rank_0(message):
|
| 25 |
+
if torch.distributed.is_initialized():
|
| 26 |
+
if torch.distributed.get_rank() == 0:
|
| 27 |
+
logging.info(message)
|
| 28 |
+
sys.stdout.flush()
|
| 29 |
+
else:
|
| 30 |
+
logging.info(message)
|
| 31 |
+
sys.stdout.flush()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def setup_logger(log_file):
|
| 35 |
+
logger = logging.getLogger()
|
| 36 |
+
logger.setLevel(logging.INFO)
|
| 37 |
+
|
| 38 |
+
fh = logging.FileHandler(log_file)
|
| 39 |
+
sh = logging.StreamHandler(sys.stdout)
|
| 40 |
+
fh.setLevel(logging.INFO)
|
| 41 |
+
sh.setLevel(logging.INFO)
|
| 42 |
+
logger.addHandler(fh)
|
| 43 |
+
logger.addHandler(sh)
|
| 44 |
+
|
| 45 |
+
return logger
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/models.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
from typing import Tuple
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_activation(name: str) -> nn.Module:
|
| 7 |
+
_activations = {
|
| 8 |
+
"relu": nn.ReLU(),
|
| 9 |
+
"elu": nn.ELU(),
|
| 10 |
+
"gelu": nn.GELU(),
|
| 11 |
+
"leakyrelu": nn.LeakyReLU(),
|
| 12 |
+
"sigmoid": nn.Sigmoid(),
|
| 13 |
+
"tanh": nn.Tanh()
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
return _activations[name]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class Dense(nn.Module):
|
| 20 |
+
def __init__(self, in_features: int, out_features: int,
|
| 21 |
+
hidden_act: nn.Module):
|
| 22 |
+
super().__init__()
|
| 23 |
+
self.linear = nn.Linear(in_features, out_features, bias=True)
|
| 24 |
+
self.hidden_act = hidden_act
|
| 25 |
+
|
| 26 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 27 |
+
return self.hidden_act(self.linear(x))
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Highway(nn.Module):
|
| 31 |
+
def __init__(self, in_features: int, out_features: int,
|
| 32 |
+
hidden_act: nn.Module, gating_act: nn.Module):
|
| 33 |
+
super().__init__()
|
| 34 |
+
self.dense = nn.Linear(in_features, out_features, bias=True)
|
| 35 |
+
self.gate = nn.Linear(in_features, out_features, bias=True)
|
| 36 |
+
self.hidden_act = hidden_act
|
| 37 |
+
self.gating_act = gating_act
|
| 38 |
+
|
| 39 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 40 |
+
transform = self.hidden_act(self.dense(x))
|
| 41 |
+
transform_gate = self.gating_act(self.gate(x))
|
| 42 |
+
carry_gate = 1 - transform_gate
|
| 43 |
+
output = transform * transform_gate + x * carry_gate
|
| 44 |
+
|
| 45 |
+
return output
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class TemplRel(nn.Module):
|
| 49 |
+
def __init__(self, args):
|
| 50 |
+
super().__init__()
|
| 51 |
+
|
| 52 |
+
if isinstance(args.hidden_sizes, str):
|
| 53 |
+
args.hidden_sizes = [int(size) for size in args.hidden_sizes.split(",")]
|
| 54 |
+
|
| 55 |
+
self.args = args
|
| 56 |
+
self.layers = self._build_layers(args)
|
| 57 |
+
self.output_layer = nn.Linear(
|
| 58 |
+
args.hidden_sizes[-1], args.n_templates, bias=True)
|
| 59 |
+
|
| 60 |
+
# we will do all the dropout here in TemplRel, for backward compatibility
|
| 61 |
+
self.dropout = nn.Dropout(args.dropout)
|
| 62 |
+
self.criterion = nn.CrossEntropyLoss(ignore_index=-1, reduction="mean")
|
| 63 |
+
|
| 64 |
+
@staticmethod
|
| 65 |
+
def _build_layers(args) -> nn.ModuleList:
|
| 66 |
+
hidden_act = get_activation(args.hidden_activation)
|
| 67 |
+
# input projection layer; no skip connection here
|
| 68 |
+
layers = nn.ModuleList([
|
| 69 |
+
Dense(args.fp_size, args.hidden_sizes[0], hidden_act=hidden_act)
|
| 70 |
+
])
|
| 71 |
+
|
| 72 |
+
for layer_i in range(len(args.hidden_sizes) - 1):
|
| 73 |
+
in_features = args.hidden_sizes[layer_i]
|
| 74 |
+
out_features = args.hidden_sizes[layer_i + 1]
|
| 75 |
+
|
| 76 |
+
if args.skip_connection == "none":
|
| 77 |
+
layer = Dense(in_features, out_features, hidden_act=hidden_act)
|
| 78 |
+
elif args.skip_connection == "highway":
|
| 79 |
+
layer = Highway(
|
| 80 |
+
in_features,
|
| 81 |
+
out_features,
|
| 82 |
+
hidden_act=hidden_act,
|
| 83 |
+
gating_act=get_activation(args.gating_activation)
|
| 84 |
+
)
|
| 85 |
+
else:
|
| 86 |
+
raise ValueError(
|
| 87 |
+
f"Unsupported skip_connection: {args.skip_connection}"
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
layers.append(layer)
|
| 91 |
+
|
| 92 |
+
return layers
|
| 93 |
+
|
| 94 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 95 |
+
for layer in self.layers:
|
| 96 |
+
x = layer(x)
|
| 97 |
+
x = self.dropout(x)
|
| 98 |
+
|
| 99 |
+
logits = self.output_layer(x) # returning *unnormalized* logits
|
| 100 |
+
|
| 101 |
+
return logits
|
| 102 |
+
|
| 103 |
+
def get_loss(self, logits: torch.Tensor, target: torch.Tensor
|
| 104 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 105 |
+
loss = self.criterion(input=logits, target=target)
|
| 106 |
+
|
| 107 |
+
predictions = torch.argmax(logits, dim=1)
|
| 108 |
+
accs = (predictions == target).float()
|
| 109 |
+
acc = accs.mean()
|
| 110 |
+
|
| 111 |
+
# Data points with label -1 (no/failed templates) should really be treated as
|
| 112 |
+
# if they are predicted wrong. Therefore, we turned off the masking. This may
|
| 113 |
+
# noticeably decrease the computed accuracy, but would reflect the reality.
|
| 114 |
+
|
| 115 |
+
# mask = (target != -1).long()
|
| 116 |
+
# accs = accs * mask
|
| 117 |
+
# acc = accs.sum() / mask.sum()
|
| 118 |
+
|
| 119 |
+
return loss, acc
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/templ_rel_handler.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import glob
|
| 3 |
+
import numpy as np
|
| 4 |
+
import os
|
| 5 |
+
import templ_rel_parser
|
| 6 |
+
import torch
|
| 7 |
+
import torch.nn.functional as F
|
| 8 |
+
from utils import canonicalize_smiles
|
| 9 |
+
from rdchiral.initialization import rdchiralReactants, rdchiralReaction
|
| 10 |
+
from rdchiral.main import rdchiralRun
|
| 11 |
+
from typing import Any, Dict, List, Tuple
|
| 12 |
+
from utils import get_model, load_templates_as_list, mol_smi_to_count_fp
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class TemplRelHandler:
|
| 16 |
+
"""TemplRel Handler for use with torchserve"""
|
| 17 |
+
|
| 18 |
+
def __init__(self):
|
| 19 |
+
self._context = None
|
| 20 |
+
self.manifest = None
|
| 21 |
+
self.initialized = False
|
| 22 |
+
|
| 23 |
+
self.args = None
|
| 24 |
+
self.templates = None
|
| 25 |
+
self.template_attributes = None
|
| 26 |
+
self.model = None
|
| 27 |
+
self.indices = None
|
| 28 |
+
self.device = None
|
| 29 |
+
|
| 30 |
+
def initialize(self, context):
|
| 31 |
+
self._context = context
|
| 32 |
+
self.manifest = context.manifest
|
| 33 |
+
|
| 34 |
+
properties = context.system_properties
|
| 35 |
+
model_dir = properties.get("model_dir")
|
| 36 |
+
print(glob.glob(f"{model_dir}/*"))
|
| 37 |
+
self.device = torch.device("cuda:" + str(properties.get("gpu_id"))
|
| 38 |
+
if torch.cuda.is_available() else "cpu")
|
| 39 |
+
|
| 40 |
+
serve_parser = argparse.ArgumentParser("serve")
|
| 41 |
+
templ_rel_parser.add_predict_opts(serve_parser)
|
| 42 |
+
self.args, _ = serve_parser.parse_known_args()
|
| 43 |
+
|
| 44 |
+
template_file = os.path.join(model_dir, "templates.jsonl")
|
| 45 |
+
print(f"Loading templates and attributes from {template_file}")
|
| 46 |
+
self.templates, self.template_attributes = \
|
| 47 |
+
load_templates_as_list(template_file=template_file)
|
| 48 |
+
print(f'Total number of templates: {len(self.templates)}')
|
| 49 |
+
|
| 50 |
+
checkpoint_file = os.path.join(model_dir, "model_latest.pt")
|
| 51 |
+
print(f"Building model and loading from {checkpoint_file}")
|
| 52 |
+
|
| 53 |
+
self.args.load_from = checkpoint_file
|
| 54 |
+
self.args.local_rank = -1
|
| 55 |
+
# Note: the model will be built using pretraining args
|
| 56 |
+
self.model, _ = get_model(self.args, device=self.device)
|
| 57 |
+
self.model.eval()
|
| 58 |
+
|
| 59 |
+
self.initialized = True
|
| 60 |
+
|
| 61 |
+
def preprocess(self, data: List[dict]
|
| 62 |
+
) -> Tuple[List[str], int, float, List[Dict[str, Any]]]:
|
| 63 |
+
print(f"input: {data}")
|
| 64 |
+
canonical_smiles = [canonicalize_smiles(smi)
|
| 65 |
+
for smi in data[0]["body"]["smiles"]]
|
| 66 |
+
max_num_templates = data[0]["body"].get("max_num_templates", 1000)
|
| 67 |
+
max_cum_prob = data[0]["body"].get("max_cum_prob", 0.999)
|
| 68 |
+
attribute_filter = data[0]["body"].get("attribute_filter", [])
|
| 69 |
+
|
| 70 |
+
return canonical_smiles, max_num_templates, max_cum_prob, attribute_filter
|
| 71 |
+
|
| 72 |
+
def inference(self, inputs: Tuple[List[str], int, float, List[Dict[str, Any]]]
|
| 73 |
+
) -> List[Dict[str, Any]]:
|
| 74 |
+
canonical_smiles, max_num_templates, max_cum_prob, attribute_filter = inputs
|
| 75 |
+
filters = [x for x in attribute_filter
|
| 76 |
+
if x.get("name") in self.template_attributes]
|
| 77 |
+
|
| 78 |
+
if filters:
|
| 79 |
+
filter_query = " and ".join(
|
| 80 |
+
[f"({q['name']} {q['logic']} {q['value']})" for q in filters]
|
| 81 |
+
)
|
| 82 |
+
filtered_indices = self.template_attributes.query(filter_query).index.values
|
| 83 |
+
|
| 84 |
+
results = []
|
| 85 |
+
|
| 86 |
+
# maybe not the most efficient way, but should have been faster than v1 already
|
| 87 |
+
with torch.no_grad():
|
| 88 |
+
for smi in canonical_smiles:
|
| 89 |
+
prod_fp = mol_smi_to_count_fp(smi, self.args.radius, self.args.fp_size)
|
| 90 |
+
final_fp = torch.as_tensor(prod_fp.toarray()).float().to(self.device)
|
| 91 |
+
|
| 92 |
+
# template_prioritizer.predict()
|
| 93 |
+
logits = self.model(final_fp)
|
| 94 |
+
scores = F.softmax(logits, dim=1)
|
| 95 |
+
scores = scores.squeeze(dim=0).cpu().numpy()
|
| 96 |
+
indices = np.argsort(-scores)
|
| 97 |
+
scores = scores[indices]
|
| 98 |
+
|
| 99 |
+
# retro_transformer.filter_by_attributes()
|
| 100 |
+
if filters:
|
| 101 |
+
bool_mask = np.isin(indices, filtered_indices)
|
| 102 |
+
indices = indices[bool_mask]
|
| 103 |
+
scores = scores[bool_mask]
|
| 104 |
+
|
| 105 |
+
# template_prioritizer.truncate()
|
| 106 |
+
if max_num_templates:
|
| 107 |
+
indices = indices[:max_num_templates]
|
| 108 |
+
scores = scores[:max_num_templates]
|
| 109 |
+
|
| 110 |
+
if max_cum_prob:
|
| 111 |
+
exceeds = np.nonzero(np.cumsum(scores) >= max_cum_prob)[0]
|
| 112 |
+
if exceeds.size:
|
| 113 |
+
# Include the prediction which exceeds max_cum_prob
|
| 114 |
+
max_index = exceeds[0] + 1
|
| 115 |
+
scores = scores[:max_index]
|
| 116 |
+
indices = indices[:max_index]
|
| 117 |
+
|
| 118 |
+
smiles_to_index = {}
|
| 119 |
+
result = {
|
| 120 |
+
"templates": [],
|
| 121 |
+
"reactants": [],
|
| 122 |
+
"scores": []
|
| 123 |
+
}
|
| 124 |
+
for rank, (score, idx) in enumerate(zip(scores, indices), start=1):
|
| 125 |
+
template = self.templates[idx]
|
| 126 |
+
# IMPORTANT MAGIC from v1. DO NOT TOUCH
|
| 127 |
+
# Force reactants and products to be one pseudo-molecule (bookkeeping)
|
| 128 |
+
reaction_smarts = template["reaction_smarts"]
|
| 129 |
+
reaction_smarts_one = "(" + reaction_smarts.replace(">>", ")>>(") + ")"
|
| 130 |
+
rxn = rdchiralReaction(str(reaction_smarts_one))
|
| 131 |
+
prod = rdchiralReactants(smi)
|
| 132 |
+
try:
|
| 133 |
+
# New: set return_mapped to False. Remap after in expand_one
|
| 134 |
+
reactants = rdchiralRun(rxn, prod, return_mapped=False)
|
| 135 |
+
except:
|
| 136 |
+
continue # unknown error in rdchiral
|
| 137 |
+
|
| 138 |
+
if not reactants: # empty precursors
|
| 139 |
+
continue
|
| 140 |
+
|
| 141 |
+
template = {k: v for k, v in template.items()
|
| 142 |
+
if k not in ["references", "rxn"]}
|
| 143 |
+
template["template_score"] = score.item()
|
| 144 |
+
template["template_rank"] = rank
|
| 145 |
+
|
| 146 |
+
for reactant in reactants:
|
| 147 |
+
# here we just return the full template with metadata
|
| 148 |
+
# in theory it should also be fetchable from the DB
|
| 149 |
+
smiles_list = reactant.split(".")
|
| 150 |
+
if template["intra_only"] and len(smiles_list) > 1:
|
| 151 |
+
# Disallowed intermolecular reaction
|
| 152 |
+
continue
|
| 153 |
+
if template["dimer_only"] and (
|
| 154 |
+
len(set(smiles_list)) != 1 or len(smiles_list) != 2
|
| 155 |
+
):
|
| 156 |
+
# Not a dimer
|
| 157 |
+
continue
|
| 158 |
+
if smi in smiles_list:
|
| 159 |
+
# Skip if no transformation happened
|
| 160 |
+
continue
|
| 161 |
+
|
| 162 |
+
joined_smiles = ".".join(sorted(smiles_list))
|
| 163 |
+
if joined_smiles in smiles_to_index:
|
| 164 |
+
# Precursor was already generated by another template
|
| 165 |
+
# -> update metadata. Templates are ordered by score, so
|
| 166 |
+
# no need to update template score or rank
|
| 167 |
+
res = result["templates"][
|
| 168 |
+
smiles_to_index[joined_smiles]
|
| 169 |
+
]
|
| 170 |
+
if template["_id"] not in res["tforms"]:
|
| 171 |
+
res["tforms"].append(template["_id"])
|
| 172 |
+
res["num_examples"] += template["count"]
|
| 173 |
+
else:
|
| 174 |
+
# New precursor -> generate metadata
|
| 175 |
+
template["tforms"] = [template["_id"]]
|
| 176 |
+
template["num_examples"] = template["count"]
|
| 177 |
+
smiles_to_index[joined_smiles] = len(result["templates"])
|
| 178 |
+
|
| 179 |
+
result["templates"].append(template)
|
| 180 |
+
result["reactants"].append(reactant)
|
| 181 |
+
result["scores"].append(score.item())
|
| 182 |
+
|
| 183 |
+
del rxn, prod, reactants
|
| 184 |
+
|
| 185 |
+
results.append(result)
|
| 186 |
+
|
| 187 |
+
return results
|
| 188 |
+
|
| 189 |
+
def postprocess(self, data: List[Dict[str, Any]]) -> List[List[Dict[str, Any]]]:
|
| 190 |
+
return [data]
|
| 191 |
+
|
| 192 |
+
def handle(self, data: List, context) -> List[List[Dict[str, Any]]]:
|
| 193 |
+
self._context = context
|
| 194 |
+
|
| 195 |
+
inputs = self.preprocess(data)
|
| 196 |
+
output = self.inference(inputs)
|
| 197 |
+
output = self.postprocess(output)
|
| 198 |
+
|
| 199 |
+
# print(output) # turn off (debug) printing to speed up
|
| 200 |
+
|
| 201 |
+
return output
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/templ_rel_parser.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def add_model_opts(parser):
|
| 2 |
+
"""Model options"""
|
| 3 |
+
group = parser.add_argument_group("template_relevance_model")
|
| 4 |
+
group.add_argument("--seed", help="random seed", type=int, default=0)
|
| 5 |
+
group.add_argument("--load_from", help="Trained checkpoint to load from",
|
| 6 |
+
type=str, default="")
|
| 7 |
+
group.add_argument("--log_file", help="Log file name",
|
| 8 |
+
type=str, default="default")
|
| 9 |
+
group.add_argument("--model_path", help="Checkpoint folder",
|
| 10 |
+
type=str, default="./checkpoints")
|
| 11 |
+
group.add_argument('--local_rank', help='Local process rank',
|
| 12 |
+
type=int, default=-1, metavar='N')
|
| 13 |
+
group.add_argument("--num_cores", help="number of cpu cores to use",
|
| 14 |
+
type=int, default=4)
|
| 15 |
+
group.add_argument("--min_freq", help="minimum frequency of template in training "
|
| 16 |
+
"data to be retained",
|
| 17 |
+
type=int, default=1)
|
| 18 |
+
group.add_argument("--n_templates", help="number of training templates",
|
| 19 |
+
type=int, default=4)
|
| 20 |
+
group.add_argument("--radius", help="fingerprint radius", type=int, default=2)
|
| 21 |
+
group.add_argument("--fp_size", help="fingerprint size", type=int, default=2048)
|
| 22 |
+
group.add_argument("--hidden_sizes",
|
| 23 |
+
help="hidden sizes, as a single comma-separated string",
|
| 24 |
+
type=str, default="1024")
|
| 25 |
+
group.add_argument("--hidden_activation", help="hidden activation",
|
| 26 |
+
type=str, default="relu")
|
| 27 |
+
group.add_argument("--skip_connection", help="type of skip connection "
|
| 28 |
+
"(for backward compatibility)",
|
| 29 |
+
type=str, choices=["none", "highway"], default="none")
|
| 30 |
+
group.add_argument("--gating_activation", help="activation for highway gating",
|
| 31 |
+
type=str, default="sigmoid")
|
| 32 |
+
group.add_argument("--dropout", help="hidden dropout", type=float, default=0.1)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def add_train_opts(parser):
|
| 36 |
+
"""Training options"""
|
| 37 |
+
group = parser.add_argument_group("template_relevance_train")
|
| 38 |
+
group.add_argument("--backend", help="Backend for DDP", type=str, default="gloo")
|
| 39 |
+
group.add_argument("--train_batch_size", help="training batch size",
|
| 40 |
+
type=int, default=128)
|
| 41 |
+
group.add_argument("--val_batch_size", help="validation batch size",
|
| 42 |
+
type=int, default=256)
|
| 43 |
+
group.add_argument("--learning_rate", help="learning rate",
|
| 44 |
+
type=float, default=1e-3)
|
| 45 |
+
group.add_argument("--clip_norm", help="Max norm for gradient clipping",
|
| 46 |
+
type=float, default=20.0)
|
| 47 |
+
group.add_argument("--epochs", help="num. of epochs", type=int, default=30)
|
| 48 |
+
group.add_argument("--early_stop", help="whether to use early stopping",
|
| 49 |
+
action="store_true")
|
| 50 |
+
group.add_argument("--early_stop_patience",
|
| 51 |
+
help="num. of epochs w/o improvement before early stop",
|
| 52 |
+
type=int, default=2)
|
| 53 |
+
group.add_argument("--early_stop_min_delta",
|
| 54 |
+
help="min. improvement in criteria needed to not early stop",
|
| 55 |
+
type=float, default=1e-4)
|
| 56 |
+
group.add_argument("--lr_scheduler_factor",
|
| 57 |
+
help="factor by which to reduce LR (ReduceLROnPlateau)",
|
| 58 |
+
type=float, default=0.3)
|
| 59 |
+
group.add_argument("--lr_scheduler_patience",
|
| 60 |
+
help="num. of epochs w/o improvement before "
|
| 61 |
+
"reducing LR (ReduceLROnPlateau)",
|
| 62 |
+
type=int, default=1)
|
| 63 |
+
group.add_argument("--lr_cooldown", help="epochs to wait before resuming "
|
| 64 |
+
"normal operation (ReduceLROnPlateau)",
|
| 65 |
+
type=int, default=0)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def add_predict_opts(parser):
|
| 69 |
+
"""Predicting options"""
|
| 70 |
+
group = parser.add_argument_group("template_relevance_predict")
|
| 71 |
+
group.add_argument("--test_batch_size", help="Testing batch size",
|
| 72 |
+
type=int, default=256)
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_files/utils.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime
|
| 2 |
+
import json
|
| 3 |
+
import logging
|
| 4 |
+
import math
|
| 5 |
+
import misc
|
| 6 |
+
import numpy as np
|
| 7 |
+
import os
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import random
|
| 10 |
+
import sys
|
| 11 |
+
import torch
|
| 12 |
+
import torch.distributed as dist
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
from models import TemplRel
|
| 15 |
+
from rdchiral.initialization import rdchiralReaction
|
| 16 |
+
from rdkit import Chem
|
| 17 |
+
from rdkit.Chem import AllChem, DataStructs
|
| 18 |
+
from rdkit.Chem.rdFingerprintGenerator import GetMorganGenerator
|
| 19 |
+
from scipy import sparse
|
| 20 |
+
from torch.nn.init import xavier_uniform_
|
| 21 |
+
from torch.nn.parallel import DistributedDataParallel as DDP
|
| 22 |
+
from typing import Any, Dict, List, Tuple
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def set_seed(seed: int) -> None:
|
| 26 |
+
random.seed(seed)
|
| 27 |
+
os.environ['PYTHONHASHSEED'] = str(seed)
|
| 28 |
+
np.random.seed(seed)
|
| 29 |
+
torch.manual_seed(seed)
|
| 30 |
+
torch.cuda.manual_seed_all(seed)
|
| 31 |
+
torch.backends.cudnn.benchmark = False
|
| 32 |
+
torch.backends.cudnn.deterministic = True
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def init_dist(args):
|
| 36 |
+
if args.local_rank != -1:
|
| 37 |
+
dist.init_process_group(backend=args.backend,
|
| 38 |
+
init_method='env://',
|
| 39 |
+
timeout=datetime.timedelta(0, 7200))
|
| 40 |
+
torch.cuda.set_device(args.local_rank)
|
| 41 |
+
torch.backends.cudnn.benchmark = False
|
| 42 |
+
|
| 43 |
+
if dist.is_initialized():
|
| 44 |
+
logging.info(f"Device rank: {dist.get_rank()}")
|
| 45 |
+
sys.stdout.flush()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def canonicalize_smiles(smiles: str, remove_atom_number: bool = True) -> str:
|
| 49 |
+
"""Adapted from Molecular Transformer"""
|
| 50 |
+
smiles = "".join(smiles.split())
|
| 51 |
+
cano_smiles = ""
|
| 52 |
+
|
| 53 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 54 |
+
|
| 55 |
+
if mol is not None:
|
| 56 |
+
if remove_atom_number:
|
| 57 |
+
[a.ClearProp('molAtomMapNumber') for a in mol.GetAtoms()]
|
| 58 |
+
|
| 59 |
+
cano_smiles = Chem.MolToSmiles(mol, isomericSmiles=True, canonical=True)
|
| 60 |
+
# Sometimes stereochem takes another canonicalization... (just in case)
|
| 61 |
+
mol = Chem.MolFromSmiles(cano_smiles)
|
| 62 |
+
if mol is not None:
|
| 63 |
+
cano_smiles = Chem.MolToSmiles(mol, isomericSmiles=True, canonical=True)
|
| 64 |
+
|
| 65 |
+
return cano_smiles
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def canonicalize_smarts(smarts: str) -> str:
|
| 69 |
+
templ = Chem.MolFromSmarts(smarts)
|
| 70 |
+
if templ is None:
|
| 71 |
+
logging.info(f'Could not parse {smarts}')
|
| 72 |
+
return smarts
|
| 73 |
+
|
| 74 |
+
canon_smarts = Chem.MolToSmarts(templ)
|
| 75 |
+
if '[[se]]' in canon_smarts: # strange parse error
|
| 76 |
+
canon_smarts = smarts
|
| 77 |
+
|
| 78 |
+
return canon_smarts
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def mol_smi_to_count_fp_min_htoo(
|
| 82 |
+
mol_smi: str, radius: int = 2, fp_size: int = 2048, dtype: str = "int32"
|
| 83 |
+
) -> sparse.csr_matrix:
|
| 84 |
+
fp_gen = GetMorganGenerator(
|
| 85 |
+
radius=radius, countSimulation=True, includeChirality=True, fpSize=fp_size
|
| 86 |
+
)
|
| 87 |
+
mol = Chem.MolFromSmiles(mol_smi)
|
| 88 |
+
uint_count_fp = fp_gen.GetCountFingerprint(mol)
|
| 89 |
+
count_fp = np.empty((1, fp_size), dtype=dtype)
|
| 90 |
+
DataStructs.ConvertToNumpyArray(uint_count_fp, count_fp)
|
| 91 |
+
|
| 92 |
+
return sparse.csr_matrix(count_fp, dtype=dtype)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def mol_smi_to_count_fp(
|
| 96 |
+
mol_smi: str, radius: int = 2, fp_size: int = 2048, dtype: str = "int32"
|
| 97 |
+
) -> sparse.csr_matrix:
|
| 98 |
+
mol = Chem.MolFromSmiles(mol_smi)
|
| 99 |
+
fp_bit = AllChem.GetMorganFingerprintAsBitVect(
|
| 100 |
+
mol,
|
| 101 |
+
radius=radius,
|
| 102 |
+
nBits=fp_size,
|
| 103 |
+
useChirality=True
|
| 104 |
+
)
|
| 105 |
+
fp = np.empty((1, fp_size), dtype=dtype)
|
| 106 |
+
DataStructs.ConvertToNumpyArray(fp_bit, fp)
|
| 107 |
+
|
| 108 |
+
return sparse.csr_matrix(fp, dtype=dtype)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def get_model(args, device) -> Tuple[nn.Module, Dict[str, Any]]:
|
| 112 |
+
state = {}
|
| 113 |
+
if args.load_from:
|
| 114 |
+
misc.log_rank_0(f"Loading pretrained state from {args.load_from}")
|
| 115 |
+
state = torch.load(args.load_from, map_location=torch.device("cpu"))
|
| 116 |
+
pretrain_args = state["args"]
|
| 117 |
+
misc.log_args(pretrain_args, message="Logging pretraining args")
|
| 118 |
+
|
| 119 |
+
model = TemplRel(pretrain_args)
|
| 120 |
+
pretrain_state_dict = state["state_dict"]
|
| 121 |
+
pretrain_state_dict = {k.replace("module.", ""): v
|
| 122 |
+
for k, v in pretrain_state_dict.items()}
|
| 123 |
+
model.load_state_dict(pretrain_state_dict)
|
| 124 |
+
misc.log_rank_0("Loaded pretrained model state_dict.")
|
| 125 |
+
|
| 126 |
+
# Overwrite for preprocessing during (likely) inference
|
| 127 |
+
args.fp_size = pretrain_args.fp_size
|
| 128 |
+
args.radius = pretrain_args.radius
|
| 129 |
+
else:
|
| 130 |
+
model = TemplRel(args)
|
| 131 |
+
for p in model.parameters():
|
| 132 |
+
if p.dim() > 1 and p.requires_grad:
|
| 133 |
+
xavier_uniform_(p)
|
| 134 |
+
|
| 135 |
+
model.to(device)
|
| 136 |
+
if args.local_rank != -1:
|
| 137 |
+
model = DDP(
|
| 138 |
+
model,
|
| 139 |
+
device_ids=[args.local_rank],
|
| 140 |
+
output_device=args.local_rank
|
| 141 |
+
)
|
| 142 |
+
misc.log_rank_0("DDP setup finished")
|
| 143 |
+
|
| 144 |
+
return model, state
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def save_templates_from_list(templates: List[Dict[str, Any]], template_file: str):
|
| 148 |
+
with open(template_file, "w") as of:
|
| 149 |
+
for template in templates:
|
| 150 |
+
if "rxn" in template:
|
| 151 |
+
del template["rxn"]
|
| 152 |
+
of.write(f"{json.dumps(template)}\n")
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def save_templates_from_dict(templates: Dict[str, Dict[str, Any]], template_file: str):
|
| 156 |
+
with open(template_file, "w") as of:
|
| 157 |
+
for canon_templ, metadata in templates.items():
|
| 158 |
+
assert metadata["reaction_smarts"] == canon_templ
|
| 159 |
+
if "rxn" in metadata:
|
| 160 |
+
del metadata["rxn"]
|
| 161 |
+
of.write(f"{json.dumps(metadata)}\n")
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def load_templates_as_list(template_file: str
|
| 165 |
+
) -> Tuple[List[Dict[str, Any]], pd.DataFrame]:
|
| 166 |
+
templates = []
|
| 167 |
+
template_attributes = []
|
| 168 |
+
|
| 169 |
+
with open(template_file, "r") as f:
|
| 170 |
+
for line in f:
|
| 171 |
+
template = json.loads(line.strip())
|
| 172 |
+
del template["references"]
|
| 173 |
+
|
| 174 |
+
templates.append(template)
|
| 175 |
+
template_attributes.append(template.get("attributes", {}))
|
| 176 |
+
template_attributes = pd.DataFrame(template_attributes)
|
| 177 |
+
|
| 178 |
+
return templates, template_attributes
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def load_templates_as_dict(template_file: str) -> Dict[str, Dict[str, Any]]:
|
| 182 |
+
templates = {}
|
| 183 |
+
|
| 184 |
+
with open(template_file, "r") as f:
|
| 185 |
+
for line in f:
|
| 186 |
+
template = json.loads(line.strip())
|
| 187 |
+
templates[template["reaction_smarts"]] = template
|
| 188 |
+
|
| 189 |
+
return templates
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
def get_lr(optimizer) -> float:
|
| 193 |
+
for param_group in optimizer.param_groups:
|
| 194 |
+
return param_group["lr"]
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def param_count(model: nn.Module) -> int:
|
| 198 |
+
return sum(param.numel() for param in model.parameters() if param.requires_grad)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def param_norm(m: nn.Module) -> float:
|
| 202 |
+
return math.sqrt(sum([p.norm().item() ** 2 for p in m.parameters()]))
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
def grad_norm(m: nn.Module) -> float:
|
| 206 |
+
return math.sqrt(sum([p.grad.norm().item() ** 2
|
| 207 |
+
for p in m.parameters() if p.grad is not None]))
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/mar_members.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"members": [
|
| 3 |
+
{
|
| 4 |
+
"compress_size": 36834540,
|
| 5 |
+
"modified": "2023-07-07T04:15:38",
|
| 6 |
+
"path": "templates.jsonl",
|
| 7 |
+
"size": 178512888
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"compress_size": 441,
|
| 11 |
+
"modified": "2023-07-11T20:38:48",
|
| 12 |
+
"path": "misc.py",
|
| 13 |
+
"size": 1062
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"compress_size": 2113,
|
| 17 |
+
"modified": "2023-09-17T00:40:16",
|
| 18 |
+
"path": "utils.py",
|
| 19 |
+
"size": 6591
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"compress_size": 1249,
|
| 23 |
+
"modified": "2023-07-11T20:38:48",
|
| 24 |
+
"path": "models.py",
|
| 25 |
+
"size": 4027
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"compress_size": 181512384,
|
| 29 |
+
"modified": "2023-07-07T04:15:40",
|
| 30 |
+
"path": "model_latest.pt",
|
| 31 |
+
"size": 201031079
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"compress_size": 992,
|
| 35 |
+
"modified": "2023-09-16T23:59:50",
|
| 36 |
+
"path": "templ_rel_parser.py",
|
| 37 |
+
"size": 4119
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"compress_size": 2524,
|
| 41 |
+
"modified": "2023-09-17T00:44:00",
|
| 42 |
+
"path": "templ_rel_handler.py",
|
| 43 |
+
"size": 8685
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"compress_size": 140,
|
| 47 |
+
"modified": "2023-09-17T00:44:10",
|
| 48 |
+
"path": "MAR-INF/MANIFEST.json",
|
| 49 |
+
"size": 203
|
| 50 |
+
}
|
| 51 |
+
]
|
| 52 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/model_args.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dropout": 0.1,
|
| 3 |
+
"fp_size": 2048,
|
| 4 |
+
"gating_activation": "sigmoid",
|
| 5 |
+
"hidden_activation": "relu",
|
| 6 |
+
"hidden_sizes": [
|
| 7 |
+
300,
|
| 8 |
+
300,
|
| 9 |
+
300,
|
| 10 |
+
300,
|
| 11 |
+
300
|
| 12 |
+
],
|
| 13 |
+
"load_from": "",
|
| 14 |
+
"min_freq": 1,
|
| 15 |
+
"model_ckpt_new": "./tmp/legacy_v2/reaxys.pt",
|
| 16 |
+
"model_folder_old": "./tmp/legacy_v1/reaxys/1",
|
| 17 |
+
"n_params": 50256523,
|
| 18 |
+
"n_templates": 163723,
|
| 19 |
+
"num_cores": 4,
|
| 20 |
+
"radius": 2,
|
| 21 |
+
"skip_connection": "none",
|
| 22 |
+
"template_file_new": "./tmp/legacy_v2/retro.templates.reaxys.jsonl",
|
| 23 |
+
"template_file_old": "./tmp/legacy_v1/retro.templates.json.gz"
|
| 24 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/aux/safetensors_conversion.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format": "safetensors",
|
| 3 |
+
"num_tensors": 12,
|
| 4 |
+
"path": "model.safetensors",
|
| 5 |
+
"roundtrip_tensor_equal": true,
|
| 6 |
+
"runtime_assets": {
|
| 7 |
+
"model_args": "aux/model_args.json",
|
| 8 |
+
"templates": "aux/templates.jsonl"
|
| 9 |
+
},
|
| 10 |
+
"source_member": "model_latest.pt",
|
| 11 |
+
"status": "converted"
|
| 12 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/benchmarks/metadata.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 3 |
+
"built_at": "1970-01-01T00:00:00+00:00",
|
| 4 |
+
"checkpoint_id": "reaxys",
|
| 5 |
+
"dataset_id": "askcos_retro_template_relevance_reaxys_paroutes_reference_route_test",
|
| 6 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 7 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 8 |
+
"native_sources": [
|
| 9 |
+
{
|
| 10 |
+
"notes": [
|
| 11 |
+
"Public PaRoutes selected_reactions.csv source table used to reconstruct the one-step reference-route reaction subset."
|
| 12 |
+
],
|
| 13 |
+
"origin": "copied_from_local_public_record",
|
| 14 |
+
"relative_path": "benchmarks/native/selected_reactions.csv",
|
| 15 |
+
"source_url": "https://zenodo.org/records/7341155/files/selected_reactions.csv?download=1"
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"notes": [
|
| 19 |
+
"Public PaRoutes hash list identifying the reference-route reactions used here as a redistribution-safe ASKCOS compatibility benchmark."
|
| 20 |
+
],
|
| 21 |
+
"origin": "copied_from_local_public_record",
|
| 22 |
+
"relative_path": "benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 23 |
+
"source_url": "https://zenodo.org/records/7341155/files/ref_routes_reaction_hashes.txt?download=1"
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"notes": [
|
| 27 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 28 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 29 |
+
],
|
| 30 |
+
"num_examples": 56657,
|
| 31 |
+
"split": "test"
|
| 32 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/benchmarks/native/ref_routes_reaction_hashes.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
checkpoints/askcos_retro_template_relevance/reaxys/manifest.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auxiliary_files": [
|
| 3 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 4 |
+
"aux/mar_files/misc.py",
|
| 5 |
+
"aux/mar_files/models.py",
|
| 6 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 7 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 8 |
+
"aux/mar_files/utils.py",
|
| 9 |
+
"aux/mar_members.json",
|
| 10 |
+
"aux/model_args.json",
|
| 11 |
+
"aux/safetensors_conversion.json",
|
| 12 |
+
"aux/templates.jsonl",
|
| 13 |
+
"benchmarks/default_test.jsonl",
|
| 14 |
+
"benchmarks/metadata.json",
|
| 15 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 16 |
+
"benchmarks/native/selected_reactions.csv"
|
| 17 |
+
],
|
| 18 |
+
"benchmark_datasets": [
|
| 19 |
+
{
|
| 20 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 21 |
+
"dataset_id": "askcos_retro_template_relevance_reaxys_paroutes_reference_route_test",
|
| 22 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 23 |
+
"default": true,
|
| 24 |
+
"format": "jsonl",
|
| 25 |
+
"metadata_path": "benchmarks/metadata.json",
|
| 26 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 27 |
+
"native_source_paths": [
|
| 28 |
+
"benchmarks/native/selected_reactions.csv",
|
| 29 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt"
|
| 30 |
+
],
|
| 31 |
+
"notes": [
|
| 32 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 33 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 34 |
+
],
|
| 35 |
+
"num_examples": 56657,
|
| 36 |
+
"path": "benchmarks/default_test.jsonl",
|
| 37 |
+
"split": "test"
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"checkpoint_id": "reaxys",
|
| 41 |
+
"contained_artifact_bindings": [
|
| 42 |
+
{
|
| 43 |
+
"canonical_split_family": "askcos_reaxys_split_unspecified",
|
| 44 |
+
"dataset_ref": "askcos_reaxys_release",
|
| 45 |
+
"path": "modelos_ASKCOS/mars/reaxys.mar",
|
| 46 |
+
"stage": "released_torchserve_archive"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"conversion": {
|
| 50 |
+
"converted_at": "1970-01-01T00:00:00+00:00",
|
| 51 |
+
"notes": [
|
| 52 |
+
"The upstream ASKCOS TorchServe .mar was unpacked into native bundle assets.",
|
| 53 |
+
"Tensor weights are stored canonically as model.safetensors; non-tensor runtime assets are stored under aux/.",
|
| 54 |
+
"The original .mar archive is not required for wrapper inference."
|
| 55 |
+
],
|
| 56 |
+
"safetensors": {
|
| 57 |
+
"format": "safetensors",
|
| 58 |
+
"num_tensors": 12,
|
| 59 |
+
"path": "model.safetensors",
|
| 60 |
+
"roundtrip_tensor_equal": true,
|
| 61 |
+
"runtime_assets": {
|
| 62 |
+
"model_args": "aux/model_args.json",
|
| 63 |
+
"templates": "aux/templates.jsonl"
|
| 64 |
+
},
|
| 65 |
+
"source_member": "model_latest.pt",
|
| 66 |
+
"status": "converted"
|
| 67 |
+
},
|
| 68 |
+
"source_format": "torchserve_mar_embedded_checkpoint",
|
| 69 |
+
"status": "converted",
|
| 70 |
+
"tool_version": "initial"
|
| 71 |
+
},
|
| 72 |
+
"display_name": "reaxys",
|
| 73 |
+
"format_version": 1,
|
| 74 |
+
"generated_at": "1970-01-01T00:00:00+00:00",
|
| 75 |
+
"input_schema": {
|
| 76 |
+
"product_field": "smiles",
|
| 77 |
+
"request_format": {
|
| 78 |
+
"smiles": [
|
| 79 |
+
"product_smiles"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
"target_field": "reactants"
|
| 83 |
+
},
|
| 84 |
+
"license": "cc-by-nc-4.0",
|
| 85 |
+
"model_id": "askcos_retro_template_relevance",
|
| 86 |
+
"model_role": "backward",
|
| 87 |
+
"normalized_checkpoint_id": "reaxys",
|
| 88 |
+
"package_layout": {
|
| 89 |
+
"aux_dir": "aux",
|
| 90 |
+
"benchmarks_dir": "benchmarks",
|
| 91 |
+
"weights_path": "model.safetensors"
|
| 92 |
+
},
|
| 93 |
+
"source_registry_refs": [
|
| 94 |
+
{
|
| 95 |
+
"checkpoint_id": "reaxys",
|
| 96 |
+
"model_id": "askcos_retro_template_relevance"
|
| 97 |
+
}
|
| 98 |
+
],
|
| 99 |
+
"split_provenance": [
|
| 100 |
+
{
|
| 101 |
+
"canonical_split_family": "askcos_reaxys_split_unspecified",
|
| 102 |
+
"dataset_ref": "askcos_reaxys_release",
|
| 103 |
+
"split_names": [],
|
| 104 |
+
"stage": "released_torchserve_archive"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"canonical_split_family": "askcos_reaxys_split_unspecified",
|
| 108 |
+
"dataset_ref": "askcos_reaxys_release",
|
| 109 |
+
"path": "modelos_ASKCOS/mars/reaxys.mar",
|
| 110 |
+
"stage": "released_torchserve_archive"
|
| 111 |
+
}
|
| 112 |
+
],
|
| 113 |
+
"task_direction": "retrosynthesis",
|
| 114 |
+
"training_dataset_refs": [
|
| 115 |
+
"askcos_reaxys_release"
|
| 116 |
+
],
|
| 117 |
+
"training_stage_bindings": [
|
| 118 |
+
{
|
| 119 |
+
"canonical_split_family": "askcos_reaxys_split_unspecified",
|
| 120 |
+
"dataset_ref": "askcos_reaxys_release",
|
| 121 |
+
"split_names": [],
|
| 122 |
+
"stage": "released_torchserve_archive"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"canonical_split_family": "askcos_reaxys_split_unspecified",
|
| 126 |
+
"dataset_ref": "askcos_reaxys_release",
|
| 127 |
+
"path": "modelos_ASKCOS/mars/reaxys.mar",
|
| 128 |
+
"stage": "released_torchserve_archive"
|
| 129 |
+
}
|
| 130 |
+
],
|
| 131 |
+
"weights": {
|
| 132 |
+
"dtype_summary": "float tensors preserved from upstream checkpoint",
|
| 133 |
+
"framework": "safetensors",
|
| 134 |
+
"path": "model.safetensors",
|
| 135 |
+
"tensor_namespace": "askcos_template_relevance"
|
| 136 |
+
},
|
| 137 |
+
"wrapper_config": "wrapper_config.json",
|
| 138 |
+
"wrapper_family": "askcos_template_relevance"
|
| 139 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/provenance.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conversion_notes": [
|
| 3 |
+
"The ASKCOS TorchServe .mar source archive was unpacked; model.mar is not copied into the normalized package.",
|
| 4 |
+
"Embedded tensor weights were serialized to model.safetensors and verified by safetensors round-trip equality.",
|
| 5 |
+
"Required non-tensor runtime assets such as templates, vocabularies, model args, OpenNMT metadata, and Graph2SMILES source support files are copied under aux/.",
|
| 6 |
+
"Lightweight MAR metadata is retained under aux/ for provenance only."
|
| 7 |
+
],
|
| 8 |
+
"copied_sidecars": [
|
| 9 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 10 |
+
"aux/mar_files/misc.py",
|
| 11 |
+
"aux/mar_files/models.py",
|
| 12 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 13 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 14 |
+
"aux/mar_files/utils.py",
|
| 15 |
+
"aux/mar_members.json",
|
| 16 |
+
"aux/model_args.json",
|
| 17 |
+
"aux/safetensors_conversion.json",
|
| 18 |
+
"aux/templates.jsonl"
|
| 19 |
+
],
|
| 20 |
+
"inner_members": [
|
| 21 |
+
{
|
| 22 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 23 |
+
"member": "templates.jsonl",
|
| 24 |
+
"role": "template_library"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 28 |
+
"member": "misc.py",
|
| 29 |
+
"role": "archive_member"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 33 |
+
"member": "utils.py",
|
| 34 |
+
"role": "archive_member"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 38 |
+
"member": "models.py",
|
| 39 |
+
"role": "archive_member"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 43 |
+
"member": "model_latest.pt",
|
| 44 |
+
"role": "weights_source"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 48 |
+
"member": "templ_rel_parser.py",
|
| 49 |
+
"role": "archive_member"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 53 |
+
"member": "templ_rel_handler.py",
|
| 54 |
+
"role": "archive_member"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 58 |
+
"member": "MAR-INF/MANIFEST.json",
|
| 59 |
+
"role": "torchserve_manifest"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"normalized_checkpoint_id": "reaxys",
|
| 63 |
+
"source_artifacts": [
|
| 64 |
+
{
|
| 65 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 66 |
+
"kind": "local_repo_file",
|
| 67 |
+
"path": "datasets/modelos_ASKCOS/mars/reaxys.mar",
|
| 68 |
+
"role": "source_artifact",
|
| 69 |
+
"sha256": "fb05bb216df2c6483bccc738dbc0e5b17a9d6ce3c4f07f4ad8dcda7a0c7ac526",
|
| 70 |
+
"size": 218355241
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 74 |
+
"kind": "local_repo_file",
|
| 75 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 76 |
+
"role": "source_artifact",
|
| 77 |
+
"sha256": "e88d26f86ce79d2c7d8f05d1a59e3b1b88bde69c3afb95d065c932ff058092be",
|
| 78 |
+
"size": 2374
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 82 |
+
"kind": "local_repo_file",
|
| 83 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 84 |
+
"role": "source_artifact",
|
| 85 |
+
"sha256": "c2351dd12f68b0f372b23183cf470fa643f73274f66e34dfc0dacd1ce1a9843e",
|
| 86 |
+
"size": 1234
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys/wrapper_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture_class": "NeuralSym-style template relevance FFN",
|
| 3 |
+
"device_supported": [
|
| 4 |
+
"cpu",
|
| 5 |
+
"cuda"
|
| 6 |
+
],
|
| 7 |
+
"input_schema": {
|
| 8 |
+
"product_field": "smiles",
|
| 9 |
+
"request_format": {
|
| 10 |
+
"smiles": [
|
| 11 |
+
"product_smiles"
|
| 12 |
+
]
|
| 13 |
+
},
|
| 14 |
+
"target_field": "reactants"
|
| 15 |
+
},
|
| 16 |
+
"license": "cc-by-nc-4.0",
|
| 17 |
+
"loader": {
|
| 18 |
+
"kind": "askcos_template_relevance_safetensors",
|
| 19 |
+
"model_args": "aux/model_args.json",
|
| 20 |
+
"model_version": "1.0",
|
| 21 |
+
"served_model_name": "reaxys",
|
| 22 |
+
"source_handler": "templ_rel_handler.py",
|
| 23 |
+
"state_dict_format": "safetensors",
|
| 24 |
+
"templates": "aux/templates.jsonl"
|
| 25 |
+
},
|
| 26 |
+
"package_layout": {
|
| 27 |
+
"aux_dir": "aux",
|
| 28 |
+
"weights_path": "model.safetensors"
|
| 29 |
+
},
|
| 30 |
+
"runtime_file_map": {
|
| 31 |
+
"aux/model_args.json": "aux/model_args.json",
|
| 32 |
+
"aux/templates.jsonl": "aux/templates.jsonl",
|
| 33 |
+
"model.safetensors": "model.safetensors"
|
| 34 |
+
},
|
| 35 |
+
"task_direction": "retrosynthesis",
|
| 36 |
+
"wrapper_family": "askcos_template_relevance"
|
| 37 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/SHA256SUMS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
a57d7f443fc67f3d179de1979b1c6c7480a368fb13ee45d9f434e35ecf49154e aux/MAR-INF/MANIFEST.json
|
| 2 |
+
f5bef6f645347b15a1bbff2e56117d1a58f56234bdd24d89e9a18bd7a0d193d5 aux/mar_files/misc.py
|
| 3 |
+
8ee17cac57f65d954a599f18bbcf9df069a1acb0be86064a21188d4f5c2171f5 aux/mar_files/models.py
|
| 4 |
+
b5d99468d88374391e7ce7a1766ee287b8fbb9f1dbac70743606d43dee4f9f59 aux/mar_files/templ_rel_handler.py
|
| 5 |
+
9a0d07ded45cd94abeeed5e8c1f30a1e590080b10b4bbc8314aa5e4cbc622d83 aux/mar_files/templ_rel_parser.py
|
| 6 |
+
67bee61a87662e2224bb85725bdf8de048ff4ebcc934fc8ed1cdfd61186e4a4b aux/mar_files/utils.py
|
| 7 |
+
f6deb7cdcc1d08f99d823a490667d85333714f77426718e705d2b2e26fae7669 aux/mar_members.json
|
| 8 |
+
09beae83ec8d0eff16449792a0aa23fcf263997475ab0ceebb78ea638f6f799e aux/model_args.json
|
| 9 |
+
bc047b7afb7a1a3dbaf70225560fd396eee228f106ff12f615de80dea999f8b7 aux/safetensors_conversion.json
|
| 10 |
+
01525f0f1a35c06ba74e4120a2ca3f7487c218ebb1ee88b007166865dc54684b aux/templates.jsonl
|
| 11 |
+
a10255a6abd89a35d2ea48a842839f403b4b1586805c3010c0d076e0ae23754d benchmarks/default_test.jsonl
|
| 12 |
+
af366ff36fbc686bacc48c5e3bd341d47fe74f69fc39c721eed7eb88593b2252 benchmarks/metadata.json
|
| 13 |
+
87d7e0013f97da27e4fd878b0598466ac07202fe131ac0f7dbdd2b423482751f benchmarks/native/ref_routes_reaction_hashes.txt
|
| 14 |
+
872533b44788754af3aa19918a04c2a508d30249d2c93eb480078cb638ad3389 benchmarks/native/selected_reactions.csv
|
| 15 |
+
73ab2726a390d128459991eb538690957749562743d9bf1c974abd8939c4cee9 manifest.json
|
| 16 |
+
f27212055fd62b3c3edfa71f6d53a6ae7c2dc27212ac45dbe68b278d714c7ae8 model.safetensors
|
| 17 |
+
46f01b02bf2639b0c5b7c18637eb88c0a8afac23ea036665078fe43d02eacfd4 provenance.json
|
| 18 |
+
bb782bdc4f876a606d6933e45adcb76414a0e2ad847e3fc542a1f61d00d59dcd wrapper_config.json
|
checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/manifest.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auxiliary_files": [
|
| 3 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 4 |
+
"aux/mar_files/misc.py",
|
| 5 |
+
"aux/mar_files/models.py",
|
| 6 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 7 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 8 |
+
"aux/mar_files/utils.py",
|
| 9 |
+
"aux/mar_members.json",
|
| 10 |
+
"aux/model_args.json",
|
| 11 |
+
"aux/safetensors_conversion.json",
|
| 12 |
+
"aux/templates.jsonl",
|
| 13 |
+
"benchmarks/default_test.jsonl",
|
| 14 |
+
"benchmarks/metadata.json",
|
| 15 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 16 |
+
"benchmarks/native/selected_reactions.csv"
|
| 17 |
+
],
|
| 18 |
+
"benchmark_datasets": [
|
| 19 |
+
{
|
| 20 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 21 |
+
"dataset_id": "askcos_retro_template_relevance_reaxys_biocatalysis_paroutes_reference_route_test",
|
| 22 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 23 |
+
"default": true,
|
| 24 |
+
"format": "jsonl",
|
| 25 |
+
"metadata_path": "benchmarks/metadata.json",
|
| 26 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 27 |
+
"native_source_paths": [
|
| 28 |
+
"benchmarks/native/selected_reactions.csv",
|
| 29 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt"
|
| 30 |
+
],
|
| 31 |
+
"notes": [
|
| 32 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 33 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 34 |
+
],
|
| 35 |
+
"num_examples": 56657,
|
| 36 |
+
"path": "benchmarks/default_test.jsonl",
|
| 37 |
+
"split": "test"
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"checkpoint_id": "reaxys_biocatalysis",
|
| 41 |
+
"contained_artifact_bindings": [
|
| 42 |
+
{
|
| 43 |
+
"canonical_split_family": "askcos_reaxys_biocatalysis_split_unspecified",
|
| 44 |
+
"dataset_ref": "askcos_reaxys_biocatalysis_release",
|
| 45 |
+
"path": "modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 46 |
+
"stage": "released_torchserve_archive"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"conversion": {
|
| 50 |
+
"converted_at": "1970-01-01T00:00:00+00:00",
|
| 51 |
+
"notes": [
|
| 52 |
+
"The upstream ASKCOS TorchServe .mar was unpacked into native bundle assets.",
|
| 53 |
+
"Tensor weights are stored canonically as model.safetensors; non-tensor runtime assets are stored under aux/.",
|
| 54 |
+
"The original .mar archive is not required for wrapper inference."
|
| 55 |
+
],
|
| 56 |
+
"safetensors": {
|
| 57 |
+
"format": "safetensors",
|
| 58 |
+
"num_tensors": 4,
|
| 59 |
+
"path": "model.safetensors",
|
| 60 |
+
"roundtrip_tensor_equal": true,
|
| 61 |
+
"runtime_assets": {
|
| 62 |
+
"model_args": "aux/model_args.json",
|
| 63 |
+
"templates": "aux/templates.jsonl"
|
| 64 |
+
},
|
| 65 |
+
"source_member": "model_latest.pt",
|
| 66 |
+
"status": "converted"
|
| 67 |
+
},
|
| 68 |
+
"source_format": "torchserve_mar_embedded_checkpoint",
|
| 69 |
+
"status": "converted",
|
| 70 |
+
"tool_version": "initial"
|
| 71 |
+
},
|
| 72 |
+
"display_name": "reaxys_biocatalysis",
|
| 73 |
+
"format_version": 1,
|
| 74 |
+
"generated_at": "1970-01-01T00:00:00+00:00",
|
| 75 |
+
"input_schema": {
|
| 76 |
+
"product_field": "smiles",
|
| 77 |
+
"request_format": {
|
| 78 |
+
"smiles": [
|
| 79 |
+
"product_smiles"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
"target_field": "reactants"
|
| 83 |
+
},
|
| 84 |
+
"license": "cc-by-nc-4.0",
|
| 85 |
+
"model_id": "askcos_retro_template_relevance",
|
| 86 |
+
"model_role": "backward",
|
| 87 |
+
"normalized_checkpoint_id": "reaxys_biocatalysis",
|
| 88 |
+
"package_layout": {
|
| 89 |
+
"aux_dir": "aux",
|
| 90 |
+
"benchmarks_dir": "benchmarks",
|
| 91 |
+
"weights_path": "model.safetensors"
|
| 92 |
+
},
|
| 93 |
+
"source_registry_refs": [
|
| 94 |
+
{
|
| 95 |
+
"checkpoint_id": "reaxys_biocatalysis",
|
| 96 |
+
"model_id": "askcos_retro_template_relevance"
|
| 97 |
+
}
|
| 98 |
+
],
|
| 99 |
+
"split_provenance": [
|
| 100 |
+
{
|
| 101 |
+
"canonical_split_family": "askcos_reaxys_biocatalysis_split_unspecified",
|
| 102 |
+
"dataset_ref": "askcos_reaxys_biocatalysis_release",
|
| 103 |
+
"split_names": [],
|
| 104 |
+
"stage": "released_torchserve_archive"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"canonical_split_family": "askcos_reaxys_biocatalysis_split_unspecified",
|
| 108 |
+
"dataset_ref": "askcos_reaxys_biocatalysis_release",
|
| 109 |
+
"path": "modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 110 |
+
"stage": "released_torchserve_archive"
|
| 111 |
+
}
|
| 112 |
+
],
|
| 113 |
+
"task_direction": "retrosynthesis",
|
| 114 |
+
"training_dataset_refs": [
|
| 115 |
+
"askcos_reaxys_biocatalysis_release"
|
| 116 |
+
],
|
| 117 |
+
"training_stage_bindings": [
|
| 118 |
+
{
|
| 119 |
+
"canonical_split_family": "askcos_reaxys_biocatalysis_split_unspecified",
|
| 120 |
+
"dataset_ref": "askcos_reaxys_biocatalysis_release",
|
| 121 |
+
"split_names": [],
|
| 122 |
+
"stage": "released_torchserve_archive"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"canonical_split_family": "askcos_reaxys_biocatalysis_split_unspecified",
|
| 126 |
+
"dataset_ref": "askcos_reaxys_biocatalysis_release",
|
| 127 |
+
"path": "modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 128 |
+
"stage": "released_torchserve_archive"
|
| 129 |
+
}
|
| 130 |
+
],
|
| 131 |
+
"weights": {
|
| 132 |
+
"dtype_summary": "float tensors preserved from upstream checkpoint",
|
| 133 |
+
"framework": "safetensors",
|
| 134 |
+
"path": "model.safetensors",
|
| 135 |
+
"tensor_namespace": "askcos_template_relevance"
|
| 136 |
+
},
|
| 137 |
+
"wrapper_config": "wrapper_config.json",
|
| 138 |
+
"wrapper_family": "askcos_template_relevance"
|
| 139 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/provenance.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conversion_notes": [
|
| 3 |
+
"The ASKCOS TorchServe .mar source archive was unpacked; model.mar is not copied into the normalized package.",
|
| 4 |
+
"Embedded tensor weights were serialized to model.safetensors and verified by safetensors round-trip equality.",
|
| 5 |
+
"Required non-tensor runtime assets such as templates, vocabularies, model args, OpenNMT metadata, and Graph2SMILES source support files are copied under aux/.",
|
| 6 |
+
"Lightweight MAR metadata is retained under aux/ for provenance only."
|
| 7 |
+
],
|
| 8 |
+
"copied_sidecars": [
|
| 9 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 10 |
+
"aux/mar_files/misc.py",
|
| 11 |
+
"aux/mar_files/models.py",
|
| 12 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 13 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 14 |
+
"aux/mar_files/utils.py",
|
| 15 |
+
"aux/mar_members.json",
|
| 16 |
+
"aux/model_args.json",
|
| 17 |
+
"aux/safetensors_conversion.json",
|
| 18 |
+
"aux/templates.jsonl"
|
| 19 |
+
],
|
| 20 |
+
"inner_members": [
|
| 21 |
+
{
|
| 22 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 23 |
+
"member": "templates.jsonl",
|
| 24 |
+
"role": "template_library"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 28 |
+
"member": "misc.py",
|
| 29 |
+
"role": "archive_member"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 33 |
+
"member": "utils.py",
|
| 34 |
+
"role": "archive_member"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 38 |
+
"member": "models.py",
|
| 39 |
+
"role": "archive_member"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 43 |
+
"member": "model_latest.pt",
|
| 44 |
+
"role": "weights_source"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 48 |
+
"member": "templ_rel_parser.py",
|
| 49 |
+
"role": "archive_member"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 53 |
+
"member": "templ_rel_handler.py",
|
| 54 |
+
"role": "archive_member"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 58 |
+
"member": "MAR-INF/MANIFEST.json",
|
| 59 |
+
"role": "torchserve_manifest"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"normalized_checkpoint_id": "reaxys_biocatalysis",
|
| 63 |
+
"source_artifacts": [
|
| 64 |
+
{
|
| 65 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 66 |
+
"kind": "local_repo_file",
|
| 67 |
+
"path": "datasets/modelos_ASKCOS/mars/reaxys_biocatalysis.mar",
|
| 68 |
+
"role": "source_artifact",
|
| 69 |
+
"sha256": "dec101adf3eef9de7bc173278f4e3aefe4c54fd9e045398fb80985145e7d994c",
|
| 70 |
+
"size": 165468559
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 74 |
+
"kind": "local_repo_file",
|
| 75 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 76 |
+
"role": "source_artifact",
|
| 77 |
+
"sha256": "e88d26f86ce79d2c7d8f05d1a59e3b1b88bde69c3afb95d065c932ff058092be",
|
| 78 |
+
"size": 2374
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 82 |
+
"kind": "local_repo_file",
|
| 83 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 84 |
+
"role": "source_artifact",
|
| 85 |
+
"sha256": "c2351dd12f68b0f372b23183cf470fa643f73274f66e34dfc0dacd1ce1a9843e",
|
| 86 |
+
"size": 1234
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
checkpoints/askcos_retro_template_relevance/reaxys_biocatalysis/wrapper_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture_class": "NeuralSym-style template relevance FFN",
|
| 3 |
+
"device_supported": [
|
| 4 |
+
"cpu",
|
| 5 |
+
"cuda"
|
| 6 |
+
],
|
| 7 |
+
"input_schema": {
|
| 8 |
+
"product_field": "smiles",
|
| 9 |
+
"request_format": {
|
| 10 |
+
"smiles": [
|
| 11 |
+
"product_smiles"
|
| 12 |
+
]
|
| 13 |
+
},
|
| 14 |
+
"target_field": "reactants"
|
| 15 |
+
},
|
| 16 |
+
"license": "cc-by-nc-4.0",
|
| 17 |
+
"loader": {
|
| 18 |
+
"kind": "askcos_template_relevance_safetensors",
|
| 19 |
+
"model_args": "aux/model_args.json",
|
| 20 |
+
"model_version": "1.0",
|
| 21 |
+
"served_model_name": "reaxys_biocatalysis",
|
| 22 |
+
"source_handler": "templ_rel_handler.py",
|
| 23 |
+
"state_dict_format": "safetensors",
|
| 24 |
+
"templates": "aux/templates.jsonl"
|
| 25 |
+
},
|
| 26 |
+
"package_layout": {
|
| 27 |
+
"aux_dir": "aux",
|
| 28 |
+
"weights_path": "model.safetensors"
|
| 29 |
+
},
|
| 30 |
+
"runtime_file_map": {
|
| 31 |
+
"aux/model_args.json": "aux/model_args.json",
|
| 32 |
+
"aux/templates.jsonl": "aux/templates.jsonl",
|
| 33 |
+
"model.safetensors": "model.safetensors"
|
| 34 |
+
},
|
| 35 |
+
"task_direction": "retrosynthesis",
|
| 36 |
+
"wrapper_family": "askcos_template_relevance"
|
| 37 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/SHA256SUMS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
b7b2ca228a157b9b4df6e70c971e3f7336860544f2ff23c7e40556e86966cd2e aux/MAR-INF/MANIFEST.json
|
| 2 |
+
f5bef6f645347b15a1bbff2e56117d1a58f56234bdd24d89e9a18bd7a0d193d5 aux/mar_files/misc.py
|
| 3 |
+
8ee17cac57f65d954a599f18bbcf9df069a1acb0be86064a21188d4f5c2171f5 aux/mar_files/models.py
|
| 4 |
+
b5d99468d88374391e7ce7a1766ee287b8fbb9f1dbac70743606d43dee4f9f59 aux/mar_files/templ_rel_handler.py
|
| 5 |
+
52cf84f9aa1f02337d3d5bfad049ce09fd150111b5917aa7d896afe223dee883 aux/mar_files/templ_rel_parser.py
|
| 6 |
+
7033f7390bc992b54a060ccf992d8da538fed53d7f30fc6a6d6165af73566ad1 aux/mar_files/utils.py
|
| 7 |
+
6256064b2b61eab625a625793face8fa47b3226a5e29959a0733ad151c2926cd aux/mar_members.json
|
| 8 |
+
67227a4e1d20c16fde3841a279deff3b7f5f2fcfcb0263252075ffa6a84b2ef7 aux/model_args.json
|
| 9 |
+
bc047b7afb7a1a3dbaf70225560fd396eee228f106ff12f615de80dea999f8b7 aux/safetensors_conversion.json
|
| 10 |
+
3b8ca4a6d7b5157f61c4dc0d922dae64c589ef2555e472b5f1c2669b46e9306b aux/templates.jsonl
|
| 11 |
+
a10255a6abd89a35d2ea48a842839f403b4b1586805c3010c0d076e0ae23754d benchmarks/default_test.jsonl
|
| 12 |
+
f4395261a25edfd67ae73c77f77aaa42a614c99114959973d98332fc51fc22db benchmarks/metadata.json
|
| 13 |
+
87d7e0013f97da27e4fd878b0598466ac07202fe131ac0f7dbdd2b423482751f benchmarks/native/ref_routes_reaction_hashes.txt
|
| 14 |
+
872533b44788754af3aa19918a04c2a508d30249d2c93eb480078cb638ad3389 benchmarks/native/selected_reactions.csv
|
| 15 |
+
1a7cc2e955245c897cc240d3cca74bd45da2242cc52c3897df57e9b7091292cf manifest.json
|
| 16 |
+
dcefcc766f005ec0a1b3cf06941069b29b415b09ea23fd614c4a96485fd489c5 model.safetensors
|
| 17 |
+
2c245c1023c2965739b73eff6fcc1b401081ea0f6c2691595b58ad6f622e9385 provenance.json
|
| 18 |
+
8e0f10e122856e7fa87c182a0e1e167cf9f07e43428ecebc01c9d85f9e173219 wrapper_config.json
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/MAR-INF/MANIFEST.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"archiverVersion": "0.3.1",
|
| 3 |
+
"createdOn": "17/04/2026 19:55:38",
|
| 4 |
+
"model": {
|
| 5 |
+
"handler": "templ_rel_handler.py",
|
| 6 |
+
"modelName": "uspto_higher_level",
|
| 7 |
+
"modelVersion": "1.0"
|
| 8 |
+
},
|
| 9 |
+
"runtime": "python"
|
| 10 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/misc.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class BlockPrint:
|
| 8 |
+
"""Context manager to suppress printing from subprocesses"""
|
| 9 |
+
def __enter__(self):
|
| 10 |
+
self._original_stdout = sys.stdout
|
| 11 |
+
sys.stdout = open(os.devnull, 'w')
|
| 12 |
+
|
| 13 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
| 14 |
+
sys.stdout.close()
|
| 15 |
+
sys.stdout = self._original_stdout
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def log_args(args, message: str):
|
| 19 |
+
log_rank_0(message)
|
| 20 |
+
for k, v in vars(args).items():
|
| 21 |
+
log_rank_0(f"**** {k} = *{v}*")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def log_rank_0(message):
|
| 25 |
+
if torch.distributed.is_initialized():
|
| 26 |
+
if torch.distributed.get_rank() == 0:
|
| 27 |
+
logging.info(message)
|
| 28 |
+
sys.stdout.flush()
|
| 29 |
+
else:
|
| 30 |
+
logging.info(message)
|
| 31 |
+
sys.stdout.flush()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def setup_logger(log_file):
|
| 35 |
+
logger = logging.getLogger()
|
| 36 |
+
logger.setLevel(logging.INFO)
|
| 37 |
+
|
| 38 |
+
fh = logging.FileHandler(log_file)
|
| 39 |
+
sh = logging.StreamHandler(sys.stdout)
|
| 40 |
+
fh.setLevel(logging.INFO)
|
| 41 |
+
sh.setLevel(logging.INFO)
|
| 42 |
+
logger.addHandler(fh)
|
| 43 |
+
logger.addHandler(sh)
|
| 44 |
+
|
| 45 |
+
return logger
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/models.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
from typing import Tuple
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_activation(name: str) -> nn.Module:
|
| 7 |
+
_activations = {
|
| 8 |
+
"relu": nn.ReLU(),
|
| 9 |
+
"elu": nn.ELU(),
|
| 10 |
+
"gelu": nn.GELU(),
|
| 11 |
+
"leakyrelu": nn.LeakyReLU(),
|
| 12 |
+
"sigmoid": nn.Sigmoid(),
|
| 13 |
+
"tanh": nn.Tanh()
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
return _activations[name]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class Dense(nn.Module):
|
| 20 |
+
def __init__(self, in_features: int, out_features: int,
|
| 21 |
+
hidden_act: nn.Module):
|
| 22 |
+
super().__init__()
|
| 23 |
+
self.linear = nn.Linear(in_features, out_features, bias=True)
|
| 24 |
+
self.hidden_act = hidden_act
|
| 25 |
+
|
| 26 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 27 |
+
return self.hidden_act(self.linear(x))
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Highway(nn.Module):
|
| 31 |
+
def __init__(self, in_features: int, out_features: int,
|
| 32 |
+
hidden_act: nn.Module, gating_act: nn.Module):
|
| 33 |
+
super().__init__()
|
| 34 |
+
self.dense = nn.Linear(in_features, out_features, bias=True)
|
| 35 |
+
self.gate = nn.Linear(in_features, out_features, bias=True)
|
| 36 |
+
self.hidden_act = hidden_act
|
| 37 |
+
self.gating_act = gating_act
|
| 38 |
+
|
| 39 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 40 |
+
transform = self.hidden_act(self.dense(x))
|
| 41 |
+
transform_gate = self.gating_act(self.gate(x))
|
| 42 |
+
carry_gate = 1 - transform_gate
|
| 43 |
+
output = transform * transform_gate + x * carry_gate
|
| 44 |
+
|
| 45 |
+
return output
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class TemplRel(nn.Module):
|
| 49 |
+
def __init__(self, args):
|
| 50 |
+
super().__init__()
|
| 51 |
+
|
| 52 |
+
if isinstance(args.hidden_sizes, str):
|
| 53 |
+
args.hidden_sizes = [int(size) for size in args.hidden_sizes.split(",")]
|
| 54 |
+
|
| 55 |
+
self.args = args
|
| 56 |
+
self.layers = self._build_layers(args)
|
| 57 |
+
self.output_layer = nn.Linear(
|
| 58 |
+
args.hidden_sizes[-1], args.n_templates, bias=True)
|
| 59 |
+
|
| 60 |
+
# we will do all the dropout here in TemplRel, for backward compatibility
|
| 61 |
+
self.dropout = nn.Dropout(args.dropout)
|
| 62 |
+
self.criterion = nn.CrossEntropyLoss(ignore_index=-1, reduction="mean")
|
| 63 |
+
|
| 64 |
+
@staticmethod
|
| 65 |
+
def _build_layers(args) -> nn.ModuleList:
|
| 66 |
+
hidden_act = get_activation(args.hidden_activation)
|
| 67 |
+
# input projection layer; no skip connection here
|
| 68 |
+
layers = nn.ModuleList([
|
| 69 |
+
Dense(args.fp_size, args.hidden_sizes[0], hidden_act=hidden_act)
|
| 70 |
+
])
|
| 71 |
+
|
| 72 |
+
for layer_i in range(len(args.hidden_sizes) - 1):
|
| 73 |
+
in_features = args.hidden_sizes[layer_i]
|
| 74 |
+
out_features = args.hidden_sizes[layer_i + 1]
|
| 75 |
+
|
| 76 |
+
if args.skip_connection == "none":
|
| 77 |
+
layer = Dense(in_features, out_features, hidden_act=hidden_act)
|
| 78 |
+
elif args.skip_connection == "highway":
|
| 79 |
+
layer = Highway(
|
| 80 |
+
in_features,
|
| 81 |
+
out_features,
|
| 82 |
+
hidden_act=hidden_act,
|
| 83 |
+
gating_act=get_activation(args.gating_activation)
|
| 84 |
+
)
|
| 85 |
+
else:
|
| 86 |
+
raise ValueError(
|
| 87 |
+
f"Unsupported skip_connection: {args.skip_connection}"
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
layers.append(layer)
|
| 91 |
+
|
| 92 |
+
return layers
|
| 93 |
+
|
| 94 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 95 |
+
for layer in self.layers:
|
| 96 |
+
x = layer(x)
|
| 97 |
+
x = self.dropout(x)
|
| 98 |
+
|
| 99 |
+
logits = self.output_layer(x) # returning *unnormalized* logits
|
| 100 |
+
|
| 101 |
+
return logits
|
| 102 |
+
|
| 103 |
+
def get_loss(self, logits: torch.Tensor, target: torch.Tensor
|
| 104 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 105 |
+
loss = self.criterion(input=logits, target=target)
|
| 106 |
+
|
| 107 |
+
predictions = torch.argmax(logits, dim=1)
|
| 108 |
+
accs = (predictions == target).float()
|
| 109 |
+
acc = accs.mean()
|
| 110 |
+
|
| 111 |
+
# Data points with label -1 (no/failed templates) should really be treated as
|
| 112 |
+
# if they are predicted wrong. Therefore, we turned off the masking. This may
|
| 113 |
+
# noticeably decrease the computed accuracy, but would reflect the reality.
|
| 114 |
+
|
| 115 |
+
# mask = (target != -1).long()
|
| 116 |
+
# accs = accs * mask
|
| 117 |
+
# acc = accs.sum() / mask.sum()
|
| 118 |
+
|
| 119 |
+
return loss, acc
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/templ_rel_handler.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import glob
|
| 3 |
+
import numpy as np
|
| 4 |
+
import os
|
| 5 |
+
import templ_rel_parser
|
| 6 |
+
import torch
|
| 7 |
+
import torch.nn.functional as F
|
| 8 |
+
from utils import canonicalize_smiles
|
| 9 |
+
from rdchiral.initialization import rdchiralReactants, rdchiralReaction
|
| 10 |
+
from rdchiral.main import rdchiralRun
|
| 11 |
+
from typing import Any, Dict, List, Tuple
|
| 12 |
+
from utils import get_model, load_templates_as_list, mol_smi_to_count_fp
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class TemplRelHandler:
|
| 16 |
+
"""TemplRel Handler for use with torchserve"""
|
| 17 |
+
|
| 18 |
+
def __init__(self):
|
| 19 |
+
self._context = None
|
| 20 |
+
self.manifest = None
|
| 21 |
+
self.initialized = False
|
| 22 |
+
|
| 23 |
+
self.args = None
|
| 24 |
+
self.templates = None
|
| 25 |
+
self.template_attributes = None
|
| 26 |
+
self.model = None
|
| 27 |
+
self.indices = None
|
| 28 |
+
self.device = None
|
| 29 |
+
|
| 30 |
+
def initialize(self, context):
|
| 31 |
+
self._context = context
|
| 32 |
+
self.manifest = context.manifest
|
| 33 |
+
|
| 34 |
+
properties = context.system_properties
|
| 35 |
+
model_dir = properties.get("model_dir")
|
| 36 |
+
print(glob.glob(f"{model_dir}/*"))
|
| 37 |
+
self.device = torch.device("cuda:" + str(properties.get("gpu_id"))
|
| 38 |
+
if torch.cuda.is_available() else "cpu")
|
| 39 |
+
|
| 40 |
+
serve_parser = argparse.ArgumentParser("serve")
|
| 41 |
+
templ_rel_parser.add_predict_opts(serve_parser)
|
| 42 |
+
self.args, _ = serve_parser.parse_known_args()
|
| 43 |
+
|
| 44 |
+
template_file = os.path.join(model_dir, "templates.jsonl")
|
| 45 |
+
print(f"Loading templates and attributes from {template_file}")
|
| 46 |
+
self.templates, self.template_attributes = \
|
| 47 |
+
load_templates_as_list(template_file=template_file)
|
| 48 |
+
print(f'Total number of templates: {len(self.templates)}')
|
| 49 |
+
|
| 50 |
+
checkpoint_file = os.path.join(model_dir, "model_latest.pt")
|
| 51 |
+
print(f"Building model and loading from {checkpoint_file}")
|
| 52 |
+
|
| 53 |
+
self.args.load_from = checkpoint_file
|
| 54 |
+
self.args.local_rank = -1
|
| 55 |
+
# Note: the model will be built using pretraining args
|
| 56 |
+
self.model, _ = get_model(self.args, device=self.device)
|
| 57 |
+
self.model.eval()
|
| 58 |
+
|
| 59 |
+
self.initialized = True
|
| 60 |
+
|
| 61 |
+
def preprocess(self, data: List[dict]
|
| 62 |
+
) -> Tuple[List[str], int, float, List[Dict[str, Any]]]:
|
| 63 |
+
print(f"input: {data}")
|
| 64 |
+
canonical_smiles = [canonicalize_smiles(smi)
|
| 65 |
+
for smi in data[0]["body"]["smiles"]]
|
| 66 |
+
max_num_templates = data[0]["body"].get("max_num_templates", 1000)
|
| 67 |
+
max_cum_prob = data[0]["body"].get("max_cum_prob", 0.999)
|
| 68 |
+
attribute_filter = data[0]["body"].get("attribute_filter", [])
|
| 69 |
+
|
| 70 |
+
return canonical_smiles, max_num_templates, max_cum_prob, attribute_filter
|
| 71 |
+
|
| 72 |
+
def inference(self, inputs: Tuple[List[str], int, float, List[Dict[str, Any]]]
|
| 73 |
+
) -> List[Dict[str, Any]]:
|
| 74 |
+
canonical_smiles, max_num_templates, max_cum_prob, attribute_filter = inputs
|
| 75 |
+
filters = [x for x in attribute_filter
|
| 76 |
+
if x.get("name") in self.template_attributes]
|
| 77 |
+
|
| 78 |
+
if filters:
|
| 79 |
+
filter_query = " and ".join(
|
| 80 |
+
[f"({q['name']} {q['logic']} {q['value']})" for q in filters]
|
| 81 |
+
)
|
| 82 |
+
filtered_indices = self.template_attributes.query(filter_query).index.values
|
| 83 |
+
|
| 84 |
+
results = []
|
| 85 |
+
|
| 86 |
+
# maybe not the most efficient way, but should have been faster than v1 already
|
| 87 |
+
with torch.no_grad():
|
| 88 |
+
for smi in canonical_smiles:
|
| 89 |
+
prod_fp = mol_smi_to_count_fp(smi, self.args.radius, self.args.fp_size)
|
| 90 |
+
final_fp = torch.as_tensor(prod_fp.toarray()).float().to(self.device)
|
| 91 |
+
|
| 92 |
+
# template_prioritizer.predict()
|
| 93 |
+
logits = self.model(final_fp)
|
| 94 |
+
scores = F.softmax(logits, dim=1)
|
| 95 |
+
scores = scores.squeeze(dim=0).cpu().numpy()
|
| 96 |
+
indices = np.argsort(-scores)
|
| 97 |
+
scores = scores[indices]
|
| 98 |
+
|
| 99 |
+
# retro_transformer.filter_by_attributes()
|
| 100 |
+
if filters:
|
| 101 |
+
bool_mask = np.isin(indices, filtered_indices)
|
| 102 |
+
indices = indices[bool_mask]
|
| 103 |
+
scores = scores[bool_mask]
|
| 104 |
+
|
| 105 |
+
# template_prioritizer.truncate()
|
| 106 |
+
if max_num_templates:
|
| 107 |
+
indices = indices[:max_num_templates]
|
| 108 |
+
scores = scores[:max_num_templates]
|
| 109 |
+
|
| 110 |
+
if max_cum_prob:
|
| 111 |
+
exceeds = np.nonzero(np.cumsum(scores) >= max_cum_prob)[0]
|
| 112 |
+
if exceeds.size:
|
| 113 |
+
# Include the prediction which exceeds max_cum_prob
|
| 114 |
+
max_index = exceeds[0] + 1
|
| 115 |
+
scores = scores[:max_index]
|
| 116 |
+
indices = indices[:max_index]
|
| 117 |
+
|
| 118 |
+
smiles_to_index = {}
|
| 119 |
+
result = {
|
| 120 |
+
"templates": [],
|
| 121 |
+
"reactants": [],
|
| 122 |
+
"scores": []
|
| 123 |
+
}
|
| 124 |
+
for rank, (score, idx) in enumerate(zip(scores, indices), start=1):
|
| 125 |
+
template = self.templates[idx]
|
| 126 |
+
# IMPORTANT MAGIC from v1. DO NOT TOUCH
|
| 127 |
+
# Force reactants and products to be one pseudo-molecule (bookkeeping)
|
| 128 |
+
reaction_smarts = template["reaction_smarts"]
|
| 129 |
+
reaction_smarts_one = "(" + reaction_smarts.replace(">>", ")>>(") + ")"
|
| 130 |
+
rxn = rdchiralReaction(str(reaction_smarts_one))
|
| 131 |
+
prod = rdchiralReactants(smi)
|
| 132 |
+
try:
|
| 133 |
+
# New: set return_mapped to False. Remap after in expand_one
|
| 134 |
+
reactants = rdchiralRun(rxn, prod, return_mapped=False)
|
| 135 |
+
except:
|
| 136 |
+
continue # unknown error in rdchiral
|
| 137 |
+
|
| 138 |
+
if not reactants: # empty precursors
|
| 139 |
+
continue
|
| 140 |
+
|
| 141 |
+
template = {k: v for k, v in template.items()
|
| 142 |
+
if k not in ["references", "rxn"]}
|
| 143 |
+
template["template_score"] = score.item()
|
| 144 |
+
template["template_rank"] = rank
|
| 145 |
+
|
| 146 |
+
for reactant in reactants:
|
| 147 |
+
# here we just return the full template with metadata
|
| 148 |
+
# in theory it should also be fetchable from the DB
|
| 149 |
+
smiles_list = reactant.split(".")
|
| 150 |
+
if template["intra_only"] and len(smiles_list) > 1:
|
| 151 |
+
# Disallowed intermolecular reaction
|
| 152 |
+
continue
|
| 153 |
+
if template["dimer_only"] and (
|
| 154 |
+
len(set(smiles_list)) != 1 or len(smiles_list) != 2
|
| 155 |
+
):
|
| 156 |
+
# Not a dimer
|
| 157 |
+
continue
|
| 158 |
+
if smi in smiles_list:
|
| 159 |
+
# Skip if no transformation happened
|
| 160 |
+
continue
|
| 161 |
+
|
| 162 |
+
joined_smiles = ".".join(sorted(smiles_list))
|
| 163 |
+
if joined_smiles in smiles_to_index:
|
| 164 |
+
# Precursor was already generated by another template
|
| 165 |
+
# -> update metadata. Templates are ordered by score, so
|
| 166 |
+
# no need to update template score or rank
|
| 167 |
+
res = result["templates"][
|
| 168 |
+
smiles_to_index[joined_smiles]
|
| 169 |
+
]
|
| 170 |
+
if template["_id"] not in res["tforms"]:
|
| 171 |
+
res["tforms"].append(template["_id"])
|
| 172 |
+
res["num_examples"] += template["count"]
|
| 173 |
+
else:
|
| 174 |
+
# New precursor -> generate metadata
|
| 175 |
+
template["tforms"] = [template["_id"]]
|
| 176 |
+
template["num_examples"] = template["count"]
|
| 177 |
+
smiles_to_index[joined_smiles] = len(result["templates"])
|
| 178 |
+
|
| 179 |
+
result["templates"].append(template)
|
| 180 |
+
result["reactants"].append(reactant)
|
| 181 |
+
result["scores"].append(score.item())
|
| 182 |
+
|
| 183 |
+
del rxn, prod, reactants
|
| 184 |
+
|
| 185 |
+
results.append(result)
|
| 186 |
+
|
| 187 |
+
return results
|
| 188 |
+
|
| 189 |
+
def postprocess(self, data: List[Dict[str, Any]]) -> List[List[Dict[str, Any]]]:
|
| 190 |
+
return [data]
|
| 191 |
+
|
| 192 |
+
def handle(self, data: List, context) -> List[List[Dict[str, Any]]]:
|
| 193 |
+
self._context = context
|
| 194 |
+
|
| 195 |
+
inputs = self.preprocess(data)
|
| 196 |
+
output = self.inference(inputs)
|
| 197 |
+
output = self.postprocess(output)
|
| 198 |
+
|
| 199 |
+
# print(output) # turn off (debug) printing to speed up
|
| 200 |
+
|
| 201 |
+
return output
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/templ_rel_parser.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def add_model_opts(parser):
|
| 2 |
+
"""Model options"""
|
| 3 |
+
group = parser.add_argument_group("template_relevance")
|
| 4 |
+
group.add_argument("--data_name", help="Data name", type=str, default="Template Relevance")
|
| 5 |
+
group.add_argument("--model_name", help="Model name", type=str, default="Template Relevance")
|
| 6 |
+
group.add_argument("--seed", help="random seed", type=int, default=0)
|
| 7 |
+
group.add_argument("--load_from", help="Trained checkpoint to load from",
|
| 8 |
+
type=str, default="")
|
| 9 |
+
group.add_argument("--log_file", help="Log file name",
|
| 10 |
+
type=str, default="default")
|
| 11 |
+
group.add_argument("--model_path", help="Checkpoint folder",
|
| 12 |
+
type=str, default="./checkpoints")
|
| 13 |
+
group.add_argument('--local_rank', help='Local process rank',
|
| 14 |
+
type=int, default=-1, metavar='N')
|
| 15 |
+
group.add_argument("--num_cores", help="number of cpu cores to use",
|
| 16 |
+
type=int, default=4)
|
| 17 |
+
group.add_argument("--min_freq", help="minimum frequency of template in training "
|
| 18 |
+
"data to be retained",
|
| 19 |
+
type=int, default=1)
|
| 20 |
+
group.add_argument("--n_templates", help="number of training templates",
|
| 21 |
+
type=int, default=4)
|
| 22 |
+
group.add_argument("--radius", help="fingerprint radius", type=int, default=2)
|
| 23 |
+
group.add_argument("--fp_size", help="fingerprint size", type=int, default=2048)
|
| 24 |
+
group.add_argument("--hidden_sizes",
|
| 25 |
+
help="hidden sizes, as a single comma-separated string",
|
| 26 |
+
type=str, default="1024")
|
| 27 |
+
group.add_argument("--hidden_activation", help="hidden activation",
|
| 28 |
+
type=str, default="relu")
|
| 29 |
+
group.add_argument("--skip_connection", help="type of skip connection "
|
| 30 |
+
"(for backward compatibility)",
|
| 31 |
+
type=str, choices=["none", "highway"], default="none")
|
| 32 |
+
group.add_argument("--gating_activation", help="activation for highway gating",
|
| 33 |
+
type=str, default="sigmoid")
|
| 34 |
+
group.add_argument("--dropout", help="hidden dropout", type=float, default=0.1)
|
| 35 |
+
|
| 36 |
+
group = parser.add_argument_group("Paths")
|
| 37 |
+
group.add_argument("--processed_data_path", help="Path for saving preprocessed outputs",
|
| 38 |
+
type=str, default="")
|
| 39 |
+
group.add_argument("--test_output_path", help="Path for saving test outputs", type=str, default="")
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def add_preprocess_opts(parser):
|
| 43 |
+
group = parser.add_argument_group("Preprocessing options")
|
| 44 |
+
# data paths
|
| 45 |
+
group.add_argument("--all_reaction_file", help="All reaction file", type=str, default="")
|
| 46 |
+
group.add_argument("--split_ratio", help="Split ratio of dataset", type=str, default="8:1:1")
|
| 47 |
+
|
| 48 |
+
group.add_argument("--train_file", help="Train file", type=str, default="")
|
| 49 |
+
group.add_argument("--val_file", help="Validation file", type=str, default="")
|
| 50 |
+
group.add_argument("--test_file", help="Test file", type=str, default="")
|
| 51 |
+
group.add_argument("--partition", help="Data partition", type=int, default=1)
|
| 52 |
+
group.add_argument("--is_data_presplit", help="Whether the data is presplit", action="store_true")
|
| 53 |
+
group.add_argument("--stage", help="(Hardcoded) preprocessing stage", type=str)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def add_train_opts(parser):
|
| 57 |
+
"""Training options"""
|
| 58 |
+
group = parser.add_argument_group("template_relevance_train")
|
| 59 |
+
group.add_argument("--backend", help="Backend for DDP", type=str, default="gloo")
|
| 60 |
+
group.add_argument("--train_batch_size", help="training batch size",
|
| 61 |
+
type=int, default=128)
|
| 62 |
+
group.add_argument("--val_batch_size", help="validation batch size",
|
| 63 |
+
type=int, default=256)
|
| 64 |
+
group.add_argument("--learning_rate", help="learning rate",
|
| 65 |
+
type=float, default=1e-3)
|
| 66 |
+
group.add_argument("--clip_norm", help="Max norm for gradient clipping",
|
| 67 |
+
type=float, default=20.0)
|
| 68 |
+
group.add_argument("--epochs", help="num. of epochs", type=int, default=30)
|
| 69 |
+
group.add_argument("--early_stop", help="whether to use early stopping",
|
| 70 |
+
action="store_true")
|
| 71 |
+
group.add_argument("--early_stop_patience",
|
| 72 |
+
help="num. of epochs w/o improvement before early stop",
|
| 73 |
+
type=int, default=2)
|
| 74 |
+
group.add_argument("--early_stop_min_delta",
|
| 75 |
+
help="min. improvement in criteria needed to not early stop",
|
| 76 |
+
type=float, default=1e-4)
|
| 77 |
+
group.add_argument("--lr_scheduler_factor",
|
| 78 |
+
help="factor by which to reduce LR (ReduceLROnPlateau)",
|
| 79 |
+
type=float, default=0.3)
|
| 80 |
+
group.add_argument("--lr_scheduler_patience",
|
| 81 |
+
help="num. of epochs w/o improvement before "
|
| 82 |
+
"reducing LR (ReduceLROnPlateau)",
|
| 83 |
+
type=int, default=1)
|
| 84 |
+
group.add_argument("--lr_cooldown", help="epochs to wait before resuming "
|
| 85 |
+
"normal operation (ReduceLROnPlateau)",
|
| 86 |
+
type=int, default=0)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def add_predict_opts(parser):
|
| 90 |
+
"""Predicting options"""
|
| 91 |
+
group = parser.add_argument_group("template_relevance_predict")
|
| 92 |
+
group.add_argument("--test_batch_size", help="Testing batch size",
|
| 93 |
+
type=int, default=256)
|
| 94 |
+
group.add_argument("--topk", help="Topk", type=int, default=50)
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_files/utils.py
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime
|
| 2 |
+
import gzip
|
| 3 |
+
import json
|
| 4 |
+
import logging
|
| 5 |
+
import math
|
| 6 |
+
import misc
|
| 7 |
+
import numpy as np
|
| 8 |
+
import os
|
| 9 |
+
import pandas as pd
|
| 10 |
+
import random
|
| 11 |
+
import sys
|
| 12 |
+
import torch
|
| 13 |
+
import torch.distributed as dist
|
| 14 |
+
import torch.nn as nn
|
| 15 |
+
from models import TemplRel
|
| 16 |
+
from rdkit import Chem
|
| 17 |
+
from rdkit.Chem import AllChem, DataStructs
|
| 18 |
+
from rdkit.Chem.rdFingerprintGenerator import GetMorganGenerator
|
| 19 |
+
from scipy import sparse
|
| 20 |
+
from torch.nn.init import xavier_uniform_
|
| 21 |
+
from torch.nn.parallel import DistributedDataParallel as DDP
|
| 22 |
+
from typing import Any, Dict, List, Tuple
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def set_seed(seed: int) -> None:
|
| 26 |
+
random.seed(seed)
|
| 27 |
+
os.environ['PYTHONHASHSEED'] = str(seed)
|
| 28 |
+
np.random.seed(seed)
|
| 29 |
+
torch.manual_seed(seed)
|
| 30 |
+
torch.cuda.manual_seed_all(seed)
|
| 31 |
+
torch.backends.cudnn.benchmark = False
|
| 32 |
+
torch.backends.cudnn.deterministic = True
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def init_dist(args):
|
| 36 |
+
if args.local_rank != -1:
|
| 37 |
+
dist.init_process_group(backend=args.backend,
|
| 38 |
+
init_method='env://',
|
| 39 |
+
timeout=datetime.timedelta(0, 7200))
|
| 40 |
+
torch.cuda.set_device(args.local_rank)
|
| 41 |
+
torch.backends.cudnn.benchmark = False
|
| 42 |
+
|
| 43 |
+
if dist.is_initialized():
|
| 44 |
+
logging.info(f"Device rank: {dist.get_rank()}")
|
| 45 |
+
sys.stdout.flush()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def canonicalize_smiles(smiles: str, remove_atom_number: bool = True) -> str:
|
| 49 |
+
"""Adapted from Molecular Transformer"""
|
| 50 |
+
smiles = "".join(smiles.split())
|
| 51 |
+
cano_smiles = ""
|
| 52 |
+
|
| 53 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 54 |
+
|
| 55 |
+
if mol is not None:
|
| 56 |
+
if remove_atom_number:
|
| 57 |
+
[a.ClearProp('molAtomMapNumber') for a in mol.GetAtoms()]
|
| 58 |
+
|
| 59 |
+
cano_smiles = Chem.MolToSmiles(mol, isomericSmiles=True, canonical=True)
|
| 60 |
+
# Sometimes stereochem takes another canonicalization... (just in case)
|
| 61 |
+
mol = Chem.MolFromSmiles(cano_smiles)
|
| 62 |
+
if mol is not None:
|
| 63 |
+
cano_smiles = Chem.MolToSmiles(mol, isomericSmiles=True, canonical=True)
|
| 64 |
+
|
| 65 |
+
return cano_smiles
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def canonicalize_smarts(smarts: str) -> str:
|
| 69 |
+
templ = Chem.MolFromSmarts(smarts)
|
| 70 |
+
if templ is None:
|
| 71 |
+
logging.info(f'Could not parse {smarts}')
|
| 72 |
+
return smarts
|
| 73 |
+
|
| 74 |
+
canon_smarts = Chem.MolToSmarts(templ)
|
| 75 |
+
if '[[se]]' in canon_smarts: # strange parse error
|
| 76 |
+
canon_smarts = smarts
|
| 77 |
+
|
| 78 |
+
return canon_smarts
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def mol_smi_to_count_fp_min_htoo(
|
| 82 |
+
mol_smi: str, radius: int = 2, fp_size: int = 2048, dtype: str = "int32"
|
| 83 |
+
) -> sparse.csr_matrix:
|
| 84 |
+
fp_gen = GetMorganGenerator(
|
| 85 |
+
radius=radius, countSimulation=True, includeChirality=True, fpSize=fp_size
|
| 86 |
+
)
|
| 87 |
+
mol = Chem.MolFromSmiles(mol_smi)
|
| 88 |
+
uint_count_fp = fp_gen.GetCountFingerprint(mol)
|
| 89 |
+
count_fp = np.empty((1, fp_size), dtype=dtype)
|
| 90 |
+
DataStructs.ConvertToNumpyArray(uint_count_fp, count_fp)
|
| 91 |
+
|
| 92 |
+
return sparse.csr_matrix(count_fp, dtype=dtype)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def mol_smi_to_count_fp(
|
| 96 |
+
mol_smi: str, radius: int = 2, fp_size: int = 2048, dtype: str = "int32"
|
| 97 |
+
) -> sparse.csr_matrix:
|
| 98 |
+
mol = Chem.MolFromSmiles(mol_smi)
|
| 99 |
+
fp_bit = AllChem.GetMorganFingerprintAsBitVect(
|
| 100 |
+
mol,
|
| 101 |
+
radius=radius,
|
| 102 |
+
nBits=fp_size,
|
| 103 |
+
useChirality=True
|
| 104 |
+
)
|
| 105 |
+
fp = np.empty((1, fp_size), dtype=dtype)
|
| 106 |
+
DataStructs.ConvertToNumpyArray(fp_bit, fp)
|
| 107 |
+
|
| 108 |
+
return sparse.csr_matrix(fp, dtype=dtype)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def get_model(args, device) -> Tuple[nn.Module, Dict[str, Any]]:
|
| 112 |
+
state = {}
|
| 113 |
+
if args.load_from:
|
| 114 |
+
misc.log_rank_0(f"Loading pretrained state from {args.load_from}")
|
| 115 |
+
state = torch.load(args.load_from, map_location=torch.device("cpu"))
|
| 116 |
+
pretrain_args = state["args"]
|
| 117 |
+
misc.log_args(pretrain_args, message="Logging pretraining args")
|
| 118 |
+
|
| 119 |
+
model = TemplRel(pretrain_args)
|
| 120 |
+
pretrain_state_dict = state["state_dict"]
|
| 121 |
+
pretrain_state_dict = {k.replace("module.", ""): v
|
| 122 |
+
for k, v in pretrain_state_dict.items()}
|
| 123 |
+
model.load_state_dict(pretrain_state_dict)
|
| 124 |
+
misc.log_rank_0("Loaded pretrained model state_dict.")
|
| 125 |
+
|
| 126 |
+
# Overwrite for preprocessing during (likely) inference
|
| 127 |
+
args.fp_size = pretrain_args.fp_size
|
| 128 |
+
args.radius = pretrain_args.radius
|
| 129 |
+
else:
|
| 130 |
+
args.n_templates = sum(1 for _ in open(os.path.join(args.processed_data_path, "templates.jsonl")))
|
| 131 |
+
model = TemplRel(args)
|
| 132 |
+
for p in model.parameters():
|
| 133 |
+
if p.dim() > 1 and p.requires_grad:
|
| 134 |
+
xavier_uniform_(p)
|
| 135 |
+
|
| 136 |
+
model.to(device)
|
| 137 |
+
if args.local_rank != -1:
|
| 138 |
+
model = DDP(
|
| 139 |
+
model,
|
| 140 |
+
device_ids=[args.local_rank],
|
| 141 |
+
output_device=args.local_rank
|
| 142 |
+
)
|
| 143 |
+
misc.log_rank_0("DDP setup finished")
|
| 144 |
+
|
| 145 |
+
return model, state
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def save_reactions_from_list(
|
| 149 |
+
reactions: List[Dict[str, Any]],
|
| 150 |
+
template_set: str,
|
| 151 |
+
reaction_file_for_preprocessing: str,
|
| 152 |
+
reaction_file_for_db: str
|
| 153 |
+
) -> None:
|
| 154 |
+
logging.info(f"Saving unique reactions for preprocessing to "
|
| 155 |
+
f"{reaction_file_for_preprocessing}")
|
| 156 |
+
|
| 157 |
+
with open(reaction_file_for_preprocessing, "w") as of:
|
| 158 |
+
of.write("rxn_id,rxn_smiles\n")
|
| 159 |
+
|
| 160 |
+
for reaction in reactions:
|
| 161 |
+
of.write(f"{reaction['id']},{reaction['rxn_smiles']}\n")
|
| 162 |
+
|
| 163 |
+
reaction["reaction_id"] = reaction.pop("id")
|
| 164 |
+
reaction["reaction_smiles"] = reaction.pop("rxn_smiles")
|
| 165 |
+
if "_id" not in reaction:
|
| 166 |
+
reaction["_id"] = f"{template_set}_{reaction['reaction_id']}"
|
| 167 |
+
if "template_set" not in reaction:
|
| 168 |
+
reaction["template_set"] = template_set
|
| 169 |
+
|
| 170 |
+
logging.info(f"Saving reactions for db seeding to {reaction_file_for_db}")
|
| 171 |
+
with gzip.open(reaction_file_for_db, "wt", encoding="UTF-8") as zipfile:
|
| 172 |
+
json.dump(reactions, zipfile)
|
| 173 |
+
|
| 174 |
+
del reactions
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def save_templates_from_list(templates: List[Dict[str, Any]], template_file: str):
|
| 178 |
+
with open(template_file, "w") as of:
|
| 179 |
+
for template in templates:
|
| 180 |
+
if "rxn" in template:
|
| 181 |
+
del template["rxn"]
|
| 182 |
+
of.write(f"{json.dumps(template)}\n")
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def save_templates_from_dict(
|
| 186 |
+
templates: Dict[str, Dict[str, Any]],
|
| 187 |
+
template_file: str,
|
| 188 |
+
template_file_for_db: str
|
| 189 |
+
) -> None:
|
| 190 |
+
templates_as_list = []
|
| 191 |
+
|
| 192 |
+
logging.info(f"Saving templates to {template_file}")
|
| 193 |
+
with open(template_file, "w") as of:
|
| 194 |
+
for canon_templ, metadata in templates.items():
|
| 195 |
+
assert metadata["reaction_smarts"] == canon_templ
|
| 196 |
+
if "rxn" in metadata:
|
| 197 |
+
del metadata["rxn"]
|
| 198 |
+
of.write(f"{json.dumps(metadata)}\n")
|
| 199 |
+
|
| 200 |
+
templates_as_list.append(metadata)
|
| 201 |
+
|
| 202 |
+
logging.info(f"Saving templates for db seeding to {template_file_for_db}")
|
| 203 |
+
with gzip.open(template_file_for_db, "wt", encoding="UTF-8") as zipfile:
|
| 204 |
+
json.dump(templates_as_list, zipfile)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def load_templates_as_list(template_file: str
|
| 208 |
+
) -> Tuple[List[Dict[str, Any]], pd.DataFrame]:
|
| 209 |
+
templates = []
|
| 210 |
+
template_attributes = []
|
| 211 |
+
|
| 212 |
+
with open(template_file, "r") as f:
|
| 213 |
+
for line in f:
|
| 214 |
+
template = json.loads(line.strip())
|
| 215 |
+
del template["references"]
|
| 216 |
+
|
| 217 |
+
templates.append(template)
|
| 218 |
+
template_attributes.append(template.get("attributes", {}))
|
| 219 |
+
template_attributes = pd.DataFrame(template_attributes)
|
| 220 |
+
|
| 221 |
+
return templates, template_attributes
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def load_templates_as_dict(template_file: str) -> Dict[str, Dict[str, Any]]:
|
| 225 |
+
templates = {}
|
| 226 |
+
|
| 227 |
+
with open(template_file, "r") as f:
|
| 228 |
+
for line in f:
|
| 229 |
+
template = json.loads(line.strip())
|
| 230 |
+
templates[template["reaction_smarts"]] = template
|
| 231 |
+
|
| 232 |
+
return templates
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def get_lr(optimizer) -> float:
|
| 236 |
+
for param_group in optimizer.param_groups:
|
| 237 |
+
return param_group["lr"]
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def param_count(model: nn.Module) -> int:
|
| 241 |
+
return sum(param.numel() for param in model.parameters() if param.requires_grad)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
def param_norm(m: nn.Module) -> float:
|
| 245 |
+
return math.sqrt(sum([p.norm().item() ** 2 for p in m.parameters()]))
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
def grad_norm(m: nn.Module) -> float:
|
| 249 |
+
return math.sqrt(sum([p.grad.norm().item() ** 2
|
| 250 |
+
for p in m.parameters() if p.grad is not None]))
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/mar_members.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"members": [
|
| 3 |
+
{
|
| 4 |
+
"compress_size": 2524,
|
| 5 |
+
"modified": "2026-04-17T19:55:38",
|
| 6 |
+
"path": "templ_rel_handler.py",
|
| 7 |
+
"size": 8685
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"compress_size": 1251,
|
| 11 |
+
"modified": "2025-03-14T13:19:40",
|
| 12 |
+
"path": "templ_rel_parser.py",
|
| 13 |
+
"size": 5483
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"compress_size": 1249,
|
| 17 |
+
"modified": "2023-11-02T19:58:44",
|
| 18 |
+
"path": "models.py",
|
| 19 |
+
"size": 4027
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"compress_size": 786660005,
|
| 23 |
+
"modified": "2026-04-17T19:35:58",
|
| 24 |
+
"path": "model_latest.pt",
|
| 25 |
+
"size": 852483210
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"compress_size": 2459,
|
| 29 |
+
"modified": "2025-03-14T13:19:40",
|
| 30 |
+
"path": "utils.py",
|
| 31 |
+
"size": 8103
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"compress_size": 441,
|
| 35 |
+
"modified": "2023-11-02T19:58:44",
|
| 36 |
+
"path": "misc.py",
|
| 37 |
+
"size": 1062
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"compress_size": 5641952,
|
| 41 |
+
"modified": "2026-04-17T19:30:02",
|
| 42 |
+
"path": "templates.jsonl",
|
| 43 |
+
"size": 26493635
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"compress_size": 149,
|
| 47 |
+
"modified": "2026-04-17T19:56:06",
|
| 48 |
+
"path": "MAR-INF/MANIFEST.json",
|
| 49 |
+
"size": 215
|
| 50 |
+
}
|
| 51 |
+
]
|
| 52 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/model_args.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "nccl",
|
| 3 |
+
"clip_norm": 20.0,
|
| 4 |
+
"data_name": "uspto_higher-level_consol",
|
| 5 |
+
"device": "cuda",
|
| 6 |
+
"dropout": 0.5,
|
| 7 |
+
"early_stop": true,
|
| 8 |
+
"early_stop_min_delta": 0.0001,
|
| 9 |
+
"early_stop_patience": 2,
|
| 10 |
+
"epochs": 150,
|
| 11 |
+
"fp_size": 2048,
|
| 12 |
+
"gating_activation": "sigmoid",
|
| 13 |
+
"hidden_activation": "relu",
|
| 14 |
+
"hidden_sizes": [
|
| 15 |
+
2048
|
| 16 |
+
],
|
| 17 |
+
"is_optimistic_ranking": false,
|
| 18 |
+
"learning_rate": 0.00252468,
|
| 19 |
+
"load_from": "",
|
| 20 |
+
"local_rank": -1,
|
| 21 |
+
"log_file": "./logs/train/template_relevance_train_uspto_higher-level_consol.240806-1710h.log",
|
| 22 |
+
"lr_cooldown": 0,
|
| 23 |
+
"lr_scheduler_factor": 0.3,
|
| 24 |
+
"lr_scheduler_patience": 1,
|
| 25 |
+
"max_num_templ": 100,
|
| 26 |
+
"min_freq": 1,
|
| 27 |
+
"model_name": "template_relevance",
|
| 28 |
+
"model_path": "/home/jihye-roh/Higher_level_retrosynthesis/ASKCOSv2/retro/template_relevance/checkpoints/uspto_higher-level_consol",
|
| 29 |
+
"n_templates": 32622,
|
| 30 |
+
"num_cores": 32,
|
| 31 |
+
"processed_data_path": "/home/jihye-roh/Higher_level_retrosynthesis/ASKCOSv2/retro/template_relevance/data/uspto_higher-level_consol/processed",
|
| 32 |
+
"radius": 2,
|
| 33 |
+
"seed": 42,
|
| 34 |
+
"skip_connection": "none",
|
| 35 |
+
"test_batch_size": 2048,
|
| 36 |
+
"test_output_path": "",
|
| 37 |
+
"topk": 50,
|
| 38 |
+
"train_batch_size": 2048,
|
| 39 |
+
"val_batch_size": 2048
|
| 40 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/aux/safetensors_conversion.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format": "safetensors",
|
| 3 |
+
"num_tensors": 4,
|
| 4 |
+
"path": "model.safetensors",
|
| 5 |
+
"roundtrip_tensor_equal": true,
|
| 6 |
+
"runtime_assets": {
|
| 7 |
+
"model_args": "aux/model_args.json",
|
| 8 |
+
"templates": "aux/templates.jsonl"
|
| 9 |
+
},
|
| 10 |
+
"source_member": "model_latest.pt",
|
| 11 |
+
"status": "converted"
|
| 12 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/benchmarks/metadata.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 3 |
+
"built_at": "1970-01-01T00:00:00+00:00",
|
| 4 |
+
"checkpoint_id": "uspto_higher_level",
|
| 5 |
+
"dataset_id": "askcos_retro_template_relevance_uspto_higher_level_paroutes_reference_route_test",
|
| 6 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 7 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 8 |
+
"native_sources": [
|
| 9 |
+
{
|
| 10 |
+
"notes": [
|
| 11 |
+
"Public PaRoutes selected_reactions.csv source table used to reconstruct the one-step reference-route reaction subset."
|
| 12 |
+
],
|
| 13 |
+
"origin": "copied_from_local_public_record",
|
| 14 |
+
"relative_path": "benchmarks/native/selected_reactions.csv",
|
| 15 |
+
"source_url": "https://zenodo.org/records/7341155/files/selected_reactions.csv?download=1"
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"notes": [
|
| 19 |
+
"Public PaRoutes hash list identifying the reference-route reactions used here as a redistribution-safe ASKCOS compatibility benchmark."
|
| 20 |
+
],
|
| 21 |
+
"origin": "copied_from_local_public_record",
|
| 22 |
+
"relative_path": "benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 23 |
+
"source_url": "https://zenodo.org/records/7341155/files/ref_routes_reaction_hashes.txt?download=1"
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"notes": [
|
| 27 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 28 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 29 |
+
],
|
| 30 |
+
"num_examples": 56657,
|
| 31 |
+
"split": "test"
|
| 32 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/benchmarks/native/ref_routes_reaction_hashes.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/manifest.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auxiliary_files": [
|
| 3 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 4 |
+
"aux/mar_files/misc.py",
|
| 5 |
+
"aux/mar_files/models.py",
|
| 6 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 7 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 8 |
+
"aux/mar_files/utils.py",
|
| 9 |
+
"aux/mar_members.json",
|
| 10 |
+
"aux/model_args.json",
|
| 11 |
+
"aux/safetensors_conversion.json",
|
| 12 |
+
"aux/templates.jsonl",
|
| 13 |
+
"benchmarks/default_test.jsonl",
|
| 14 |
+
"benchmarks/metadata.json",
|
| 15 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt",
|
| 16 |
+
"benchmarks/native/selected_reactions.csv"
|
| 17 |
+
],
|
| 18 |
+
"benchmark_datasets": [
|
| 19 |
+
{
|
| 20 |
+
"benchmark_variant": "askcos_paroutes_compatibility_view",
|
| 21 |
+
"dataset_id": "askcos_retro_template_relevance_uspto_higher_level_paroutes_reference_route_test",
|
| 22 |
+
"dataset_ref": "paroutes2_reference_route_reactions",
|
| 23 |
+
"default": true,
|
| 24 |
+
"format": "jsonl",
|
| 25 |
+
"metadata_path": "benchmarks/metadata.json",
|
| 26 |
+
"native_input_format": "tab_delimited_reactants_reagents_product_rows",
|
| 27 |
+
"native_source_paths": [
|
| 28 |
+
"benchmarks/native/selected_reactions.csv",
|
| 29 |
+
"benchmarks/native/ref_routes_reaction_hashes.txt"
|
| 30 |
+
],
|
| 31 |
+
"notes": [
|
| 32 |
+
"ASKCOS does not redistribute the native train/validation/test split for this TorchServe archive in datasets/modelos_ASKCOS.",
|
| 33 |
+
"This bundled benchmark is therefore a public PaRoutes one-step retrosynthesis compatibility view, not a claim about the model's original validation split."
|
| 34 |
+
],
|
| 35 |
+
"num_examples": 56657,
|
| 36 |
+
"path": "benchmarks/default_test.jsonl",
|
| 37 |
+
"split": "test"
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"checkpoint_id": "uspto_higher_level",
|
| 41 |
+
"contained_artifact_bindings": [
|
| 42 |
+
{
|
| 43 |
+
"canonical_split_family": "askcos_uspto_higher_level_split_unspecified",
|
| 44 |
+
"dataset_ref": "askcos_uspto_higher_level_release",
|
| 45 |
+
"path": "modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 46 |
+
"stage": "released_torchserve_archive"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"conversion": {
|
| 50 |
+
"converted_at": "1970-01-01T00:00:00+00:00",
|
| 51 |
+
"notes": [
|
| 52 |
+
"The upstream ASKCOS TorchServe .mar was unpacked into native bundle assets.",
|
| 53 |
+
"Tensor weights are stored canonically as model.safetensors; non-tensor runtime assets are stored under aux/.",
|
| 54 |
+
"The original .mar archive is not required for wrapper inference."
|
| 55 |
+
],
|
| 56 |
+
"safetensors": {
|
| 57 |
+
"format": "safetensors",
|
| 58 |
+
"num_tensors": 4,
|
| 59 |
+
"path": "model.safetensors",
|
| 60 |
+
"roundtrip_tensor_equal": true,
|
| 61 |
+
"runtime_assets": {
|
| 62 |
+
"model_args": "aux/model_args.json",
|
| 63 |
+
"templates": "aux/templates.jsonl"
|
| 64 |
+
},
|
| 65 |
+
"source_member": "model_latest.pt",
|
| 66 |
+
"status": "converted"
|
| 67 |
+
},
|
| 68 |
+
"source_format": "torchserve_mar_embedded_checkpoint",
|
| 69 |
+
"status": "converted",
|
| 70 |
+
"tool_version": "initial"
|
| 71 |
+
},
|
| 72 |
+
"display_name": "uspto_higher_level",
|
| 73 |
+
"format_version": 1,
|
| 74 |
+
"generated_at": "1970-01-01T00:00:00+00:00",
|
| 75 |
+
"input_schema": {
|
| 76 |
+
"product_field": "smiles",
|
| 77 |
+
"request_format": {
|
| 78 |
+
"smiles": [
|
| 79 |
+
"product_smiles"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
"target_field": "reactants"
|
| 83 |
+
},
|
| 84 |
+
"model_id": "askcos_retro_template_relevance",
|
| 85 |
+
"model_role": "backward",
|
| 86 |
+
"normalized_checkpoint_id": "uspto_higher_level",
|
| 87 |
+
"package_layout": {
|
| 88 |
+
"aux_dir": "aux",
|
| 89 |
+
"benchmarks_dir": "benchmarks",
|
| 90 |
+
"weights_path": "model.safetensors"
|
| 91 |
+
},
|
| 92 |
+
"source_registry_refs": [
|
| 93 |
+
{
|
| 94 |
+
"checkpoint_id": "uspto_higher_level",
|
| 95 |
+
"model_id": "askcos_retro_template_relevance"
|
| 96 |
+
}
|
| 97 |
+
],
|
| 98 |
+
"split_provenance": [
|
| 99 |
+
{
|
| 100 |
+
"canonical_split_family": "askcos_uspto_higher_level_split_unspecified",
|
| 101 |
+
"dataset_ref": "askcos_uspto_higher_level_release",
|
| 102 |
+
"split_names": [],
|
| 103 |
+
"stage": "released_torchserve_archive"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"canonical_split_family": "askcos_uspto_higher_level_split_unspecified",
|
| 107 |
+
"dataset_ref": "askcos_uspto_higher_level_release",
|
| 108 |
+
"path": "modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 109 |
+
"stage": "released_torchserve_archive"
|
| 110 |
+
}
|
| 111 |
+
],
|
| 112 |
+
"task_direction": "retrosynthesis",
|
| 113 |
+
"training_dataset_refs": [
|
| 114 |
+
"askcos_uspto_higher_level_release"
|
| 115 |
+
],
|
| 116 |
+
"training_stage_bindings": [
|
| 117 |
+
{
|
| 118 |
+
"canonical_split_family": "askcos_uspto_higher_level_split_unspecified",
|
| 119 |
+
"dataset_ref": "askcos_uspto_higher_level_release",
|
| 120 |
+
"split_names": [],
|
| 121 |
+
"stage": "released_torchserve_archive"
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"canonical_split_family": "askcos_uspto_higher_level_split_unspecified",
|
| 125 |
+
"dataset_ref": "askcos_uspto_higher_level_release",
|
| 126 |
+
"path": "modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 127 |
+
"stage": "released_torchserve_archive"
|
| 128 |
+
}
|
| 129 |
+
],
|
| 130 |
+
"weights": {
|
| 131 |
+
"dtype_summary": "float tensors preserved from upstream checkpoint",
|
| 132 |
+
"framework": "safetensors",
|
| 133 |
+
"path": "model.safetensors",
|
| 134 |
+
"tensor_namespace": "askcos_template_relevance"
|
| 135 |
+
},
|
| 136 |
+
"wrapper_config": "wrapper_config.json",
|
| 137 |
+
"wrapper_family": "askcos_template_relevance"
|
| 138 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/provenance.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"conversion_notes": [
|
| 3 |
+
"The ASKCOS TorchServe .mar source archive was unpacked; model.mar is not copied into the normalized package.",
|
| 4 |
+
"Embedded tensor weights were serialized to model.safetensors and verified by safetensors round-trip equality.",
|
| 5 |
+
"Required non-tensor runtime assets such as templates, vocabularies, model args, OpenNMT metadata, and Graph2SMILES source support files are copied under aux/.",
|
| 6 |
+
"Lightweight MAR metadata is retained under aux/ for provenance only."
|
| 7 |
+
],
|
| 8 |
+
"copied_sidecars": [
|
| 9 |
+
"aux/MAR-INF/MANIFEST.json",
|
| 10 |
+
"aux/mar_files/misc.py",
|
| 11 |
+
"aux/mar_files/models.py",
|
| 12 |
+
"aux/mar_files/templ_rel_handler.py",
|
| 13 |
+
"aux/mar_files/templ_rel_parser.py",
|
| 14 |
+
"aux/mar_files/utils.py",
|
| 15 |
+
"aux/mar_members.json",
|
| 16 |
+
"aux/model_args.json",
|
| 17 |
+
"aux/safetensors_conversion.json",
|
| 18 |
+
"aux/templates.jsonl"
|
| 19 |
+
],
|
| 20 |
+
"inner_members": [
|
| 21 |
+
{
|
| 22 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 23 |
+
"member": "templ_rel_handler.py",
|
| 24 |
+
"role": "archive_member"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 28 |
+
"member": "templ_rel_parser.py",
|
| 29 |
+
"role": "archive_member"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 33 |
+
"member": "models.py",
|
| 34 |
+
"role": "archive_member"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 38 |
+
"member": "model_latest.pt",
|
| 39 |
+
"role": "weights_source"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 43 |
+
"member": "utils.py",
|
| 44 |
+
"role": "archive_member"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 48 |
+
"member": "misc.py",
|
| 49 |
+
"role": "archive_member"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 53 |
+
"member": "templates.jsonl",
|
| 54 |
+
"role": "template_library"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"archive_path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 58 |
+
"member": "MAR-INF/MANIFEST.json",
|
| 59 |
+
"role": "torchserve_manifest"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"normalized_checkpoint_id": "uspto_higher_level",
|
| 63 |
+
"source_artifacts": [
|
| 64 |
+
{
|
| 65 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 66 |
+
"kind": "local_repo_file",
|
| 67 |
+
"path": "datasets/modelos_ASKCOS/mars/uspto_higher_level.mar",
|
| 68 |
+
"role": "source_artifact",
|
| 69 |
+
"sha256": "fe746342007a4c767ceeab8c8dddcc7d73458d8a252e2587b83e50169f93b928",
|
| 70 |
+
"size": 792310888
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 74 |
+
"kind": "local_repo_file",
|
| 75 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models.sh",
|
| 76 |
+
"role": "source_artifact",
|
| 77 |
+
"sha256": "e88d26f86ce79d2c7d8f05d1a59e3b1b88bde69c3afb95d065c932ff058092be",
|
| 78 |
+
"size": 2374
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"absolute_path": "/mnt/HDD/syntheseus-bundle-builder/datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 82 |
+
"kind": "local_repo_file",
|
| 83 |
+
"path": "datasets/modelos_ASKCOS/download_trained_models2.sh",
|
| 84 |
+
"role": "source_artifact",
|
| 85 |
+
"sha256": "c2351dd12f68b0f372b23183cf470fa643f73274f66e34dfc0dacd1ce1a9843e",
|
| 86 |
+
"size": 1234
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
checkpoints/askcos_retro_template_relevance/uspto_higher_level/wrapper_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture_class": "NeuralSym-style template relevance FFN",
|
| 3 |
+
"device_supported": [
|
| 4 |
+
"cpu",
|
| 5 |
+
"cuda"
|
| 6 |
+
],
|
| 7 |
+
"input_schema": {
|
| 8 |
+
"product_field": "smiles",
|
| 9 |
+
"request_format": {
|
| 10 |
+
"smiles": [
|
| 11 |
+
"product_smiles"
|
| 12 |
+
]
|
| 13 |
+
},
|
| 14 |
+
"target_field": "reactants"
|
| 15 |
+
},
|
| 16 |
+
"license": "mit",
|
| 17 |
+
"loader": {
|
| 18 |
+
"kind": "askcos_template_relevance_safetensors",
|
| 19 |
+
"model_args": "aux/model_args.json",
|
| 20 |
+
"model_version": "1.0",
|
| 21 |
+
"served_model_name": "uspto_higher_level",
|
| 22 |
+
"source_handler": "templ_rel_handler.py",
|
| 23 |
+
"state_dict_format": "safetensors",
|
| 24 |
+
"templates": "aux/templates.jsonl"
|
| 25 |
+
},
|
| 26 |
+
"package_layout": {
|
| 27 |
+
"aux_dir": "aux",
|
| 28 |
+
"weights_path": "model.safetensors"
|
| 29 |
+
},
|
| 30 |
+
"runtime_file_map": {
|
| 31 |
+
"aux/model_args.json": "aux/model_args.json",
|
| 32 |
+
"aux/templates.jsonl": "aux/templates.jsonl",
|
| 33 |
+
"model.safetensors": "model.safetensors"
|
| 34 |
+
},
|
| 35 |
+
"task_direction": "retrosynthesis",
|
| 36 |
+
"wrapper_family": "askcos_template_relevance"
|
| 37 |
+
}
|