diff --git a/.github/scripts/smoke_wheel.py b/.github/scripts/smoke_wheel.py index cfb5bfa..902328f 100644 --- a/.github/scripts/smoke_wheel.py +++ b/.github/scripts/smoke_wheel.py @@ -50,6 +50,13 @@ def main(version): if "matches" in expected.score_fields: assert planes[1] == expected.to_array("matches").item() == 2 print(f"Cuda{name}: {planes.tolist()} ({actual.device})") + molecules = simms.MolecularGraphs.from_smiles(["CC", "NN"]) + distances = gpu.CudaMyopicMCES(threshold=2).matrix(molecules, progress_bar=False) + np.testing.assert_array_equal(distances.to_array("score"), [[0, 2], [2, 0]]) + assert distances.to_array("exact").all() + forced = gpu.CudaMyopicMCES(max_frames=1).pair("C1CCCCC1", "C1CC1.C1CC1") + assert forced.item() == (4, True) + print("CudaMyopicMCES: exact GPU and HiGHS fallback distances") network = gpu.CudaTransitiveAlignment(min_direct_matches=2).sparse_matrix([spectrum, spectrum]) matches = network.to_coo("matches") assert sorted(zip(matches.row, matches.col, matches.data)) == [(0, 1, 2), (1, 0, 2)] diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dff757..706152b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v1.1.0 + +- Added `CudaMyopicMCES` and the cached `MolecularGraphs` container for exact thresholded (`threshold=10.0`) and unrestricted (`threshold=None`) Myopic MCES molecular distances on CUDA with automatic in-process SciPy HiGHS (`scipy.optimize.milp`) fallback and zero new required dependencies. +- Verified `2,240/2,240` exact oracle parity against `myopic-mces 2.3.0` across threshold-10 and unrestricted benchmarks (`92×` faster than 8-core HiGHS and `690×` faster than 8-core CBC on 1,000 mixed pairs; see [benchmarks/myopic_mces_rtx4060.json](benchmarks/myopic_mces_rtx4060.json)). +- Supports `Spectrum` sequences, `SpectraCollection`, one-shot MGF generators, SMILES lists, RDKit `Mol` lists, and prepacked `MolecularGraphs`, with automatic unique-compound deduplication and GPU-side `sparse_matrix(..., max_distance=..., exact_only=...)` filtering. + ## v1.0.0 - Install the `simms-gpu` distribution and keep using `import simms`. The release targets Python 3.11 through 3.14 and matchms 1.0. CUDA 12 and 13 extras install the corresponding numba-cuda toolchain. The `fingerprints` extra adds chemap. diff --git a/README.md b/README.md index b148587..fbc1888 100644 --- a/README.md +++ b/README.md @@ -68,11 +68,32 @@ The default cosine tensor has shape `(2, n_refs, n_queries)`, with score and mat | `CudaModifiedCosineLinear` | `ModifiedCosineLinear` | Linear matching with a precursor shift and conflict resolution | | `CudaBinnedEmbeddingSimilarity` | `BinnedEmbeddingSimilarity` | Cosine or Euclidean similarity of binned intensities | | `CudaFingerprintSimilarity` | `FingerprintSimilarity` | Tanimoto or cosine over molecular fingerprints | +| `CudaMyopicMCES` | `myopic-mces` (`MCES`) | Exact thresholded or unrestricted Myopic MCES molecular distance (GPU bounds + bounded graph search + SciPy HiGHS fallback) | `CudaModifiedCosine` is an alias for `CudaModifiedCosineGreedy`. Fingerprint matrices are indexed by valid unique compounds, in matchms `Fingerprints.inchikeys` order on each axis. Use a chemap-compatible generator with valid InChIKey and SMILES or InChI metadata, or pass prepared containers as `fingerprints_1` and `fingerprints_2`. A precursor mask for fingerprint scoring must use those same compound axes. A spectrum-level mask is directly reusable when each spectrum represents a different valid compound on its axis. RDKit generators with JSON support can be exported through `to_dict()` and reconstructed from the saved parameters. Embedding, entropy and fingerprint scorers return a single score field. Binned embeddings and precomputed fingerprints also run on CPU. The six spectral CUDA scorers require a CUDA device or the Numba simulator. For simulator tests, set `NUMBA_ENABLE_CUDASIM=1` before starting Python. +## Myopic MCES (`CudaMyopicMCES`) + +`CudaMyopicMCES` computes exact thresholded (`threshold=10.0`) or unrestricted (`threshold=None`) weighted Maximum Common Edge Subgraph distances matching `myopic-mces 2.3.0`, with zero extra dependencies beyond SimMS's core install (`numba-cuda`, `rdkit`, and SciPy's in-process HiGHS `scipy.optimize.milp`). Duplicate SMILES/structures are deduplicated automatically and pairs exceeding `max_frames` or `max_gpu_atoms` fall back to exact in-process HiGHS before returning or sparse filtering. + +```python +from simms import MolecularGraphs +from simms.similarity import CudaMyopicMCES + +graphs = MolecularGraphs.from_smiles(["CC(=O)Oc1ccccc1C(=O)O", "O=C(O)c1ccccc1O", "Cn1cnc2c1c(=O)n(C)c(=O)n2C"]) +mces = CudaMyopicMCES(threshold=10.0) +scores = mces.matrix(graphs) +close_pairs = mces.sparse_matrix(graphs, max_distance=10.0, exact_only=True) +``` + +On the RTX 4060 Laptop GPU (`2,240/2,240` exact oracle parity vs `myopic-mces 2.3.0`, max diff `1.66e-12`; [benchmarks/myopic_mces_rtx4060.json](benchmarks/myopic_mces_rtx4060.json)): + +- **1,000 mixed pairs (`threshold=10`):** `17.9 ms` (`92.2×` vs 8-core upstream HiGHS, `690×` vs 8-core CBC) +- **120 `filter2` survivors (`threshold=10`):** `444 ms` (`4.24×` vs 8-core upstream HiGHS, `24.9×` vs 8-core CBC) +- *(Honest baseline note: an 8-core Numba CPU port of the same graph-native algorithm ran `1.1×–3.6×` faster than Numba CUDA on these 120–1,000 pair laptop batches, showing that most of the speedup over upstream `myopic-mces` comes from replacing generic MILP setup with compact integer graph bounds + in-process HiGHS fallback.)* + ## Transitive alignment `CudaTransitiveAlignment` builds an undirected network from one collection of spectra. Its defaults retain direct modified-cosine edges with a score of at least 0.7 and at least six matches. Each reachable non-edge uses the fewest-hop path with the highest sum of direct scores. Set `max_hops` to limit path length. [Wang et al., JASMS 2024](https://doi.org/10.1021/jasms.4c00208) diff --git a/benchmarks/benchmark_myopic_mces.py b/benchmarks/benchmark_myopic_mces.py new file mode 100644 index 0000000..d6ccac1 --- /dev/null +++ b/benchmarks/benchmark_myopic_mces.py @@ -0,0 +1,382 @@ +# SPDX-License-Identifier: MIT +"""RTX benchmark. Run from the repository root, e.g. on the i9-14900HX: + +OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 NUMBA_CUDA_LOW_OCCUPANCY_WARNINGS=0 \ + taskset -c 0,2,4,6,8,10,12,14 .venv/bin/python benchmarks/benchmark_myopic_mces.py + +The isolated oracle needs myopic-mces[cpp] and highspy. Input files are the +SimMS GNPS-random-10k and pesticides sample MGFs in data/downloads. Each panel +contains distinct unordered pairs. Both panels are checked at both thresholds. +""" +import argparse +from concurrent.futures import ProcessPoolExecutor +from importlib import import_module +from importlib.metadata import version +import json +import os +from pathlib import Path +import random +import subprocess +import sys +from tempfile import TemporaryDirectory +from time import perf_counter +from unittest.mock import patch + +import numpy as np +from rdkit import Chem, DataStructs, RDLogger +from rdkit.Chem.rdFingerprintGenerator import GetMorganGenerator + + +DRUGS = [ + "CC(=O)Oc1ccccc1C(=O)O", "O=C(O)c1ccccc1O", # aspirin, salicylic acid + "Cn1c(=O)c2c(ncn2C)n(C)c1=O", "Cn1c(=O)c2[nH]cnc2n(C)c1=O", + "NC(CO)C(=O)O", "CC(O)C(N)C(=O)O", # serine, threonine +] + + +def panels(): + from myopic_mces.filter_MCES import mf + + rng = random.Random(4060) + RDLogger.DisableLog("rdApp.*") + sources = {} + for name in ("pesticides", "GNPS-random-10k", "drugs"): + entries = DRUGS + if name != "drugs": + lines = Path(f"data/downloads/{name}.mgf").read_text().splitlines() + entries = [line.partition("=")[2] for line in lines if line.upper().startswith("SMILES=")] + for s in sorted(set(entries)): + mol = Chem.MolFromSmiles(s) + if mol and 4 <= mol.GetNumAtoms() <= 25 and mol.GetNumBonds(): + sources.setdefault(Chem.MolToSmiles(mol), name) + smiles = sorted(sources) + mols = [Chem.MolFromSmiles(s) for s in smiles] + fp = GetMorganGenerator(radius=2, fpSize=1024) + fps = [fp.GetFingerprint(m) for m in mols] + analogues = [(smiles.index(Chem.MolToSmiles(Chem.MolFromSmiles(a))), + smiles.index(Chem.MolToSmiles(Chem.MolFromSmiles(b)))) + for a, b in zip(DRUGS[::2], DRUGS[1::2])] + seen = {tuple(sorted(pair)) for pair in analogues} + anchors = [i for i, m in enumerate(mols) if 10 <= m.GetNumAtoms() <= 25] + rng.shuffle(anchors) + for i in anchors: + sims = DataStructs.BulkTanimotoSimilarity(fps[i], fps) + for j in np.argsort(sims)[::-1]: + pair = tuple(sorted((i, int(j)))) + if i != j and pair not in seen and 0 < mf.filter2(mols[i], mols[j]) <= 10: + analogues.append(pair) + seen.add(pair) + break + if len(analogues) == 120: + break + assert len(analogues) == 120 + # Bound the mixed-panel size range so unrestricted oracle ILPs are tractable. + small = [i for i, m in enumerate(mols) if 4 <= m.GetNumAtoms() <= 13] + mixed = [] + while len(mixed) < 1000: + pair = tuple(sorted(rng.sample(small, 2))) + if pair not in seen: + seen.add(pair) + mixed.append(pair) + used = sorted(set(i for pair in analogues + mixed for i in pair)) + remap = {v: i for i, v in enumerate(used)} + return dict(smiles=[smiles[i] for i in used], sources=[sources[smiles[i]] for i in used], + panels={k: [[remap[i], remap[j]] for i, j in pairs] + for k, pairs in (("survivors", analogues), ("mixed", mixed))}) + + +def oracle_init(smiles): + global oracle_mols + oracle_mols = [Chem.MolFromSmiles(s) for s in smiles] + + +def oracle_pair(args): + from myopic_mces.myopic_mces import MCES + + (i, j), solver, threshold = args + _, score, _, mode = MCES(oracle_mols[i], oracle_mols[j], threshold=threshold, solver=solver, + solver_options={"threads": 1, "msg": False, "gapRel": 0}) + return score, mode == 1 + + +def oracle(path): + data = panels() + from myopic_mces.filter_MCES import mf + + molecules = [Chem.MolFromSmiles(s) for s in data["smiles"]] + data["bounds"] = {name: [[mf.filter1(molecules[i], molecules[j]), mf.filter2(molecules[i], molecules[j])] + for i, j in pairs] for name, pairs in data["panels"].items()} + result = {} + configs = [(n, solver, threshold) for threshold in (10, -1) + for solver in ("HiGHS", "COIN_CMD") for n in (1, 8)] + for workers, solver, threshold in configs: + key = f"{solver}/{workers}/{threshold}" + result[key] = {} + with ProcessPoolExecutor(workers, initializer=oracle_init, initargs=(data["smiles"],)) as pool: + list(pool.map(oracle_pair, [((0, 1), solver, 10)] * workers)) + for panel, pairs in data["panels"].items(): + start = perf_counter() + values = list(pool.map(oracle_pair, [(p, solver, threshold) for p in pairs], chunksize=4)) + result[key][panel] = dict(seconds=perf_counter() - start, values=values) + print(key, panel, result[key][panel]["seconds"], file=sys.stderr, flush=True) + data.update(oracle=result, oracle_versions={p: version(p) for p in + ("myopic-mces", "myopic-mces-cpp", "pulp", "highspy", "rdkit")}) + path.write_text(json.dumps(data)) + + +def cpu_port(): + """Compile the very same bounds and search for CPU, with independent pair workspaces.""" + from numba import njit, prange + from simms.similarity import CudaMyopicMCES + from simms.similarity._mces_milp import solve_milp + from simms.similarity._mces_search import _objective_bound, _specialize + + bounds, search, _, _ = _specialize(njit) + objective_bound = njit(_objective_bound) + + @njit(parallel=True) + def solve(meta, vertices, adjacency, neighbors, pairs, limit, frame_cap, atom_cap): + n = len(pairs) + lower, distance, frames = np.empty(n, np.int32), np.empty(n, np.int32), np.zeros(n, np.int64) + for k in prange(n): + i, j = pairs[k] + a = vertices[meta[i, 0]:meta[i + 1, 0]] + b = vertices[meta[j, 0]:meta[j + 1, 0]] + na = neighbors[meta[i, 2]:meta[i + 1, 2]] + nb = neighbors[meta[j, 2]:meta[j + 1, 2]] + width = max(len(a), len(b)) + cost = np.empty((width, width), np.int32) + work = np.empty((7, width + 1), np.int32) + seed = np.empty((3, width), np.int32) + wa, wb = meta[i, 3], meta[j, 3] + lower[k] = bounds(a, b, na, nb, wa + wb, limit, True, cost, work, seed[0], seed[1], seed[2]) + distance[k] = lower[k] + if lower[k] <= limit: + distance[k] = -1 + if width <= atom_cap: + goal = objective_bound(wa + wb, lower[k], meta[i, 4], meta[j, 4]) + if goal > limit: + distance[k], frames[k] = goal, -1 + continue + adj = adjacency[meta[j, 1]:meta[j + 1, 1]] + distance[k], frames[k] = search(a, b, na, nb, adj, wa, wb, goal, limit, + frame_cap, seed[0], seed[1], seed[2], work) + return lower, distance, frames + + class Cpu(CudaMyopicMCES): + _upload = staticmethod(tuple) + + def _solve(self, library, graphs, pairs, width, pool, maximum, only_exact, device_output): + limit = np.inf if self.threshold is None else 2 * self.threshold + lower, distance, frames = solve(*library, np.asarray(pairs, np.int32), limit, + self.max_frames, self.max_gpu_atoms) + exact = distance <= limit + values = np.where(exact | (lower > limit), distance / 2, limit / 2) + pending = np.flatnonzero(distance < 0) + + def fallback(k): + i, j = pairs[k] + return solve_milp(graphs[i], graphs[j], self.threshold) + + for k, result in zip(pending, pool.map(fallback, pending)): + values[k], exact[k] = result + if self.counts is not None: + self.counts += np.array([np.count_nonzero(lower > limit), + np.count_nonzero((lower <= limit) & (frames == 0)), + np.count_nonzero((frames > 0) & (distance >= 0)), + np.count_nonzero(frames == -1), len(pending)]) + return range(len(pairs)), values, exact + + return Cpu + + +def unpack(scores, pairs): + values, flags = scores.to_coo("score"), scores.to_coo("exact") + np.testing.assert_array_equal(flags.row, values.row) + np.testing.assert_array_equal(flags.col, values.col) + records = {(i, j): [v, bool(e)] for i, j, v, e in zip(values.row, values.col, values.data, flags.data)} + return [records[tuple(pair)] for pair in pairs] + + +def mismatches(values, oracle): + return sum(not np.isclose(x, y, rtol=0, atol=1e-7) or a != b for (x, a), (y, b) in zip(values, oracle, strict=True)) + + +def verify_filters(graphs, pairs, expected): + from numba import cuda + from simms.similarity._mces_search import filter_kernel, pack + + indices = np.sort(graphs.index[np.asarray(pairs)], axis=1) + meta, vertices, _, neighbors = pack(graphs.graphs) + n, width = len(pairs), max(len(g.elements) for g in graphs.graphs) + args = [cuda.to_device(arr) for arr in (meta, vertices, neighbors, indices)] + scratch = [cuda.device_array(shape, np.int32) for shape in + ((n, width, width), (n, 7, width + 1), (n, 3, width), n)] + for column in (0, 1): + # A limit of -1 forces even a zero filter1 to return in dynamic mode. + filter_kernel[(n + 31) // 32, 32](*args, -1., bool(column), *scratch) + actual = scratch[-1].copy_to_host() / 2 + np.testing.assert_array_equal(actual, np.array(expected)[:, column]) + seeds = scratch[2].copy_to_host()[:, 0] + seed_certificates = 0 + for k, (i, j) in enumerate(indices): + if actual[k] > 10: + continue + a, b = graphs.graphs[i], graphs.graphs[j] + seed = seeds[k, :len(a.elements)] + left = np.flatnonzero(seed >= 0) + right = seed[left] + overlap_twice = np.minimum(a.adjacency[np.ix_(left, left)], + b.adjacency[np.ix_(right, right)]).sum(dtype=np.int64) + distance = (a.weight + b.weight - overlap_twice) / 2 + seed_certificates += int(distance == actual[k]) + return {"checked_per_filter": n, "filter1_mismatches": 0, "filter2_mismatches": 0, + "threshold_10_survivors": int(np.count_nonzero(actual <= 10)), + "unmodified_assignment_certificates_at_10": seed_certificates} + + +def device_load(): + """Sample compute-only clients outside the timed region, excluding this process.""" + output = subprocess.check_output(["nvidia-smi", "pmon", "-c", "1", "-s", "u"], text=True) + clients = [] + for line in output.splitlines(): + columns = line.split() + if len(columns) >= 5 and columns[2] == "C" and int(columns[1]) != os.getpid(): + clients.append(int(columns[3]) if columns[3].isdigit() else None) + return {"other_compute_clients": len(clients), "sampled_other_sm_percent": clients} + + +def benchmark(data, repeats): + from numba import cuda, set_num_threads + from simms import MolecularGraphs + from simms.similarity import CudaMyopicMCES + + set_num_threads(8) + cpu = cpu_port() + start = perf_counter() + graphs = MolecularGraphs.from_smiles(data["smiles"]) + preparation = perf_counter() - start + result = dict( + gpu=str(cuda.get_current_device().name), + cpu=next(line.split(":")[1].strip() for line in Path("/proc/cpuinfo").read_text().splitlines() + if line.startswith("model name")), + driver=subprocess.check_output(["nvidia-smi", "--query-gpu=driver_version", "--format=csv,noheader"], + text=True).strip(), + cpu_affinity=sorted(os.sched_getaffinity(0)), numba_threads=8, + versions={p: version(p) for p in ("simms-gpu", "numba-cuda", "numba", "numpy", "scipy", "rdkit")}, + oracle_versions=data["oracle_versions"], repeats=repeats, preparation_seconds=preparation, + timing="Warm sparse_matrix on prepared MolecularGraphs, including graph packing, host/device transfers, " + "fallback and Scores assembly. CPU graph solver uses identical JIT source and public batch path. " + "Upstream uses MCES on cached RDKit molecules, native C++ filters, one solver thread per process. " + "Pool startup and first call excluded. Speedups use medians of the recorded wall times. GPU lanes partition " + "root choices and share a frame cap. CPU threads handle one complete pair at a time. " + "Routing counts come from an untimed pass. Score tolerance is 1e-7 with exact flag equality.", + sampling="Distinct unordered pairs. Analogue panel uses three named analogue pairs plus seeded " + "Tanimoto-neighbor selection with 0 < upstream filter2 <= 10. Mixed panel sampled without " + "replacement from molecules with 4-13 atoms to make unrestricted oracle testing practical.", + panels={}, smiles=data["smiles"], sources=data["sources"], + ) + for panel, pairs in data["panels"].items(): + rows, cols = np.array(pairs).T + times = {} + for key, entry in data["oracle"].items(): + actual = entry[panel]["values"] + reference = data["oracle"]["HiGHS/8/" + key.split("/")[-1]][panel]["values"] + samples = entry[panel].get("samples", [entry[panel]["seconds"]]) + times[key] = dict(seconds=float(np.median(samples)), samples=samples, + mismatches=mismatches(actual, reference)) + stats = dict(pairs=pairs, oracle=times, filters=verify_filters(graphs, pairs, data["bounds"][panel])) + stats["filters"]["filter2_equals_optimum"] = sum( + bool(np.isclose(f2, exact[0], rtol=0, atol=1e-7)) + for (_, f2), exact in zip(data["bounds"][panel], data["oracle"]["HiGHS/8/-1"][panel]["values"]) + ) + result["panels"][panel] = stats + for threshold in (10, None): + key = f"HiGHS/8/{threshold or -1}" + oracle_values = data["oracle"][key][panel]["values"] + run = stats["threshold_10" if threshold else "unrestricted"] = {} + for name, cls in (("numba_cpu", cpu), ("cuda", CudaMyopicMCES)): + scorer = cls(threshold=threshold, n_fallback_workers=8) + scorer.counts = None + latencies = [] + before = device_load() + for trial in range(repeats + 1): + start = perf_counter() + scored = scorer.sparse_matrix(graphs, graphs, rows, cols, progress_bar=False) + elapsed = perf_counter() - start + if trial: + latencies.append(elapsed) + values = unpack(scored, pairs) + errors = mismatches(values, oracle_values) + if errors: + raise AssertionError(f"{name} {panel} threshold={threshold}: {errors} mismatches") + run[name] = dict(seconds=latencies, median_seconds=float(np.median(latencies)), + checked=len(values), mismatches=errors, + load_before=before, load_after=device_load(), + exact=sum(e for _, e in values), + max_absolute_error=max(abs(a[0] - b[0]) for a, b in zip(values, oracle_values))) + if name == "numba_cpu": + scorer.counts = np.zeros(5, np.int64) + scorer.sparse_matrix(graphs, graphs, rows, cols, progress_bar=False) + routes = ("filter_rejections", "map_certificates", "search_proofs", + "objective_bound_rejections", "fallbacks") + run[name]["routing"] = dict(zip(routes, scorer.counts.tolist())) + else: + module = import_module("simms.similarity.CudaMyopicMCES") + with patch.object(module, "solve_milp", wraps=module.solve_milp) as fallback: + checked = scorer.sparse_matrix(graphs, graphs, rows, cols, progress_bar=False) + assert not mismatches(unpack(checked, pairs), oracle_values) + routing = run["numba_cpu"]["routing"].copy() + routing["search_proofs"] += routing["fallbacks"] - len(fallback.call_args_list) + routing["fallbacks"] = len(fallback.call_args_list) + run[name]["routing"] = routing + gpu_time = run["cuda"]["median_seconds"] + run["speedup"] = {"numba_cpu_8": run["numba_cpu"]["median_seconds"] / gpu_time, + **{k: v["seconds"] / gpu_time for k, v in times.items() + if k.endswith("/" + str(threshold or -1))}} + print(panel, threshold, run, flush=True) + assert not any(item["mismatches"] for item in times.values()) + return result + + +def oracle_runs(paths): + """Pool complete timing passes only after checking panel identity and solver outputs.""" + first, *rest = paths + data = json.loads(first.read_text()) + for path in rest: + other = json.loads(path.read_text()) + for field in ("panels", "smiles", "oracle_versions"): + if data[field] != other[field]: + raise ValueError(f"Incompatible oracle run in {path}: {field}") + for key, panels_ in other["oracle"].items(): + for panel, sample in panels_.items(): + entry = data["oracle"][key][panel] + if mismatches(sample["values"], entry["values"]): + raise ValueError(f"Oracle disagreement in {path}: {key} {panel}") + entry.setdefault("samples", [entry["seconds"]]).append(sample["seconds"]) + return data + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--oracle-python", default="/tmp/mces-oracle/bin/python") + parser.add_argument("--oracle-data", type=Path, action="append", + help="reuse oracle-worker JSON, repeat to aggregate timings on identical panels") + parser.add_argument("--repeats", type=int, default=3) + parser.add_argument("--output", type=Path, default=Path("benchmarks/myopic_mces_rtx4060.json")) + args = parser.parse_args() + with TemporaryDirectory() as tmp: + paths = args.oracle_data + if paths is None: + data_path = Path(tmp) / "oracle.json" + subprocess.run([args.oracle_python, __file__, "--oracle-worker", str(data_path)], check=True) + paths = [data_path] + result = benchmark(oracle_runs(paths), args.repeats) + args.output.write_text(json.dumps(result, indent=2) + "\n") + + +if __name__ == "__main__": + if sys.argv[1:2] == ["--oracle-worker"]: + oracle(Path(sys.argv[2])) + else: + main() diff --git a/benchmarks/myopic_mces_rtx4060.json b/benchmarks/myopic_mces_rtx4060.json new file mode 100644 index 0000000..634d96b --- /dev/null +++ b/benchmarks/myopic_mces_rtx4060.json @@ -0,0 +1,6341 @@ +{ + "gpu": "NVIDIA GeForce RTX 4060 Laptop GPU", + "cpu": "Intel(R) Core(TM) i9-14900HX", + "driver": "580.105.08", + "cpu_affinity": [ + 0, + 2, + 4, + 6, + 8, + 10, + 12, + 14 + ], + "numba_threads": 8, + "versions": { + "simms-gpu": "1.0.0", + "numba-cuda": "0.30.4", + "numba": "0.68.1", + "numpy": "2.4.6", + "scipy": "1.18.1", + "rdkit": "2026.3.5" + }, + "oracle_versions": { + "myopic-mces": "2.3.0", + "myopic-mces-cpp": "2.3.0", + "pulp": "4.3.1", + "highspy": "1.16.0", + "rdkit": "2025.3.4" + }, + "repeats": 5, + "preparation_seconds": 0.34918677099994966, + "timing": "Warm sparse_matrix on prepared MolecularGraphs, including graph packing, host/device transfers, fallback and Scores assembly. CPU graph solver uses identical JIT source and public batch path. Upstream uses MCES on cached RDKit molecules, native C++ filters, one solver thread per process. Pool startup and first call excluded. Speedups use medians of the recorded wall times. GPU lanes partition root choices and share a frame cap. CPU threads handle one complete pair at a time. Routing counts come from an untimed pass. Score tolerance is 1e-7 with exact flag equality.", + "sampling": "Distinct unordered pairs. Analogue panel uses three named analogue pairs plus seeded Tanimoto-neighbor selection with 0 < upstream filter2 <= 10. Mixed panel sampled without replacement from molecules with 4-13 atoms to make unrestricted oracle testing practical.", + "panels": { + "survivors": { + "pairs": [ + [ + 57, + 569 + ], + [ + 355, + 354 + ], + [ + 403, + 102 + ], + [ + 616, + 617 + ], + [ + 87, + 338 + ], + [ + 138, + 147 + ], + [ + 638, + 639 + ], + [ + 16, + 17 + ], + [ + 137, + 144 + ], + [ + 6, + 623 + ], + [ + 108, + 109 + ], + [ + 450, + 451 + ], + [ + 208, + 613 + ], + [ + 336, + 673 + ], + [ + 247, + 439 + ], + [ + 203, + 629 + ], + [ + 266, + 267 + ], + [ + 160, + 178 + ], + [ + 227, + 249 + ], + [ + 74, + 283 + ], + [ + 320, + 342 + ], + [ + 588, + 648 + ], + [ + 387, + 388 + ], + [ + 8, + 9 + ], + [ + 577, + 581 + ], + [ + 459, + 642 + ], + [ + 122, + 270 + ], + [ + 624, + 625 + ], + [ + 614, + 615 + ], + [ + 454, + 645 + ], + [ + 264, + 280 + ], + [ + 474, + 644 + ], + [ + 217, + 636 + ], + [ + 68, + 618 + ], + [ + 479, + 482 + ], + [ + 35, + 520 + ], + [ + 142, + 145 + ], + [ + 526, + 527 + ], + [ + 93, + 95 + ], + [ + 236, + 238 + ], + [ + 555, + 604 + ], + [ + 248, + 285 + ], + [ + 127, + 176 + ], + [ + 80, + 81 + ], + [ + 391, + 533 + ], + [ + 245, + 246 + ], + [ + 189, + 332 + ], + [ + 172, + 173 + ], + [ + 82, + 583 + ], + [ + 177, + 437 + ], + [ + 29, + 30 + ], + [ + 86, + 521 + ], + [ + 242, + 243 + ], + [ + 49, + 50 + ], + [ + 141, + 148 + ], + [ + 87, + 466 + ], + [ + 611, + 612 + ], + [ + 605, + 628 + ], + [ + 63, + 470 + ], + [ + 34, + 492 + ], + [ + 106, + 275 + ], + [ + 260, + 279 + ], + [ + 331, + 334 + ], + [ + 323, + 462 + ], + [ + 125, + 184 + ], + [ + 609, + 610 + ], + [ + 480, + 481 + ], + [ + 319, + 329 + ], + [ + 578, + 579 + ], + [ + 12, + 13 + ], + [ + 69, + 117 + ], + [ + 225, + 409 + ], + [ + 383, + 503 + ], + [ + 339, + 624 + ], + [ + 64, + 159 + ], + [ + 485, + 487 + ], + [ + 254, + 261 + ], + [ + 167, + 168 + ], + [ + 238, + 619 + ], + [ + 38, + 39 + ], + [ + 158, + 484 + ], + [ + 239, + 240 + ], + [ + 151, + 163 + ], + [ + 281, + 349 + ], + [ + 89, + 174 + ], + [ + 170, + 441 + ], + [ + 149, + 150 + ], + [ + 151, + 152 + ], + [ + 437, + 536 + ], + [ + 250, + 286 + ], + [ + 356, + 585 + ], + [ + 166, + 418 + ], + [ + 20, + 21 + ], + [ + 51, + 332 + ], + [ + 401, + 448 + ], + [ + 230, + 231 + ], + [ + 233, + 269 + ], + [ + 252, + 253 + ], + [ + 234, + 258 + ], + [ + 103, + 104 + ], + [ + 43, + 171 + ], + [ + 265, + 608 + ], + [ + 255, + 256 + ], + [ + 67, + 237 + ], + [ + 33, + 58 + ], + [ + 110, + 111 + ], + [ + 4, + 14 + ], + [ + 13, + 105 + ], + [ + 516, + 518 + ], + [ + 663, + 664 + ], + [ + 589, + 590 + ], + [ + 354, + 357 + ], + [ + 257, + 259 + ], + [ + 307, + 309 + ], + [ + 212, + 289 + ], + [ + 206, + 316 + ], + [ + 27, + 488 + ], + [ + 75, + 76 + ], + [ + 197, + 331 + ], + [ + 262, + 263 + ] + ], + "oracle": { + "HiGHS/1/10": { + "seconds": 7.890829615000257, + "samples": [ + 9.978299058999255, + 6.894470979999824, + 7.890829615000257 + ], + "mismatches": 0 + }, + "HiGHS/8/10": { + "seconds": 1.8833286720000615, + "samples": [ + 1.8833286720000615, + 1.8330911630000628, + 2.2207927619992915 + ], + "mismatches": 0 + }, + "COIN_CMD/1/10": { + "seconds": 20.01714254000035, + "samples": [ + 52.716087591999894, + 20.01714254000035, + 10.103645863000565 + ], + "mismatches": 0 + }, + "COIN_CMD/8/10": { + "seconds": 11.07454858500023, + "samples": [ + 11.092567662000874, + 11.07454858500023, + 2.3189487369991184 + ], + "mismatches": 0 + }, + "HiGHS/1/-1": { + "seconds": 15.997664368000187, + "samples": [ + 20.20355684200058, + 11.791771893999794 + ], + "mismatches": 0 + }, + "HiGHS/8/-1": { + "seconds": 5.884709136999845, + "samples": [ + 8.400772516999496, + 5.122528826000234, + 5.884709136999845 + ], + "mismatches": 0 + }, + "COIN_CMD/1/-1": { + "seconds": 19.88309620300015, + "samples": [ + 28.539876771999843, + 11.226315634000457 + ], + "mismatches": 0 + }, + "COIN_CMD/8/-1": { + "seconds": 13.412344856000345, + "samples": [ + 13.314246532000652, + 13.510443180000038 + ], + "mismatches": 0 + } + }, + "filters": { + "checked_per_filter": 120, + "filter1_mismatches": 0, + "filter2_mismatches": 0, + "threshold_10_survivors": 120, + "unmodified_assignment_certificates_at_10": 16, + "filter2_equals_optimum": 72 + }, + "threshold_10": { + "numba_cpu": { + "seconds": [ + 0.4189009919991804, + 0.3954415409998546, + 0.39751947700005985, + 0.3684059809993414, + 0.37243162499999016 + ], + "median_seconds": 0.3954415409998546, + "checked": 120, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 24 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 23 + ] + }, + "exact": 99, + "max_absolute_error": 1.2256862191861728e-13, + "routing": { + "filter_rejections": 0, + "map_certificates": 49, + "search_proofs": 62, + "objective_bound_rejections": 4, + "fallbacks": 5 + } + }, + "cuda": { + "seconds": [ + 0.4443944909999118, + 0.4502719439997236, + 0.44087627499993687, + 0.4569548039999063, + 0.4386585960000957 + ], + "median_seconds": 0.4443944909999118, + "checked": 120, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 23 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 38 + ] + }, + "exact": 99, + "max_absolute_error": 1.2256862191861728e-13, + "routing": { + "filter_rejections": 0, + "map_certificates": 49, + "search_proofs": 63, + "objective_bound_rejections": 4, + "fallbacks": 4 + } + }, + "speedup": { + "numba_cpu_8": 0.8898434814304057, + "HiGHS/1/10": 17.756362364541154, + "HiGHS/8/10": 4.237965839230971, + "COIN_CMD/1/10": 45.04363340544724, + "COIN_CMD/8/10": 24.920535266046823 + } + }, + "unrestricted": { + "numba_cpu": { + "seconds": [ + 3.9065129700002217, + 3.878725814999598, + 3.8566069640000933, + 3.8314850750002734, + 3.78563714899974 + ], + "median_seconds": 3.8566069640000933, + "checked": 120, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 40 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 28 + ] + }, + "exact": 120, + "max_absolute_error": 4.973799150320701e-14, + "routing": { + "filter_rejections": 0, + "map_certificates": 50, + "search_proofs": 59, + "objective_bound_rejections": 0, + "fallbacks": 11 + } + }, + "cuda": { + "seconds": [ + 4.12586815099985, + 4.199051216999578, + 4.132975428000464, + 4.592841650999617, + 4.928209851000247 + ], + "median_seconds": 4.199051216999578, + "checked": 120, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 31 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 25 + ] + }, + "exact": 120, + "max_absolute_error": 4.973799150320701e-14, + "routing": { + "filter_rejections": 0, + "map_certificates": 50, + "search_proofs": 58, + "objective_bound_rejections": 0, + "fallbacks": 12 + } + }, + "speedup": { + "numba_cpu_8": 0.918447231219014, + "HiGHS/1/-1": 3.809828349612577, + "HiGHS/8/-1": 1.4014378088973989, + "COIN_CMD/1/-1": 4.735140196076857, + "COIN_CMD/8/-1": 3.1941369997349316 + } + } + }, + "mixed": { + "pairs": [ + [ + 188, + 370 + ], + [ + 425, + 525 + ], + [ + 404, + 522 + ], + [ + 251, + 513 + ], + [ + 372, + 429 + ], + [ + 465, + 478 + ], + [ + 571, + 671 + ], + [ + 45, + 532 + ], + [ + 61, + 333 + ], + [ + 224, + 584 + ], + [ + 497, + 657 + ], + [ + 199, + 381 + ], + [ + 308, + 426 + ], + [ + 464, + 566 + ], + [ + 199, + 303 + ], + [ + 326, + 569 + ], + [ + 351, + 665 + ], + [ + 77, + 661 + ], + [ + 102, + 652 + ], + [ + 417, + 565 + ], + [ + 70, + 414 + ], + [ + 23, + 664 + ], + [ + 113, + 419 + ], + [ + 476, + 626 + ], + [ + 537, + 652 + ], + [ + 191, + 541 + ], + [ + 562, + 568 + ], + [ + 318, + 525 + ], + [ + 274, + 583 + ], + [ + 153, + 277 + ], + [ + 77, + 416 + ], + [ + 272, + 509 + ], + [ + 235, + 463 + ], + [ + 120, + 560 + ], + [ + 79, + 451 + ], + [ + 123, + 594 + ], + [ + 175, + 314 + ], + [ + 272, + 522 + ], + [ + 307, + 452 + ], + [ + 91, + 215 + ], + [ + 424, + 672 + ], + [ + 164, + 513 + ], + [ + 220, + 561 + ], + [ + 88, + 180 + ], + [ + 303, + 389 + ], + [ + 421, + 472 + ], + [ + 71, + 407 + ], + [ + 277, + 326 + ], + [ + 532, + 639 + ], + [ + 140, + 658 + ], + [ + 183, + 282 + ], + [ + 133, + 564 + ], + [ + 226, + 582 + ], + [ + 510, + 549 + ], + [ + 356, + 559 + ], + [ + 180, + 402 + ], + [ + 247, + 346 + ], + [ + 515, + 554 + ], + [ + 322, + 543 + ], + [ + 200, + 465 + ], + [ + 364, + 509 + ], + [ + 123, + 244 + ], + [ + 78, + 654 + ], + [ + 62, + 219 + ], + [ + 317, + 378 + ], + [ + 169, + 278 + ], + [ + 155, + 330 + ], + [ + 359, + 558 + ], + [ + 386, + 622 + ], + [ + 156, + 162 + ], + [ + 522, + 569 + ], + [ + 130, + 459 + ], + [ + 61, + 435 + ], + [ + 271, + 671 + ], + [ + 40, + 574 + ], + [ + 25, + 506 + ], + [ + 140, + 187 + ], + [ + 540, + 635 + ], + [ + 375, + 661 + ], + [ + 385, + 652 + ], + [ + 435, + 598 + ], + [ + 80, + 522 + ], + [ + 85, + 331 + ], + [ + 201, + 669 + ], + [ + 241, + 520 + ], + [ + 36, + 632 + ], + [ + 220, + 497 + ], + [ + 228, + 504 + ], + [ + 297, + 344 + ], + [ + 347, + 465 + ], + [ + 79, + 200 + ], + [ + 143, + 378 + ], + [ + 502, + 661 + ], + [ + 498, + 514 + ], + [ + 293, + 560 + ], + [ + 235, + 251 + ], + [ + 26, + 136 + ], + [ + 214, + 447 + ], + [ + 10, + 390 + ], + [ + 252, + 606 + ], + [ + 54, + 546 + ], + [ + 390, + 592 + ], + [ + 294, + 637 + ], + [ + 94, + 519 + ], + [ + 44, + 508 + ], + [ + 476, + 505 + ], + [ + 56, + 460 + ], + [ + 426, + 658 + ], + [ + 200, + 420 + ], + [ + 41, + 59 + ], + [ + 52, + 78 + ], + [ + 135, + 183 + ], + [ + 16, + 445 + ], + [ + 471, + 517 + ], + [ + 119, + 560 + ], + [ + 123, + 340 + ], + [ + 70, + 457 + ], + [ + 103, + 229 + ], + [ + 217, + 450 + ], + [ + 187, + 463 + ], + [ + 398, + 414 + ], + [ + 37, + 98 + ], + [ + 31, + 384 + ], + [ + 341, + 436 + ], + [ + 290, + 526 + ], + [ + 118, + 526 + ], + [ + 26, + 661 + ], + [ + 298, + 372 + ], + [ + 252, + 630 + ], + [ + 85, + 209 + ], + [ + 537, + 622 + ], + [ + 123, + 463 + ], + [ + 101, + 414 + ], + [ + 85, + 126 + ], + [ + 44, + 47 + ], + [ + 300, + 656 + ], + [ + 330, + 358 + ], + [ + 113, + 211 + ], + [ + 461, + 674 + ], + [ + 73, + 546 + ], + [ + 83, + 315 + ], + [ + 470, + 472 + ], + [ + 45, + 439 + ], + [ + 214, + 451 + ], + [ + 525, + 527 + ], + [ + 37, + 188 + ], + [ + 70, + 569 + ], + [ + 207, + 330 + ], + [ + 369, + 537 + ], + [ + 370, + 669 + ], + [ + 426, + 575 + ], + [ + 402, + 557 + ], + [ + 337, + 666 + ], + [ + 326, + 556 + ], + [ + 83, + 428 + ], + [ + 314, + 564 + ], + [ + 423, + 475 + ], + [ + 192, + 465 + ], + [ + 400, + 528 + ], + [ + 26, + 369 + ], + [ + 77, + 274 + ], + [ + 472, + 674 + ], + [ + 2, + 28 + ], + [ + 42, + 359 + ], + [ + 318, + 538 + ], + [ + 129, + 460 + ], + [ + 286, + 317 + ], + [ + 182, + 415 + ], + [ + 52, + 528 + ], + [ + 277, + 650 + ], + [ + 22, + 621 + ], + [ + 200, + 514 + ], + [ + 132, + 516 + ], + [ + 51, + 321 + ], + [ + 398, + 559 + ], + [ + 434, + 512 + ], + [ + 468, + 572 + ], + [ + 492, + 602 + ], + [ + 43, + 390 + ], + [ + 285, + 341 + ], + [ + 356, + 562 + ], + [ + 53, + 568 + ], + [ + 370, + 598 + ], + [ + 209, + 346 + ], + [ + 15, + 328 + ], + [ + 247, + 309 + ], + [ + 277, + 407 + ], + [ + 65, + 514 + ], + [ + 292, + 637 + ], + [ + 363, + 431 + ], + [ + 22, + 666 + ], + [ + 347, + 551 + ], + [ + 493, + 516 + ], + [ + 524, + 626 + ], + [ + 217, + 607 + ], + [ + 273, + 361 + ], + [ + 10, + 473 + ], + [ + 45, + 295 + ], + [ + 220, + 271 + ], + [ + 291, + 591 + ], + [ + 247, + 507 + ], + [ + 118, + 377 + ], + [ + 362, + 390 + ], + [ + 59, + 525 + ], + [ + 348, + 607 + ], + [ + 465, + 470 + ], + [ + 337, + 450 + ], + [ + 2, + 446 + ], + [ + 294, + 603 + ], + [ + 22, + 573 + ], + [ + 305, + 397 + ], + [ + 500, + 642 + ], + [ + 80, + 477 + ], + [ + 132, + 561 + ], + [ + 88, + 580 + ], + [ + 2, + 669 + ], + [ + 119, + 435 + ], + [ + 35, + 204 + ], + [ + 126, + 381 + ], + [ + 63, + 301 + ], + [ + 23, + 583 + ], + [ + 16, + 42 + ], + [ + 404, + 443 + ], + [ + 510, + 560 + ], + [ + 618, + 636 + ], + [ + 200, + 458 + ], + [ + 335, + 359 + ], + [ + 18, + 599 + ], + [ + 45, + 235 + ], + [ + 131, + 559 + ], + [ + 399, + 545 + ], + [ + 205, + 399 + ], + [ + 457, + 519 + ], + [ + 497, + 534 + ], + [ + 376, + 496 + ], + [ + 427, + 663 + ], + [ + 350, + 518 + ], + [ + 511, + 586 + ], + [ + 96, + 438 + ], + [ + 61, + 548 + ], + [ + 204, + 553 + ], + [ + 408, + 599 + ], + [ + 15, + 112 + ], + [ + 545, + 587 + ], + [ + 395, + 469 + ], + [ + 56, + 472 + ], + [ + 301, + 330 + ], + [ + 405, + 532 + ], + [ + 56, + 640 + ], + [ + 413, + 659 + ], + [ + 312, + 457 + ], + [ + 211, + 425 + ], + [ + 165, + 674 + ], + [ + 200, + 300 + ], + [ + 346, + 490 + ], + [ + 458, + 669 + ], + [ + 641, + 668 + ], + [ + 574, + 667 + ], + [ + 282, + 653 + ], + [ + 143, + 495 + ], + [ + 394, + 587 + ], + [ + 81, + 494 + ], + [ + 83, + 450 + ], + [ + 186, + 402 + ], + [ + 583, + 653 + ], + [ + 348, + 647 + ], + [ + 229, + 640 + ], + [ + 141, + 412 + ], + [ + 224, + 424 + ], + [ + 42, + 155 + ], + [ + 37, + 570 + ], + [ + 11, + 274 + ], + [ + 45, + 201 + ], + [ + 347, + 647 + ], + [ + 10, + 427 + ], + [ + 65, + 646 + ], + [ + 119, + 478 + ], + [ + 18, + 511 + ], + [ + 364, + 467 + ], + [ + 118, + 486 + ], + [ + 194, + 271 + ], + [ + 352, + 621 + ], + [ + 143, + 377 + ], + [ + 328, + 497 + ], + [ + 324, + 583 + ], + [ + 195, + 565 + ], + [ + 221, + 368 + ], + [ + 584, + 675 + ], + [ + 25, + 71 + ], + [ + 287, + 603 + ], + [ + 465, + 560 + ], + [ + 124, + 573 + ], + [ + 317, + 490 + ], + [ + 202, + 309 + ], + [ + 98, + 359 + ], + [ + 478, + 506 + ], + [ + 285, + 666 + ], + [ + 124, + 413 + ], + [ + 218, + 226 + ], + [ + 311, + 538 + ], + [ + 526, + 626 + ], + [ + 141, + 531 + ], + [ + 80, + 451 + ], + [ + 102, + 132 + ], + [ + 398, + 536 + ], + [ + 393, + 640 + ], + [ + 25, + 352 + ], + [ + 146, + 498 + ], + [ + 204, + 518 + ], + [ + 204, + 524 + ], + [ + 15, + 129 + ], + [ + 218, + 421 + ], + [ + 115, + 488 + ], + [ + 115, + 662 + ], + [ + 19, + 377 + ], + [ + 146, + 563 + ], + [ + 440, + 527 + ], + [ + 446, + 676 + ], + [ + 395, + 675 + ], + [ + 179, + 450 + ], + [ + 36, + 496 + ], + [ + 414, + 501 + ], + [ + 393, + 429 + ], + [ + 514, + 672 + ], + [ + 131, + 381 + ], + [ + 191, + 558 + ], + [ + 244, + 345 + ], + [ + 308, + 362 + ], + [ + 193, + 377 + ], + [ + 290, + 313 + ], + [ + 100, + 500 + ], + [ + 205, + 209 + ], + [ + 3, + 520 + ], + [ + 37, + 71 + ], + [ + 48, + 244 + ], + [ + 368, + 580 + ], + [ + 43, + 376 + ], + [ + 301, + 598 + ], + [ + 562, + 650 + ], + [ + 24, + 140 + ], + [ + 169, + 597 + ], + [ + 134, + 376 + ], + [ + 512, + 621 + ], + [ + 40, + 458 + ], + [ + 200, + 444 + ], + [ + 78, + 317 + ], + [ + 101, + 295 + ], + [ + 435, + 600 + ], + [ + 116, + 296 + ], + [ + 24, + 57 + ], + [ + 63, + 322 + ], + [ + 252, + 664 + ], + [ + 247, + 428 + ], + [ + 312, + 394 + ], + [ + 173, + 395 + ], + [ + 31, + 564 + ], + [ + 544, + 585 + ], + [ + 36, + 130 + ], + [ + 220, + 444 + ], + [ + 370, + 415 + ], + [ + 40, + 641 + ], + [ + 373, + 637 + ], + [ + 232, + 351 + ], + [ + 116, + 359 + ], + [ + 489, + 528 + ], + [ + 297, + 343 + ], + [ + 391, + 478 + ], + [ + 328, + 528 + ], + [ + 222, + 356 + ], + [ + 384, + 606 + ], + [ + 217, + 421 + ], + [ + 40, + 376 + ], + [ + 424, + 637 + ], + [ + 373, + 669 + ], + [ + 457, + 476 + ], + [ + 96, + 455 + ], + [ + 169, + 436 + ], + [ + 510, + 639 + ], + [ + 72, + 384 + ], + [ + 341, + 553 + ], + [ + 143, + 653 + ], + [ + 494, + 643 + ], + [ + 28, + 617 + ], + [ + 92, + 654 + ], + [ + 583, + 607 + ], + [ + 228, + 229 + ], + [ + 562, + 620 + ], + [ + 188, + 404 + ], + [ + 635, + 640 + ], + [ + 28, + 417 + ], + [ + 357, + 522 + ], + [ + 398, + 658 + ], + [ + 99, + 146 + ], + [ + 90, + 449 + ], + [ + 507, + 518 + ], + [ + 63, + 143 + ], + [ + 42, + 356 + ], + [ + 425, + 528 + ], + [ + 90, + 396 + ], + [ + 494, + 495 + ], + [ + 365, + 438 + ], + [ + 156, + 635 + ], + [ + 140, + 539 + ], + [ + 191, + 282 + ], + [ + 495, + 661 + ], + [ + 511, + 526 + ], + [ + 393, + 505 + ], + [ + 348, + 575 + ], + [ + 417, + 432 + ], + [ + 241, + 496 + ], + [ + 252, + 302 + ], + [ + 309, + 455 + ], + [ + 404, + 455 + ], + [ + 483, + 567 + ], + [ + 312, + 463 + ], + [ + 42, + 674 + ], + [ + 15, + 606 + ], + [ + 450, + 676 + ], + [ + 384, + 453 + ], + [ + 1, + 524 + ], + [ + 394, + 601 + ], + [ + 215, + 643 + ], + [ + 295, + 445 + ], + [ + 118, + 216 + ], + [ + 165, + 556 + ], + [ + 126, + 187 + ], + [ + 417, + 459 + ], + [ + 483, + 551 + ], + [ + 224, + 272 + ], + [ + 112, + 379 + ], + [ + 102, + 408 + ], + [ + 272, + 606 + ], + [ + 297, + 640 + ], + [ + 136, + 573 + ], + [ + 221, + 602 + ], + [ + 26, + 367 + ], + [ + 157, + 635 + ], + [ + 52, + 164 + ], + [ + 90, + 442 + ], + [ + 374, + 380 + ], + [ + 121, + 516 + ], + [ + 278, + 564 + ], + [ + 368, + 506 + ], + [ + 393, + 669 + ], + [ + 66, + 143 + ], + [ + 173, + 537 + ], + [ + 389, + 647 + ], + [ + 37, + 300 + ], + [ + 286, + 643 + ], + [ + 118, + 393 + ], + [ + 556, + 637 + ], + [ + 548, + 554 + ], + [ + 309, + 529 + ], + [ + 452, + 593 + ], + [ + 202, + 382 + ], + [ + 429, + 541 + ], + [ + 276, + 640 + ], + [ + 100, + 601 + ], + [ + 285, + 420 + ], + [ + 425, + 599 + ], + [ + 420, + 429 + ], + [ + 0, + 635 + ], + [ + 493, + 527 + ], + [ + 352, + 411 + ], + [ + 196, + 598 + ], + [ + 301, + 450 + ], + [ + 188, + 327 + ], + [ + 53, + 330 + ], + [ + 318, + 473 + ], + [ + 140, + 333 + ], + [ + 44, + 414 + ], + [ + 115, + 129 + ], + [ + 157, + 570 + ], + [ + 207, + 573 + ], + [ + 71, + 515 + ], + [ + 372, + 537 + ], + [ + 365, + 660 + ], + [ + 157, + 305 + ], + [ + 510, + 516 + ], + [ + 345, + 544 + ], + [ + 10, + 133 + ], + [ + 44, + 432 + ], + [ + 395, + 585 + ], + [ + 410, + 452 + ], + [ + 295, + 559 + ], + [ + 303, + 639 + ], + [ + 113, + 567 + ], + [ + 465, + 492 + ], + [ + 66, + 216 + ], + [ + 335, + 414 + ], + [ + 100, + 526 + ], + [ + 361, + 518 + ], + [ + 569, + 642 + ], + [ + 46, + 385 + ], + [ + 446, + 591 + ], + [ + 81, + 542 + ], + [ + 35, + 653 + ], + [ + 360, + 544 + ], + [ + 306, + 621 + ], + [ + 123, + 661 + ], + [ + 165, + 476 + ], + [ + 121, + 473 + ], + [ + 318, + 671 + ], + [ + 467, + 652 + ], + [ + 548, + 600 + ], + [ + 37, + 504 + ], + [ + 48, + 507 + ], + [ + 446, + 531 + ], + [ + 366, + 676 + ], + [ + 98, + 599 + ], + [ + 278, + 565 + ], + [ + 420, + 442 + ], + [ + 0, + 657 + ], + [ + 194, + 563 + ], + [ + 183, + 634 + ], + [ + 303, + 621 + ], + [ + 72, + 287 + ], + [ + 56, + 636 + ], + [ + 16, + 542 + ], + [ + 306, + 420 + ], + [ + 34, + 228 + ], + [ + 164, + 302 + ], + [ + 90, + 322 + ], + [ + 456, + 464 + ], + [ + 475, + 549 + ], + [ + 22, + 368 + ], + [ + 386, + 593 + ], + [ + 268, + 366 + ], + [ + 97, + 668 + ], + [ + 290, + 560 + ], + [ + 40, + 630 + ], + [ + 400, + 654 + ], + [ + 514, + 532 + ], + [ + 26, + 292 + ], + [ + 337, + 420 + ], + [ + 156, + 477 + ], + [ + 51, + 378 + ], + [ + 65, + 314 + ], + [ + 57, + 216 + ], + [ + 306, + 598 + ], + [ + 446, + 502 + ], + [ + 180, + 638 + ], + [ + 84, + 303 + ], + [ + 307, + 415 + ], + [ + 299, + 483 + ], + [ + 335, + 436 + ], + [ + 25, + 165 + ], + [ + 423, + 535 + ], + [ + 201, + 552 + ], + [ + 340, + 417 + ], + [ + 211, + 216 + ], + [ + 57, + 621 + ], + [ + 120, + 574 + ], + [ + 516, + 617 + ], + [ + 61, + 414 + ], + [ + 386, + 502 + ], + [ + 113, + 363 + ], + [ + 453, + 554 + ], + [ + 60, + 431 + ], + [ + 59, + 414 + ], + [ + 81, + 661 + ], + [ + 201, + 420 + ], + [ + 461, + 647 + ], + [ + 499, + 534 + ], + [ + 526, + 541 + ], + [ + 421, + 551 + ], + [ + 362, + 506 + ], + [ + 386, + 572 + ], + [ + 72, + 357 + ], + [ + 22, + 650 + ], + [ + 2, + 277 + ], + [ + 185, + 282 + ], + [ + 514, + 556 + ], + [ + 370, + 563 + ], + [ + 277, + 432 + ], + [ + 41, + 396 + ], + [ + 15, + 518 + ], + [ + 501, + 647 + ], + [ + 386, + 642 + ], + [ + 364, + 637 + ], + [ + 411, + 435 + ], + [ + 205, + 315 + ], + [ + 31, + 372 + ], + [ + 126, + 297 + ], + [ + 415, + 550 + ], + [ + 140, + 488 + ], + [ + 126, + 215 + ], + [ + 78, + 310 + ], + [ + 115, + 123 + ], + [ + 146, + 343 + ], + [ + 414, + 545 + ], + [ + 365, + 538 + ], + [ + 438, + 663 + ], + [ + 426, + 654 + ], + [ + 526, + 638 + ], + [ + 65, + 568 + ], + [ + 346, + 596 + ], + [ + 165, + 434 + ], + [ + 115, + 514 + ], + [ + 123, + 341 + ], + [ + 282, + 497 + ], + [ + 475, + 583 + ], + [ + 57, + 475 + ], + [ + 357, + 585 + ], + [ + 126, + 657 + ], + [ + 215, + 354 + ], + [ + 358, + 660 + ], + [ + 430, + 639 + ], + [ + 433, + 452 + ], + [ + 251, + 398 + ], + [ + 330, + 486 + ], + [ + 493, + 583 + ], + [ + 190, + 632 + ], + [ + 247, + 492 + ], + [ + 73, + 666 + ], + [ + 186, + 553 + ], + [ + 126, + 282 + ], + [ + 506, + 548 + ], + [ + 384, + 621 + ], + [ + 293, + 565 + ], + [ + 327, + 425 + ], + [ + 298, + 506 + ], + [ + 73, + 436 + ], + [ + 343, + 363 + ], + [ + 483, + 548 + ], + [ + 445, + 524 + ], + [ + 55, + 369 + ], + [ + 378, + 453 + ], + [ + 48, + 564 + ], + [ + 393, + 477 + ], + [ + 119, + 634 + ], + [ + 347, + 464 + ], + [ + 165, + 359 + ], + [ + 221, + 292 + ], + [ + 374, + 557 + ], + [ + 584, + 620 + ], + [ + 488, + 570 + ], + [ + 476, + 670 + ], + [ + 162, + 636 + ], + [ + 232, + 620 + ], + [ + 226, + 313 + ], + [ + 506, + 551 + ], + [ + 2, + 394 + ], + [ + 210, + 483 + ], + [ + 134, + 209 + ], + [ + 181, + 375 + ], + [ + 38, + 431 + ], + [ + 542, + 547 + ], + [ + 0, + 646 + ], + [ + 56, + 543 + ], + [ + 394, + 591 + ], + [ + 157, + 556 + ], + [ + 381, + 667 + ], + [ + 37, + 180 + ], + [ + 0, + 535 + ], + [ + 458, + 523 + ], + [ + 161, + 491 + ], + [ + 213, + 322 + ], + [ + 295, + 631 + ], + [ + 46, + 537 + ], + [ + 23, + 347 + ], + [ + 51, + 235 + ], + [ + 361, + 535 + ], + [ + 251, + 333 + ], + [ + 181, + 561 + ], + [ + 447, + 571 + ], + [ + 377, + 545 + ], + [ + 146, + 324 + ], + [ + 356, + 563 + ], + [ + 80, + 318 + ], + [ + 129, + 211 + ], + [ + 396, + 660 + ], + [ + 429, + 580 + ], + [ + 52, + 288 + ], + [ + 384, + 592 + ], + [ + 300, + 583 + ], + [ + 215, + 308 + ], + [ + 344, + 647 + ], + [ + 190, + 526 + ], + [ + 232, + 381 + ], + [ + 11, + 392 + ], + [ + 331, + 450 + ], + [ + 321, + 353 + ], + [ + 194, + 373 + ], + [ + 276, + 304 + ], + [ + 80, + 325 + ], + [ + 390, + 650 + ], + [ + 308, + 676 + ], + [ + 26, + 88 + ], + [ + 78, + 400 + ], + [ + 5, + 59 + ], + [ + 77, + 277 + ], + [ + 452, + 675 + ], + [ + 91, + 414 + ], + [ + 57, + 513 + ], + [ + 430, + 658 + ], + [ + 220, + 293 + ], + [ + 179, + 268 + ], + [ + 571, + 573 + ], + [ + 28, + 277 + ], + [ + 51, + 472 + ], + [ + 449, + 509 + ], + [ + 220, + 251 + ], + [ + 221, + 571 + ], + [ + 162, + 639 + ], + [ + 90, + 207 + ], + [ + 297, + 324 + ], + [ + 219, + 251 + ], + [ + 196, + 542 + ], + [ + 420, + 497 + ], + [ + 277, + 356 + ], + [ + 156, + 544 + ], + [ + 346, + 455 + ], + [ + 370, + 646 + ], + [ + 42, + 559 + ], + [ + 146, + 232 + ], + [ + 455, + 636 + ], + [ + 38, + 583 + ], + [ + 312, + 569 + ], + [ + 364, + 473 + ], + [ + 62, + 433 + ], + [ + 34, + 393 + ], + [ + 450, + 561 + ], + [ + 402, + 511 + ], + [ + 469, + 563 + ], + [ + 274, + 540 + ], + [ + 114, + 651 + ], + [ + 411, + 458 + ], + [ + 153, + 450 + ], + [ + 374, + 492 + ], + [ + 179, + 415 + ], + [ + 200, + 419 + ], + [ + 322, + 495 + ], + [ + 126, + 461 + ], + [ + 340, + 626 + ], + [ + 76, + 439 + ], + [ + 431, + 440 + ], + [ + 406, + 534 + ], + [ + 188, + 407 + ], + [ + 450, + 603 + ], + [ + 494, + 580 + ], + [ + 26, + 653 + ], + [ + 274, + 276 + ], + [ + 10, + 302 + ], + [ + 431, + 670 + ], + [ + 143, + 187 + ], + [ + 179, + 221 + ], + [ + 285, + 493 + ], + [ + 38, + 114 + ], + [ + 221, + 559 + ], + [ + 41, + 627 + ], + [ + 120, + 416 + ], + [ + 128, + 549 + ], + [ + 368, + 635 + ], + [ + 596, + 631 + ], + [ + 199, + 553 + ], + [ + 305, + 442 + ], + [ + 134, + 327 + ], + [ + 292, + 641 + ], + [ + 343, + 436 + ], + [ + 76, + 198 + ], + [ + 131, + 634 + ], + [ + 85, + 660 + ], + [ + 26, + 199 + ], + [ + 251, + 586 + ], + [ + 379, + 538 + ], + [ + 223, + 655 + ], + [ + 54, + 642 + ], + [ + 192, + 642 + ], + [ + 427, + 594 + ], + [ + 121, + 522 + ], + [ + 356, + 642 + ], + [ + 22, + 442 + ], + [ + 337, + 529 + ], + [ + 45, + 293 + ], + [ + 31, + 323 + ], + [ + 47, + 348 + ], + [ + 220, + 576 + ], + [ + 606, + 635 + ], + [ + 88, + 601 + ], + [ + 305, + 327 + ], + [ + 223, + 406 + ], + [ + 229, + 671 + ], + [ + 444, + 499 + ], + [ + 308, + 561 + ], + [ + 194, + 463 + ], + [ + 357, + 666 + ], + [ + 37, + 594 + ], + [ + 191, + 432 + ], + [ + 366, + 370 + ], + [ + 357, + 430 + ], + [ + 46, + 469 + ], + [ + 39, + 502 + ], + [ + 113, + 446 + ], + [ + 205, + 483 + ], + [ + 202, + 524 + ], + [ + 322, + 348 + ], + [ + 25, + 386 + ], + [ + 381, + 524 + ], + [ + 311, + 443 + ], + [ + 222, + 663 + ], + [ + 169, + 220 + ], + [ + 35, + 475 + ], + [ + 94, + 549 + ], + [ + 156, + 517 + ], + [ + 25, + 118 + ], + [ + 308, + 576 + ], + [ + 468, + 660 + ], + [ + 15, + 550 + ], + [ + 18, + 469 + ], + [ + 380, + 617 + ], + [ + 107, + 154 + ], + [ + 303, + 527 + ], + [ + 24, + 98 + ], + [ + 3, + 301 + ], + [ + 308, + 571 + ], + [ + 247, + 354 + ], + [ + 467, + 593 + ], + [ + 72, + 392 + ], + [ + 390, + 584 + ], + [ + 247, + 277 + ], + [ + 344, + 549 + ], + [ + 309, + 403 + ], + [ + 285, + 298 + ], + [ + 101, + 330 + ], + [ + 445, + 548 + ], + [ + 88, + 181 + ], + [ + 228, + 659 + ], + [ + 584, + 674 + ], + [ + 19, + 169 + ], + [ + 37, + 591 + ], + [ + 77, + 353 + ], + [ + 293, + 587 + ], + [ + 115, + 509 + ], + [ + 51, + 452 + ], + [ + 273, + 488 + ], + [ + 132, + 586 + ], + [ + 179, + 637 + ], + [ + 37, + 154 + ], + [ + 221, + 331 + ], + [ + 214, + 501 + ], + [ + 357, + 498 + ], + [ + 1, + 200 + ], + [ + 115, + 508 + ], + [ + 586, + 663 + ], + [ + 120, + 323 + ], + [ + 232, + 431 + ], + [ + 188, + 621 + ], + [ + 291, + 296 + ], + [ + 221, + 463 + ], + [ + 331, + 564 + ], + [ + 435, + 519 + ], + [ + 543, + 668 + ], + [ + 229, + 251 + ], + [ + 298, + 315 + ], + [ + 344, + 661 + ], + [ + 173, + 366 + ], + [ + 70, + 524 + ], + [ + 0, + 416 + ], + [ + 515, + 570 + ], + [ + 79, + 216 + ], + [ + 292, + 475 + ], + [ + 439, + 617 + ], + [ + 161, + 363 + ], + [ + 0, + 467 + ], + [ + 0, + 440 + ], + [ + 219, + 299 + ], + [ + 134, + 298 + ], + [ + 193, + 247 + ], + [ + 298, + 531 + ], + [ + 309, + 422 + ], + [ + 118, + 602 + ], + [ + 73, + 345 + ], + [ + 154, + 164 + ], + [ + 340, + 509 + ], + [ + 345, + 354 + ], + [ + 55, + 133 + ], + [ + 200, + 432 + ], + [ + 325, + 361 + ], + [ + 16, + 443 + ], + [ + 26, + 442 + ], + [ + 447, + 464 + ], + [ + 399, + 492 + ], + [ + 97, + 382 + ], + [ + 205, + 567 + ], + [ + 465, + 659 + ], + [ + 307, + 671 + ], + [ + 313, + 544 + ], + [ + 195, + 431 + ], + [ + 398, + 663 + ], + [ + 63, + 596 + ], + [ + 40, + 510 + ], + [ + 7, + 169 + ], + [ + 26, + 41 + ], + [ + 519, + 576 + ], + [ + 214, + 633 + ], + [ + 182, + 341 + ], + [ + 298, + 620 + ], + [ + 31, + 517 + ], + [ + 198, + 209 + ], + [ + 547, + 662 + ], + [ + 274, + 486 + ], + [ + 312, + 627 + ], + [ + 24, + 553 + ], + [ + 140, + 656 + ], + [ + 300, + 651 + ], + [ + 389, + 574 + ], + [ + 493, + 675 + ], + [ + 175, + 507 + ], + [ + 157, + 427 + ], + [ + 201, + 428 + ], + [ + 126, + 548 + ], + [ + 282, + 450 + ], + [ + 133, + 373 + ], + [ + 116, + 333 + ], + [ + 367, + 405 + ], + [ + 445, + 463 + ], + [ + 92, + 517 + ], + [ + 28, + 420 + ], + [ + 19, + 634 + ], + [ + 570, + 656 + ], + [ + 350, + 399 + ], + [ + 344, + 546 + ], + [ + 405, + 527 + ], + [ + 595, + 600 + ], + [ + 62, + 436 + ], + [ + 327, + 412 + ], + [ + 512, + 565 + ], + [ + 10, + 412 + ], + [ + 202, + 311 + ], + [ + 71, + 584 + ], + [ + 284, + 359 + ], + [ + 214, + 268 + ], + [ + 73, + 460 + ], + [ + 80, + 486 + ], + [ + 45, + 220 + ], + [ + 222, + 374 + ], + [ + 292, + 640 + ], + [ + 169, + 422 + ], + [ + 131, + 582 + ], + [ + 28, + 525 + ], + [ + 165, + 463 + ], + [ + 543, + 583 + ], + [ + 7, + 48 + ], + [ + 39, + 356 + ], + [ + 440, + 675 + ], + [ + 313, + 656 + ], + [ + 34, + 210 + ], + [ + 407, + 475 + ], + [ + 284, + 346 + ], + [ + 94, + 195 + ], + [ + 371, + 574 + ], + [ + 333, + 493 + ], + [ + 406, + 649 + ], + [ + 47, + 408 + ], + [ + 228, + 522 + ], + [ + 5, + 15 + ], + [ + 449, + 519 + ], + [ + 386, + 566 + ], + [ + 390, + 433 + ], + [ + 323, + 384 + ], + [ + 214, + 323 + ], + [ + 528, + 630 + ], + [ + 419, + 468 + ], + [ + 511, + 593 + ], + [ + 32, + 369 + ], + [ + 459, + 633 + ], + [ + 318, + 483 + ], + [ + 553, + 597 + ], + [ + 18, + 671 + ], + [ + 307, + 528 + ], + [ + 7, + 38 + ], + [ + 141, + 169 + ], + [ + 107, + 139 + ], + [ + 449, + 465 + ], + [ + 130, + 530 + ], + [ + 291, + 508 + ], + [ + 173, + 322 + ], + [ + 56, + 328 + ], + [ + 427, + 430 + ], + [ + 298, + 575 + ], + [ + 445, + 600 + ], + [ + 361, + 638 + ], + [ + 193, + 374 + ], + [ + 307, + 356 + ], + [ + 156, + 661 + ], + [ + 78, + 216 + ], + [ + 40, + 558 + ], + [ + 598, + 659 + ], + [ + 284, + 290 + ], + [ + 318, + 386 + ], + [ + 379, + 583 + ], + [ + 214, + 621 + ], + [ + 199, + 302 + ], + [ + 24, + 567 + ], + [ + 156, + 559 + ], + [ + 100, + 582 + ], + [ + 16, + 403 + ], + [ + 28, + 575 + ], + [ + 469, + 671 + ] + ], + "oracle": { + "HiGHS/1/10": { + "seconds": 7.129505744999733, + "samples": [ + 8.886320064000756, + 6.158689443000185, + 7.129505744999733 + ], + "mismatches": 0 + }, + "HiGHS/8/10": { + "seconds": 1.654459665000104, + "samples": [ + 1.3368080950003787, + 1.654459665000104, + 1.8946357679997163 + ], + "mismatches": 0 + }, + "COIN_CMD/1/10": { + "seconds": 9.32507071999953, + "samples": [ + 73.7794249260005, + 8.249845851000828, + 9.32507071999953 + ], + "mismatches": 0 + }, + "COIN_CMD/8/10": { + "seconds": 12.382717059999777, + "samples": [ + 12.382717059999777, + 20.120375993999914, + 11.958619098000781 + ], + "mismatches": 0 + }, + "HiGHS/1/-1": { + "seconds": 29.680910590499934, + "samples": [ + 35.25659019199975, + 24.10523098900012 + ], + "mismatches": 0 + }, + "HiGHS/8/-1": { + "seconds": 5.184104155000568, + "samples": [ + 6.2718258830000195, + 4.265475667999453, + 5.184104155000568 + ], + "mismatches": 0 + }, + "COIN_CMD/1/-1": { + "seconds": 106.01074918649965, + "samples": [ + 147.9938804049998, + 64.0276179679995 + ], + "mismatches": 0 + }, + "COIN_CMD/8/-1": { + "seconds": 25.373941111500244, + "samples": [ + 26.23115648700059, + 24.5167257359999 + ], + "mismatches": 0 + } + }, + "filters": { + "checked_per_filter": 1000, + "filter1_mismatches": 0, + "filter2_mismatches": 0, + "threshold_10_survivors": 371, + "unmodified_assignment_certificates_at_10": 10, + "filter2_equals_optimum": 450 + }, + "threshold_10": { + "numba_cpu": { + "seconds": [ + 0.011372221999408794, + 0.01140263999968738, + 0.01271991599969624, + 0.01011636999919574, + 0.012473482999666885 + ], + "median_seconds": 0.01140263999968738, + "checked": 1000, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 38 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 36 + ] + }, + "exact": 289, + "max_absolute_error": 7.549516567451064e-14, + "routing": { + "filter_rejections": 629, + "map_certificates": 110, + "search_proofs": 253, + "objective_bound_rejections": 8, + "fallbacks": 0 + } + }, + "cuda": { + "seconds": [ + 0.017206348999934562, + 0.01766060699992522, + 0.017939266999746906, + 0.019439021999460238, + 0.018971200000123645 + ], + "median_seconds": 0.017939266999746906, + "checked": 1000, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 38 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 40 + ] + }, + "exact": 289, + "max_absolute_error": 7.549516567451064e-14, + "routing": { + "filter_rejections": 629, + "map_certificates": 110, + "search_proofs": 253, + "objective_bound_rejections": 8, + "fallbacks": 0 + } + }, + "speedup": { + "numba_cpu_8": 0.6356246328151676, + "HiGHS/1/10": 397.42458513496223, + "HiGHS/8/10": 92.2256001331295, + "COIN_CMD/1/10": 519.8133636190984, + "COIN_CMD/8/10": 690.2576933703299 + } + }, + "unrestricted": { + "numba_cpu": { + "seconds": [ + 0.05155169699992257, + 0.05361504699976649, + 0.050704808999398665, + 0.047332309000012174, + 0.049440283999501844 + ], + "median_seconds": 0.050704808999398665, + "checked": 1000, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 40 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 38 + ] + }, + "exact": 1000, + "max_absolute_error": 1.659117287999834e-12, + "routing": { + "filter_rejections": 0, + "map_certificates": 358, + "search_proofs": 641, + "objective_bound_rejections": 0, + "fallbacks": 1 + } + }, + "cuda": { + "seconds": [ + 0.1858823989996381, + 0.18171271699975478, + 0.18923100200026965, + 0.17824832599944784, + 0.17759525800011033 + ], + "median_seconds": 0.18171271699975478, + "checked": 1000, + "mismatches": 0, + "load_before": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 39 + ] + }, + "load_after": { + "other_compute_clients": 1, + "sampled_other_sm_percent": [ + 14 + ] + }, + "exact": 1000, + "max_absolute_error": 1.659117287999834e-12, + "routing": { + "filter_rejections": 0, + "map_certificates": 358, + "search_proofs": 641, + "objective_bound_rejections": 0, + "fallbacks": 1 + } + }, + "speedup": { + "numba_cpu_8": 0.2790383074810724, + "HiGHS/1/-1": 163.33975453429596, + "HiGHS/8/-1": 28.52912135482276, + "COIN_CMD/1/-1": 583.3975240524454, + "COIN_CMD/8/-1": 139.63767385380345 + } + } + } + }, + "smiles": [ + "C/C(O)=N/CC(=O)O", + "C/C(O)=N/CCCCN", + "C/C(O)=N/CCCCNCCCN", + "C/C(O)=N/[C@@H](CCCN)C(=O)O", + "C/C1=C\\CC(=O)/C(C)=C/C2C(CC/C(C)=C/CC1)C2(C)C", + "C/N=C(\\O)c1cccnc1", + "C1CCN2CC3CC(CN4CCCCC34)C2C1", + "C=C(C)C1CC=C(C)C(=O)C1", + "C=C(C)C1CCC2(C)CCC(=O)C(C)=C2C1", + "C=C(C)C1CCC2=CC(=O)CC(C)C2(C)C1", + "C=C(C)[C@H]1CC=C(C)CC1", + "C=C(OP(=O)(O)O)C(=O)O", + "C=C1C(=O)C23C(O)CC4C(C)(C)C(=O)CCC4(C)C2CCC1C3O", + "C=C1CCC2C(C)(CO)C(O)CCC2(C)C1CCC1=CCOC1=O", + "C=C1CCC=C(C)CCC2C1CC2(C)C", + "C=C1CC[C@]2(C(C)C)C[C@H]12", + "C=CC(=C)CCC=C(C)C", + "C=CC(=C)CCC=C(C)CCC=C(C)C", + "C=CC(=O)NC(C)(C)CC(C)=O", + "C=CC(N)CCC(=O)O", + "C=CCCCCCCCCC(=O)NC(CCCC(=O)O)C(=O)O", + "C=CCCCCCCCCCC(=O)NCCCC(=O)O", + "C=CCS(=O)C[C@H](N)C(=O)O", + "C=CCc1ccc(OC)c(OC)c1", + "C=Cc1ccc(O)c(OC)c1", + "C=Cc1cncc2c1CCOC2=O", + "CC(=CC(=O)O)C(=O)O", + "CC(=CC(=O)O)CC(=O)O", + "CC(=CCC(=O)O)C(=O)O", + "CC(=CCNc1nc[nH]c2ncnc1-2)CO", + "CC(=CCNc1ncnc2nc[nH]c12)CO", + "CC(=O)C(=O)O", + "CC(=O)C(C)=O", + "CC(=O)C1=C(O)C=C2Oc3c(C(C)=O)c(O)c(C)c(O)c3C2(C)C1=O", + "CC(=O)C=Cc1ccccc1", + "CC(=O)CC(=O)CCC(=O)O", + "CC(=O)CC(O)c1ccccn1", + "CC(=O)CCCC(=O)O", + "CC(=O)N1CCC(C(=O)O)CC1", + "CC(=O)N1CSCC1C(=O)O", + "CC(=O)NC(CCC(=O)O)C(=O)O", + "CC(=O)NC(CCCN)C(=O)O", + "CC(=O)NC(CO)C(=O)O", + "CC(=O)NCCC(=O)O", + "CC(=O)NCCCC(=O)O", + "CC(=O)NCCCCN", + "CC(=O)NCCCCNCCCN", + "CC(=O)NCCCC[C@H](N)C(=O)O", + "CC(=O)N[C@@H](CC(C)C)C(=O)O", + "CC(=O)N[C@@H]1[C@@H](O)[C@H](O)[C@@H](CO)O[C@@H]1O", + "CC(=O)N[C@H]1C(O)O[C@H](CO)[C@@H](O)[C@@H]1O[C@H](C)C(=O)O", + "CC(=O)Nc1ccc(C)c(Cl)c1", + "CC(=O)O", + "CC(=O)OCC(C)C", + "CC(=O)OCC[N+](C)(C)C", + "CC(=O)OC[C@H](N)C(=O)O", + "CC(=O)Oc1ccccc1", + "CC(=O)Oc1ccccc1C(=O)O", + "CC(=O)c1c(O)c(C)c(O)c2c1OC1=CC(=O)C(C(C)=O)C(=O)C12C", + "CC(=O)c1c(O)cc(O)cc1O", + "CC(=O)c1c(O)cccc1O", + "CC(=O)c1ccc(O)c(O)c1O", + "CC(=O)c1ccc(O)cc1O", + "CC(=O)c1cccc(N)c1", + "CC(C)(C)C(=O)C(Oc1ccc(Cl)cc1)n1ccnc1", + "CC(C)(C)c1ccc(C(=O)O)cc1", + "CC(C)(O)C#Cc1ccccn1", + "CC(C)(O)C(O)COc1c2occc2cc2ccc(=O)oc12", + "CC(C)(O)C(O)Cc1cc2ccc(=O)oc2cc1O", + "CC(C)(O)C1Cc2cc3ccc(=O)oc3cc2O1", + "CC(C)/N=c1\\[nH]c(O)nc(=N)[nH]1", + "CC(C)=CC(=O)O", + "CC(C)=CCCC(C)=CCO", + "CC(C)=CCCC(C)CC=O", + "CC(C)=CCc1c(O)ccc2ccc(=O)oc12", + "CC(C)C(O)=NCC(O)=NCC(=O)O", + "CC(C)C/C(O)=N/CC(=O)O", + "CC(C)CC(=O)C(=O)O", + "CC(C)CC(=O)O", + "CC(C)CC(N)C(=O)O", + "CC(C)CCC(=O)O", + "CC(C)CCN1C(=O)C(C)N=C1O", + "CC(C)C[C@@H]1NC(=O)[C@@H]2CCCN2C1=O", + "CC(C)C[C@H](N)C(=O)NCC(=O)O", + "CC(C)C[C@H](N)C(=O)O", + "CC(C)C[C@H](NC(=O)CN)C(=O)O", + "CC(C)N(C(=O)C(=O)O)c1ccc(F)cc1", + "CC(C)Nc1ccc(Nc2ccccc2)cc1", + "CC(C)Nc1nc(N)nc(Cl)n1", + "CC(C)Nc1nc(NC(C)C)[nH]c(=O)n1", + "CC(C)Oc1ccc(C(=O)O)cn1", + "CC(C)[C@H](/N=C(/O)CN)C(=O)O", + "CC(C)[C@H](N)C(=O)O", + "CC(C)c1cc2c(c(O)c1O)C13CCCC(C)(C)C1C(OC3=O)C2O", + "CC(C)c1ccc(N)cc1", + "CC(C)c1ccc2c(c1O)CCC1C3=C(CCC21C)C(=O)OC3", + "CC(CC(=O)O)CC(=O)O", + "CC(CC(=O)O)c1ccccc1", + "CC(N)(Cc1cnc[nH]1)C(=O)O", + "CC(N)Cc1ccccc1", + "CC(O)(CC(=O)O)C(=O)O", + "CC(O)(CC(=O)O)CC(=O)O", + "CC(O)C(N)C(=O)O", + "CC/C=C\\CC1CCCC(=O)O1", + "CC/C=C\\C[C@H]1C(=O)CC[C@@H]1CC(=O)OC", + "CC1(C(O)CO)C=C2CCC3C(C)(C)C(O)CCC3(C)C2CC1", + "CC1(C)C=Cc2c(ccc3c2OCC(c2ccc(O)cc2O)C3)O1", + "CC1(C)OC2C(=O)OC(CO)C2O1", + "CC1(C)SC2C(NC(=O)C(N)c3ccccc3)C(=O)N2C1C(=O)O", + "CC1(C)S[C@@H]2[C@H](/N=C(\\O)[C@H](N)c3ccccc3)C(=O)N2[C@H]1C(=O)O", + "CC1=C(/C=C/C(C)=C/C=C/C(C)=C/C(=O)O)C(C)(C)CCC1", + "CC1=C(/C=C/C(C)=C/C=C/C(C)=C/C=O)C(C)(C)CCC1", + "CC1=CC(=O)C=CC1=O", + "CC1=CC(=O)CC(C)(C)C1", + "CC1=CC(=O)c2ccccc2C1=O", + "CC=C(C)C(=O)NCC(=O)O", + "CC=C(C)C(=O)OC(=O)C(C)=CC", + "CC=C(C)C(=O)OC1Cc2cc3ccc(=O)oc3cc2OC1(C)C", + "CC=CC=CC(=O)O", + "CCC(=O)O", + "CCC(C(=O)O)c1ccccc1", + "CCC(C(N)=O)N1CCCC1=O", + "CCC(C)(CC)c1cc(NC(=O)c2c(OC)cccc2OC)on1", + "CCC(C)/C(O)=N/CC(=O)O", + "CCC(C)C(=O)NCC(=O)O", + "CCC(C)C(N)C(=O)NC(CO)C(=O)O", + "CCC(C)COC(=O)C(C)CC", + "CCC(CC)O[C@@H]1C=C(C(=O)O)C[C@H](N)[C@H]1NC(C)=O", + "CCC(N)C(=O)O", + "CCC(O)C(=O)O", + "CCC/C(O)=N/CC(=O)O", + "CCCC(=O)CC", + "CCCC(=O)O", + "CCCC(CCC)C(=O)O", + "CCCC(N=C(O)C(C)N)C(=O)O", + "CCCCC(=O)NCC(=O)O", + "CCCCC(O)C(=O)O", + "CCCCC/C=C/C/C=C/CCCCCCCC(=O)O", + "CCCCCC(=O)CC(=O)NC1CCOC1=O", + "CCCCCC(=O)NCC(=O)O", + "CCCCCC(=O)O", + "CCCCCC(=O)OCC(C)C", + "CCCCCC/C=C/CCCCCCCC(=O)O", + "CCCCCC1=C(C)CCC1=O", + "CCCCCC=CCC=CCC=CCCCCC(=O)O", + "CCCCCCCCC=CCCCCCCCC(=O)O", + "CCCCCCCCCC(=O)O", + "CCCCCCCCCCC(=O)CCCC(=O)O", + "CCCCCCCCCCCCCC(=O)OCC(O)CO", + "CCCCCCCCCCCCCCCCCCCCCCC", + "CCCCCCCCCCCCCCCCCO", + "CCCCCCCCCCCCOC(=O)c1cc(O)c(O)c(O)c1", + "CCCCCCCCOC(=O)c1cc(O)c(O)c(O)c1", + "CCCCCCCCOC(C)=O", + "CCCCN(CCCC)CCCC", + "CCCCOc1ccc(N)cc1", + "CCCC[C@H](N)C(=O)O", + "CCCCc1ccc(C(=O)O)nc1", + "CCCCn1c(=O)c(C(O)=Nc2nccs2)c(O)c2ccccc21", + "CCCN(CCOc1c(Cl)cc(Cl)cc1Cl)C(=O)n1ccnc1", + "CCCNC(=O)c1c(N=C(O)c2ccc3c(c2)OCCO3)cnn1C", + "CCCOC(=O)C(N)CCSC", + "CCCOC(=O)NCCCN(C)C", + "CCCOC(=O)c1cc(O)c(O)c(O)c1", + "CCCSP(=O)(OCC)SCCC", + "CCC[C@H](N)C(=O)O", + "CCN(C)C(=C[N+](=O)[O-])NCc1ccc(Cl)nc1", + "CCN(CC)CCNC(=O)c1cc(Cl)c(N)cc1OC", + "CCN(CC)CCNC(=O)c1cc(S(C)(=O)=O)ccc1OC", + "CCN(CC)Cc1ccccc1", + "CCN1CCCC1CNC(=O)c1cc(S(N)(=O)=O)ccc1OC", + "CCNC(=O)NC(=O)C(C#N)=NOC", + "CCNc1nc(Cl)nc(NC(C)(C)C#N)n1", + "CCNc1nc(Cl)nc(NCC)n1", + "CCNc1nc(NC(C)C)[nH]c(=O)n1", + "CCOC(=O)C(N)CCSC", + "CCOC(=O)C1=C[C@@H](OC(CC)CC)[C@H](NC(C)=O)[C@@H](N)C1", + "CCOC(=O)CCC(O)=NN=C(O)Cc1ccc(Cl)cc1", + "CCOC(=O)Cn1ccc(=NC(=O)c2ccc3c(c2)OCO3)[nH]1", + "CCOC(=O)c1ccc(O)cc1", + "CCOP(O)(=S)OCC", + "CCOc1ccc(NC(C)=O)cc1", + "CCOc1ccc(NC(N)=O)cc1", + "CC[C@H](C)[C@@H]1NC(=O)[C@H](C)NC1=O", + "CC[C@H](C)[C@H](N)C(=O)N[C@@H](CC(C)C)C(=O)O", + "CC[C@H](C)[C@H](N)C(=O)O", + "CCc1cc(C(N)=S)ccn1", + "CN(C)C(=N)N=C(N)N", + "CN(C)C(=N)NC(=N)N", + "CN(C)C(=O)Nc1ccc(Cl)c(Cl)c1", + "CN(C)C1CSSSC1", + "CN(C)CCc1ccc(O)cc1", + "CN(C)Cc1c[nH]c2ccccc12", + "CN(C)S(=O)(=O)Nc1ccccc1", + "CN(C)S(N)(=O)=O", + "CN(C)c1ccc(SC#N)cc1", + "CN(C)c1cccc(Br)c1", + "CN(C1CCCCC1)S(=O)(=O)c1ccccc1N", + "CN(CC(=O)O)C(=N)N", + "CN1C(=O)CCC1c1cccnc1", + "CN1C(=O)CC[C@H]1c1cccnc1", + "CN1CC(O)=NC1=N", + "CN1CC(O)=NC1=O", + "CN1CCC(OC(=O)c2cc3cc([N+](=O)[O-])ccc3oc2=O)CC1", + "CN1CCC[C@H]1c1cccnc1", + "CN1CCN(C)C1=O", + "CN1Cc2c(ccc3c2OCO3)-c2ccc3cc4c(cc3c21)OCO4", + "CN1[C@@H]2CC[C@H]1C[C@H](O)C2", + "CN1c2ccccc2C(=O)N2CCc3c([nH]c4ccccc34)C21", + "CN=CNc1ccc(C)cc1C", + "CNC(=O)CSP(=O)(OC)OC", + "CNC(=O)CSP(=S)(OC)OC", + "CNC(Cc1c[nH]c2ccccc12)C(=O)O", + "CNC1(C)C2CCC(C2)C1(C)C", + "CNCC(O)C(O)C(O)C(O)CO", + "CNCC(O)c1ccc(O)c(O)c1", + "CNCC(O)c1ccc(O)cc1", + "CNCCc1c[nH]c2ccccc12", + "CNCCc1ccc(O)c(O)c1", + "CNCCc1ccc(O)cc1", + "CNC[C@H](O)c1ccc(O)c(O)c1", + "CN[C@@H](CCC(=O)O)C(=O)O", + "CN[C@H](CC(=O)O)C(=O)O", + "CNc1ccc(Cl)cc1", + "CNc1ccccc1C(=O)O", + "COC(=O)C(N)Cc1c[nH]c2ccccc12", + "COC(=O)C1=CCC[NH+](C)C1.[Br-]", + "COC(=O)CC(OC(=O)/C=C/c1cc(OC)c(O)c(OC)c1)C(=O)O", + "COC(=O)c1cc(O)c(O)c(O)c1", + "COC1=C(OC)C(=O)C(C)=CC1=O", + "COCC(=O)N(c1c(C)cccc1C)C(C)C(=O)OC", + "COCC(=O)N(c1c(C)cccc1C)N1CCOC1=O", + "COP(=O)(NC(C)=O)SC", + "COc1c(Br)cc(Br)cc1Oc1c(O)cc(Br)cc1Br", + "COc1c(C=CC(=O)c2ccc(O)cc2)ccc(O)c1O", + "COc1c(Cl)ccc(Cl)c1C(=O)O", + "COc1c2c(cc3ccc(=O)oc13)C=CC(C)(C)O2", + "COc1c2ccoc2c(OCC(O)C(C)(C)O)c2oc(=O)ccc12", + "COc1c2occc2cc2ccc(=O)oc12", + "COc1cc(/C=C/C(=O)O)cc(OC)c1O", + "COc1cc(/C=C/C(=O)O)cc(OC)c1OC", + "COc1cc(/C=C/C=O)ccc1O", + "COc1cc(C(=O)CCNc2ccc(F)c(Cl)c2)cc(OC)c1OC", + "COc1cc(C(=O)CCNc2ccc(I)cc2)cc(OC)c1OC", + "COc1cc(C(=O)O)ccc1O", + "COc1cc(C(O)=NC(C(=O)O)C(C)C)cc(OC)c1OC", + "COc1cc(C(O)=Nc2cccnc2)cc(OC)c1OC", + "COc1cc(C(O)CN)ccc1O", + "COc1cc(C=CC(=O)O)cc(OC)c1", + "COc1cc(C=CC(=O)OC(CC(=O)O)C(=O)O)cc(OC)c1O", + "COc1cc(C=CCO)cc(OC)c1O", + "COc1cc(C=O)ccc1O", + "COc1cc(CC(=O)O)ccc1O", + "COc1cc(CCC(C)=O)ccc1O", + "COc1cc(NS(=O)(=O)c2ccc(N)cc2)nc(OC)n1", + "COc1cc(O)c2c(c1)C(=O)c1cc(C)cc(O)c1C2=O", + "COc1cc(O)c2c(c1)C1=CC(O)C(O)CC1(C)OC2=O", + "COc1cc(O)cc(O)c1C(=O)C=Cc1ccccc1", + "COc1cc(O)ccc1C=CC(=O)c1ccc(O)cc1", + "COc1cc(OC)c(C(=O)/C=C/c2ccccc2)c(OC)c1", + "COc1cc(OC)c(C(C)=O)c2c1C=CC(C)(C)O2", + "COc1cc(OC)nc(NS(=O)(=O)c2ccc(NC(C)=O)cc2)n1", + "COc1cc2c(cc1O)CC1NCCc3cc(O)c(OC)c-2c31", + "COc1cc2c3c(c1OC)C1(C=CC(=O)C=C1)CC3NCC2", + "COc1ccc(-c2cc(=O)c3ccc(O)cc3o2)cc1OC", + "COc1ccc(-c2coc3cc(O)ccc3c2=O)cc1", + "COc1ccc(-c2coc3cc(O)ccc3c2=O)cc1O", + "COc1ccc(-c2coc3cc(O)ccc3c2=O)cc1OC", + "COc1ccc(/C=C/C(=O)O)cc1", + "COc1ccc(/C=C/c2cc(O)cc(O)c2)cc1O", + "COc1ccc(C(=O)CCNc2ccc(C(=O)O)cc2)cc1OC", + "COc1ccc(C(=O)O)cc1OC", + "COc1ccc(C(C)=O)c(O)c1", + "COc1ccc(C(C)=O)c(O)c1O", + "COc1ccc(C(C)=O)cc1", + "COc1ccc(C2COc3cc(O)ccc3C2)c(O)c1", + "COc1ccc(C=O)cc1", + "COc1ccc(NC(C)=O)cc1N", + "COc1ccc(O)c(C(=O)O)c1", + "COc1ccc2[nH]c(=O)c3c(c2c1)OC(C)(C)C=C3", + "COc1ccc2c(=O)cc(-c3ccc(OC)c(OC)c3)oc2c1", + "COc1ccc2c(c1)[nH]c1c(C)nccc12", + "COc1ccc2ccc(=O)oc2c1", + "COc1ccc2ccc(=O)oc2c1CC=C(C)C", + "COc1ccc2nc(N)sc2c1", + "COc1cccc(C=CC(=O)O)c1", + "COc1coc(CO)cc1=O", + "COc1nc(C)nc(N)n1", + "CS(=N)(=O)CCC(N)C(=O)O", + "CS(=O)(=O)NC(Cc1c[nH]c2ccccc12)C(=O)O", + "CS(=O)(=O)O", + "CS(=O)C=CCCN=C=S", + "CS(=O)CCCCCCCCC#N", + "CS(=O)CC[C@H](N)C(=O)O", + "CSCCC(N=C(C)O)C(=O)O", + "CSCCC(NC(C)=O)C(=O)O", + "CSCCC(NC=O)C(=O)O", + "CSCCC(O)C(=O)O", + "CSCC[C@H](N)C(=O)O", + "CSCC[C@H](NC=O)C(=O)O", + "CSc1nc(=O)c(C(C)(C)C)n[nH]1", + "CSc1ncnc2[nH]cnc12", + "C[C@@H](O)CC(=O)O", + "C[C@@H](O)[C@H](N)C(=O)O", + "C[C@@H]1OC(O)[C@@H](O)[C@H](O)[C@@H]1O", + "C[C@H](N)[C@@H](O)c1ccccc1", + "C[C@H](O)[C@H](N)C(=O)O", + "C[N+](C)(C)CC(=O)[O-]", + "C[N+](C)(C)CC(O)CC(=O)[O-]", + "C[N+](C)(C)CCCC(=O)[O-]", + "C[N+](C)(C)CCCC[C@H](N)C(=O)[O-]", + "C[N+](C)(C)CCO", + "C[N+](C)(C)C[C@H](O)CC(=O)[O-]", + "C[N+]1(C)CCCC1C(=O)[O-].Cl", + "C[N+]1(C)C[C@H](O)C[C@H]1C(=O)[O-]", + "C[NH2+]C(C)C(O)c1ccccc1", + "C[n+]1cc2c3c(ccc2c2ccc4cc5c(cc4c21)OCO5)OCO3", + "C[n+]1cccc(C(=N)O)c1", + "C[n+]1cccc(C(=O)O)c1.[Cl-]", + "Cc1[nH]c2c(C)ccc(F)c2c1CCNC(=O)c1ccc(Br)cc1", + "Cc1c(C)c2cc3c(-c4ccc(F)cc4)coc3c(C)c2oc1=O", + "Cc1c[nH]c(=O)[nH]c1=O", + "Cc1cc(=O)oc2ccc(O)cc12", + "Cc1cc(C)nc(N)n1", + "Cc1cc(Cl)cc(Cl)c1O", + "Cc1cc(Cl)ccc1O", + "Cc1cc(Cl)ccc1OCC(=O)O", + "Cc1cc(O)c(C)c(O)c1C(=O)O", + "Cc1cc(O)cc(=O)o1", + "Cc1ccc(C(=O)NCCc2c(C)[nH]c3ccc(C)cc23)cc1", + "Cc1ccc(C(C)C)c(O)c1", + "Cc1ccc(N)c(S(=O)(=O)O)c1", + "Cc1ccc(NC(=O)N(C)C)cc1Cl", + "Cc1ccc(S(N)(=O)=O)cc1", + "Cc1ccc([N+](=O)[O-])cc1S(=O)(=O)O", + "Cc1ccc2[nH]nnc2c1", + "Cc1ccc2ccc3ccc(C)nc3c2n1", + "Cc1ccc2oc(=O)ccc2c1", + "Cc1cccc(Nc2ccccc2)c1", + "Cc1cn([C@@H]2O[C@H](CO)[C@@H](O)[C@H]2O)c(=O)[nH]c1=O", + "Cc1cnc(=O)[nH]c1N", + "Cc1cnc(O)[nH]c1=N", + "Cc1coc2c1c(C)cc1oc(=O)cc(-c3ccccc3)c12", + "Cc1nc(N)nc(O)c1CC(=O)O", + "Cc1nc(O)c2ccccc2n1", + "Cc1ncc(CO)c(C(=O)O)c1O", + "Cc1ncc(CO)c(C=O)c1O", + "Cc1ncc([N+](=O)[O-])n1C", + "Cc1ncc([N+](=O)[O-])n1CC(C)O", + "Cc1nccc2c1[nH]c1cc(O)ccc12.Cl.O.O", + "Cc1ncsc1CCO", + "Cc1occc(=O)c1O", + "Clc1ccccc1N1CCNCC1", + "Cln1nnc2ccccc21", + "Cn1c(=O)c2[nH]cnc2n(C)c1=O", + "Cn1c(=O)c2c(ncn2C)n(C)c1=O", + "Cn1c(=O)c2nc[nH]c2n(C)c1=O", + "Cn1c(N)nc2nc[nH]c2c1=O", + "Cn1c(O)nc2ncn(C)c2c1=O", + "Cn1ccnc1S", + "Cn1cnc(CCN)c1", + "Cn1cnc(N)c2ncnc1-2", + "Cn1cnc2[nH]c(=O)[nH]c(=O)c21", + "Cn1cnc2c1c(=O)[nH]c(=O)n2C", + "Cn1cnc2nc(N)[nH]c(=O)c21", + "Cn1ncc(N)c(Cl)c1=O", + "N#CCc1c[nH]c2ccccc12", + "N#Cc1cc(I)c(O)c(I)c1", + "N#Cc1cc2c(nc1O)CCC2", + "N#Cc1cccnc1", + "N=C(N)NCC(=O)O", + "N=C(N)NCCCC(=O)O", + "N=C(N)NCCCCN", + "N=C(N)NCCCC[C@H](N)C(=O)O", + "N=C(N)NCCC[C@H](N)C(=O)O", + "N=C(N)N[C@@H](CC(=O)O)C(=O)O", + "N=C(O)CCCCC1CCSS1", + "N=C(O)CC[C@H](N)C(=O)O", + "N=C(O)Cc1c[nH]c2ccccc12", + "N=C(O)NCCC(=O)O", + "N=C(O)c1ccccc1O", + "N=C(O)c1cccnc1", + "N=c1nc(O)c2nccnc2[nH]1", + "NC(=O)C(c1ccccc1)C1CCCCN1", + "NC(=O)CCCCC1CCSS1", + "NC(=O)Cc1c[nH]c2ccccc12", + "NC(=O)N1CCCC1C(=O)O", + "NC(=O)N1c2ccccc2C=Cc2cc(O)ccc21", + "NC(=O)N1c2ccccc2C=Cc2ccccc21", + "NC(=O)NC(CCC(=O)O)C(=O)O", + "NC(=O)NC(NC(N)=O)C(=O)O", + "NC(=O)NC1NC(=O)NC1=O", + "NC(=O)NCCCC(=O)O", + "NC(=O)NCCCC(N)C(=O)O", + "NC(=O)NCCC[C@H](N)C(=O)O", + "NC(=O)N[C@@H](CCC(=O)O)C(=O)O", + "NC(=O)Nc1ccc(Cl)c(Cl)c1", + "NC(=O)Nc1ccc(Cl)cc1", + "NC(=O)c1ccccc1O", + "NC(=O)c1cccnc1", + "NC(CCC(=O)O)C(=O)O", + "NC(CCC(O)=Nc1cccc2ccccc12)C(=O)O", + "NC(CCCC(N)C(=O)O)C(=O)O", + "NC(CO)C(=O)O", + "NC(CO)Cc1cnc[nH]1", + "NC(COP(=O)(O)O)C(=O)O", + "NC(CP(=O)(O)O)C(=O)O", + "NC(CS)C(=O)NCC(=O)O", + "NC(CS)C(=O)O", + "NC(Cc1c[nH]c2ccccc12)C(=O)O", + "NC(Cc1ccc(O)cc1)C(=O)O", + "NC(Cc1cccc(F)c1)C(=O)O", + "NC(Cc1ccccc1)C(=O)O", + "NC(Cc1cnc[nH]1)C(=O)O", + "NC(N)=NCC(=O)O", + "NC(N)=NCCC[C@H](N)C(=O)O", + "NC1(C(=O)O)CC1", + "NC1(CC(=O)O)CCOCC1", + "NC1=NCCN1Cc1ccc(Cl)nc1", + "NC1CCSC1=O", + "NCC(=O)NCC(=O)O", + "NCC(=O)O", + "NCC(N)C(=O)O", + "NCC1(CC(=O)O)CCCCC1", + "NCC1CCCN2CCCCC12", + "NCCC(=O)O", + "NCCCCC(=O)O", + "NCCCCC(N)C(=O)O", + "NCCCCCN", + "NCCCC[C@H](N)C(=O)O", + "NCCCN", + "NCCOc1c(Cl)cc(Cl)cc1Cl", + "NCCS(=O)(=O)O", + "NCCc1c[nH]c2ccc(O)cc12", + "NCCc1ccc(O)c(O)c1", + "NCCc1ccc(O)cc1", + "NCP(=O)(O)O", + "NC[C@H](CC(=O)O)c1ccc(Cl)cc1", + "NC[C@H](O)CC[C@H](N)C(=O)O", + "NC[C@H](O)c1ccc(O)c(O)c1", + "NCc1cc(=O)[nH]o1", + "NS(=O)(=O)c1cc(C(=O)O)c(NCc2ccco2)cc1Cl", + "NS(=O)(=O)c1ccccc1", + "N[C@@H](CC(=O)O)C(=O)O", + "N[C@@H](CC(=O)O)Cc1ccccc1", + "N[C@@H](CCC(=O)O)C(=O)O", + "N[C@@H](CO)C(=O)O", + "N[C@@H](COS(=O)(=O)O)C(=O)O", + "N[C@@H](Cc1c[nH]c2ccccc12)C(=O)O", + "N[C@@H](Cc1ccc(Br)cc1)C(=O)O", + "N[C@@H](Cc1ccc(O)cc1)C(=O)O", + "N[C@@H](Cc1ccccc1)C(=O)O", + "N[C@@H](Cc1cnc[nH]1)C(=O)O", + "N[C@@H]1C(O)O[C@H](CO)[C@@H](O)[C@@H]1O", + "N[C@@H]1[C@@H](O)[C@@H](O[C@@H]2[C@@H](O)[C@H](O)[C@@H](N)C[C@H]2N)O[C@H](CO)[C@H]1O", + "N[C@H](C=O)[C@@H](O)[C@H](O)[C@H](O)CO", + "N[C@H](CC(=O)O)C(=O)O", + "N[C@H](CCC(=O)O)C(=O)O", + "N[C@H](CO)Cc1cnc[nH]1", + "N[C@H]1C(O)O[C@H](CO)[C@@H](O)[C@@H]1O", + "Nc1c(O)cccc1C(=O)O", + "Nc1cc(C(=O)O)ccc1O", + "Nc1cc(N2CCCCC2)nc(N)[n+]1[O-]", + "Nc1cc([N+](=O)[O-])ccc1C(=O)O", + "Nc1ccc(C(=O)O)cc1", + "Nc1ccc(F)cc1", + "Nc1ccc(Nc2ccccc2)cc1", + "Nc1ccc(O)c([N+](=O)[O-])c1", + "Nc1ccc(S(N)(=O)=O)cc1", + "Nc1ccc2oc(=O)ccc2c1", + "Nc1cccc(C(=O)O)c1", + "Nc1ccccc1C(=O)O", + "Nc1ccccn1", + "Nc1cnnc(O)c1Cl", + "Nc1nc(Cl)nc2c1ncn2[C@H]1C[C@H](O)[C@@H](CO)O1", + "Nc1nc2ccc([N+](=O)[O-])cc2s1", + "Nc1nc2nc[nH]c2c(=O)[nH]1", + "Nc1ncc(C(=O)O)c(O)n1", + "Nc1ncn[nH]1", + "Nc1ncnc2c1ncn2C1CC(O)C(COP(=O)(O)O)O1", + "Nc1ncnc2c1ncn2C1OC(CO)C(O)C1O", + "Nc1ncnc2c1ncn2C1OC(CO)C2OP(=O)([O-])OC21", + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H]1O", + "Nc1ncnc2nc[nH]c12", + "O=C(CC1NCCCC1O)Cn1cnc2ccccc2c1=O", + "O=C(CO)C(O)C(O)COP(=O)(O)O", + "O=C(CO)[C@@H](O)[C@@H](O)[C@@H](O)CO", + "O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O", + "O=C(O)/C=C(\\CC(=O)O)C(=O)O", + "O=C(O)/C=C/c1ccc(O)c(O)c1", + "O=C(O)/C=C/c1ccc(O)cc1", + "O=C(O)/C=C/c1cccc(O)c1", + "O=C(O)/C=C/c1ccccc1", + "O=C(O)/C=C\\c1ccc(O)c(O)c1", + "O=C(O)C(=O)Cc1ccc(O)cc1", + "O=C(O)C(O)C(O)C(=O)O", + "O=C(O)C(O)C(O)C(O)C(=O)CO", + "O=C(O)C(O)CO", + "O=C(O)C(O)Cc1ccc(O)cc1", + "O=C(O)C(O)Cc1ccccc1", + "O=C(O)C(O)c1ccc(O)c(O)c1", + "O=C(O)C(O)c1ccc(O)cc1", + "O=C(O)C(O)c1ccccc1", + "O=C(O)C(c1ccccc1)C1CCCCN1", + "O=C(O)C1=C[C@@H](O)[C@@H](O)[C@H](O)C1", + "O=C(O)C1CC(O)CN1", + "O=C(O)C1CCC(O)CC1", + "O=C(O)C1OC(O)C(O)C(O)C1O", + "O=C(O)C=C(CC(=O)O)C(=O)O", + "O=C(O)C=CC(=O)O", + "O=C(O)C=Cc1ccc(O)c(O)c1", + "O=C(O)C=Cc1ccc(O)cc1", + "O=C(O)C=Cc1cccc(O)c1", + "O=C(O)C=Cc1ccccc1", + "O=C(O)CC(=O)C(=O)O", + "O=C(O)CC(=O)O", + "O=C(O)CC(CC(=O)O)C(=O)O", + "O=C(O)CC(O)(CC(=O)O)C(=O)O", + "O=C(O)CC(O)C(=O)O", + "O=C(O)CCC(=O)C(=O)O", + "O=C(O)CCC(=O)O", + "O=C(O)CCC(=O)c1ccc(F)cc1", + "O=C(O)CCCC(=O)O", + "O=C(O)CCCCC(=O)O", + "O=C(O)CCCCC1CCSS1", + "O=C(O)CCCCCC(=O)O", + "O=C(O)CCCCCCC(=O)O", + "O=C(O)CCCCCCCC(=O)O", + "O=C(O)CCCCCCCCCO", + "O=C(O)CCCCc1ccccc1", + "O=C(O)CCN1CCCCCC1=O", + "O=C(O)CCc1ccccc1", + "O=C(O)CN=C(O)c1ccccc1", + "O=C(O)CNC(=O)CN1C(=O)NC2NC(=O)NC21", + "O=C(O)CNC(=O)c1cccnc1", + "O=C(O)CNC(=O)c1ccco1", + "O=C(O)COc1ccc(Cl)cc1", + "O=C(O)COc1ccccc1", + "O=C(O)C[C@H](O)C(=O)O", + "O=C(O)Cc1cc(O)ccc1O", + "O=C(O)Cc1ccc(O)cc1", + "O=C(O)Cc1cccc(O)c1", + "O=C(O)[C@@H]1CCC(O)=N1", + "O=C(O)[C@@H]1C[C@@H](O)CN1", + "O=C(O)[C@H](O)CO", + "O=C(O)[C@H](O)Cc1ccccc1", + "O=C(O)[C@H](O)[C@@H](O)C(=O)O", + "O=C(O)[C@H](O)[C@@H](O)[C@@H](O)[C@H](O)CO", + "O=C(O)[C@H]1C[C@@H](O)CN1", + "O=C(O)[C@H]1O[C@@H](O)[C@H](O)[C@@H](O)[C@H]1O", + "O=C(O)c1c[nH]c2ccccc12", + "O=C(O)c1cc(=O)[nH]c(=O)[nH]1", + "O=C(O)c1cc(O)c(O)c(O)c1", + "O=C(O)c1cc(O)ccc1O", + "O=C(O)c1cc(O)nc(O)n1", + "O=C(O)c1cc(Oc2ccc(C(F)(F)F)cc2Cl)ccc1[N+](=O)[O-]", + "O=C(O)c1cc2ccccc2[nH]1", + "O=C(O)c1ccc(C(=O)O)o1", + "O=C(O)c1ccc(O)c(O)c1", + "O=C(O)c1ccc(O)cc1", + "O=C(O)c1ccc(O)cc1O", + "O=C(O)c1ccc(O)nc1", + "O=C(O)c1ccc2ccccc2c1", + "O=C(O)c1ccc2ccccc2n1", + "O=C(O)c1cccc(O)c1", + "O=C(O)c1cccc(O)c1O", + "O=C(O)c1ccccc1", + "O=C(O)c1ccccc1C(=O)O", + "O=C(O)c1ccccc1F", + "O=C(O)c1ccccc1O", + "O=C(O)c1cccnc1C(=O)O", + "O=C(O)c1ccnc2ccccc12", + "O=C(O)c1ccncc1", + "O=C/C=C/c1ccc(O)cc1", + "O=C1C=C(O)C(=O)c2ccccc21", + "O=C1C=C2C(=CCOC2O)O1", + "O=C1C=CC(=O)c2ccccc21", + "O=C1C=CCC2C3CCCN4CCCC(CN12)C34", + "O=C1CC(c2ccc(O)c(O)c2)Oc2cc(O)cc(O)c21", + "O=C1CC(c2ccc(O)cc2)Oc2cc(O)cc(O)c21", + "O=C1CCC(=O)N1", + "O=C1CCCC2C3CCCN4CCCC(CN12)C34", + "O=C1CC[C@@H](C(=O)O)N1", + "O=C1CN=C(O)[C@@H]2CCCN12", + "O=C1CNC(=O)CN1", + "O=C1N=CN=C2N=CN=C12", + "O=C1OC(C(O)CO)C(O)=C1O", + "O=C1O[C@H]([C@@H](O)CO)[C@H](O)[C@@H]1O", + "O=C1c2c(O)cc(O)cc2OC(c2ccc(O)c(O)c2)C1O", + "O=C1c2ccccc2C(=O)c2c(O)ccc(O)c21", + "O=C1c2ccccc2C(=O)c2ccccc21", + "O=CC(O)C(O)C(O)C(O)CO", + "O=CC(O)CO", + "O=CC[C@@H](O)[C@H](O)[C@H](O)CO", + "O=CCc1c[nH]c2ccccc12", + "O=C[C@H](O)[C@H]1OC(=O)[C@@H](O)[C@H]1O", + "O=NN1CCCC1", + "O=NN1CCCCC1", + "O=P(O)(O)OC(CO)CO", + "O=P(O)(O)OC[C@H](O)CO", + "O=P(O)(O)Oc1ccccc1", + "O=S(=O)(O)NC1CCCCC1", + "O=S(=O)(O)Oc1cccc(O)c1", + "O=[N+]([O-])c1ccc(O)cc1", + "O=[N+]([O-])c1ccc(Oc2ccc(Cl)cc2Cl)cc1", + "O=c1[nH]c(=O)c2ncn(C3OC(COP(=O)(O)O)C(O)C3O)c2[nH]1", + "O=c1[nH]c(Cl)c(Cl)cc1Cl", + "O=c1[nH]cc(CO)c(=O)[nH]1", + "O=c1c(-c2ccc(O)cc2)coc2cc(O)ccc12", + "O=c1c(O)c(-c2ccc(O)c(O)c2)oc2cc(O)cc(O)c12", + "O=c1c(O)c(-c2ccc(O)c(O)c2)oc2cc(O)ccc12", + "O=c1c(O)c(-c2ccc(O)cc2)oc2cc(O)cc(O)c12", + "O=c1c(O)c(-c2ccccc2)oc2cc(O)cc(O)c12", + "O=c1c2ccccc2nc2n1CCc1c-2[nH]c2ccccc12", + "O=c1cc(-c2ccc(O)cc2)oc2cc(O)ccc12", + "O=c1cc(-c2ccc(O)cc2)oc2ccccc12", + "O=c1cc(C(Cl)(Cl)Cl)oc2ccccc12", + "O=c1cc(O)c2ccccc2o1", + "O=c1ccc2cc(O)c(O)cc2o1", + "O=c1ccc2cc3ccoc3c(O)c2o1", + "O=c1ccc2ccc(O)c(O)c2o1", + "O=c1ccc2ccc(O)cc2o1", + "O=c1ccc2ccccc2o1", + "O=c1cccc2n1CC1CC2CN2CCCCC12", + "O=c1ccn(C2OC(CO)C(O)C2O)c(=O)[nH]1", + "O=c1ccn([C@@H]2O[C@H](CO)[C@@H](O)C2(F)F)c(=O)[nH]1", + "O=c1ccoc2cc(O)cc(O)c12", + "O=c1ccoc2ccccc12", + "O=c1nc[nH]c2c1ncn2[C@@H]1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H]1O", + "O=c1oc2ccccc2c(NCCOc2ccccc2)c1[N+](=O)[O-]", + "OC1CCCCCCCCCCC1", + "OC1COC(O)C(O)C1O", + "OC1COC(O)C1O", + "OCC(O)c1ccc(O)c(O)c1", + "OCC1(O)OCC(O)C(O)C1O", + "OCCNCCO", + "OCCc1c[nH]c2ccccc12", + "OC[C@@H](O)[C@@H](O)[C@H](O)[C@H](O)CO", + "OC[C@@H](O)[C@H](O)[C@@H](O)CO", + "OC[C@@H](O)[C@H](O)[C@H](O)[C@@H](O)CO", + "OC[C@H](O)C(O)[C@@H](O)CO", + "OC[C@H](O)[C@@H](O)CO", + "OC[C@H]1OC(O)[C@@H](O)[C@@H](O)[C@@H]1O", + "OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O", + "OC[C@H]1O[C@@H](n2cnc3c(O)ncnc32)C[C@@H]1O", + "OC[C@H]1O[C@H](O[C@H]2[C@H](O)[C@@H](O)C(O)O[C@@H]2CO)[C@H](O)[C@@H](O)[C@@H]1O", + "OCc1ccc2c(c1)OCO2", + "OCc1ccccc1", + "Oc1cc(O)c2c(c1)O[C@H](c1ccc(O)c(O)c1)[C@@H](O)[C@H]2O", + "Oc1ccc(Cl)cc1", + "Oc1ccc(O)cc1", + "Oc1ccc2ccccc2c1", + "Oc1cccc(S)c1O", + "Oc1cccc2ccccc12", + "Oc1cccc2cccnc12", + "Oc1cccc2n[nH]nc12", + "Oc1ccccc1-c1ccccc1", + "Oc1ccccc1O", + "Oc1ccnc(O)n1", + "Oc1nc(O)c2cn[nH]c2n1", + "Oc1ncnc2[nH]ncc12", + "Oc1ncnc2nc[nH]c12", + "On1nnc2ccccc21", + "S=c1[nH]c2ccccc2[nH]1", + "S=c1[nH]c2ccccc2s1", + "Sc1nc2ccccc2s1", + "c1ccc(CN2CCNCC2)cc1", + "c1ccc2[nH]cnc2c1", + "c1ccc2c(c1)CN1CCCC1=N2", + "c1ccc2c(c1)[nH]c1cnccc12", + "c1ccc2scnc2c1", + "c1ccncc1", + "c1cn[nH]c1", + "c1cnc2c(c1)ccc1cccnc12", + "c1cncc(C2CCCCN2)c1", + "c1ncc2[nH]cnc2n1", + "c1ncc2nc[nH]c2n1" + ], + "sources": [ + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "drugs", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "drugs", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "pesticides", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "pesticides", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "pesticides", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "pesticides", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "pesticides", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "pesticides", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k", + "GNPS-random-10k" + ] +} diff --git a/pyproject.toml b/pyproject.toml index c3a4a76..4797822 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "simms-gpu" -version = "1.0.0" +version = "1.1.0" description = "Faster Similarity for Mass Spec on GPU" authors = [ {name="Tornike Onoprishvili", email="tornikeonoprishvili@gmail.com"} diff --git a/simms/__init__.py b/simms/__init__.py index 473d97a..2c11d19 100644 --- a/simms/__init__.py +++ b/simms/__init__.py @@ -1,6 +1,7 @@ from .__version__ import __version__ +from .molecules import MolecularGraphs from .peaks import PeakArrays __author__ = "SimMS developers community" __email__ = "tornikeonoprishvili@gmail.com" -__all__ = ["__version__", "PeakArrays", "similarity"] +__all__ = ["__version__", "PeakArrays", "MolecularGraphs", "similarity"] diff --git a/simms/__version__.py b/simms/__version__.py index 5becc17..6849410 100644 --- a/simms/__version__.py +++ b/simms/__version__.py @@ -1 +1 @@ -__version__ = "1.0.0" +__version__ = "1.1.0" diff --git a/simms/molecules.py b/simms/molecules.py new file mode 100644 index 0000000..fba2bb9 --- /dev/null +++ b/simms/molecules.py @@ -0,0 +1,154 @@ +# SPDX-License-Identifier: MIT +"""Reusable element-labelled molecular graphs for weighted common-edge matching.""" +from dataclasses import dataclass + +import numpy as np +from matchms import SpectraCollection +from rdkit import Chem + + +@dataclass(frozen=True, eq=False) +class _Graph: + key: str + elements: np.ndarray + adjacency: np.ndarray + # Per vertex: element, weighted degree, signature order, neighbor offset, count. + vertices: np.ndarray + # Per incident edge: neighbor index, neighbor element, doubled bond order. + neighbors: np.ndarray + weight: int + weight_gcd: int + + +def _readonly(array): + array.flags.writeable = False + return array + + +def _graph(mol, key): + atoms = list(mol.GetAtoms()) + # Keep the search frontier connected within each component. Break ties by + # ring membership and degree, then by input index for deterministic searches. + remaining = set(range(len(atoms))) + adjacent = [set(n.GetIdx() for n in atom.GetNeighbors()) for atom in atoms] + order, visited = [], set() + while remaining: + i = max(remaining, key=lambda a: (len(adjacent[a] & visited), atoms[a].IsInRing(), + len(adjacent[a]), -a)) + order.append(i) + visited.add(i) + remaining.remove(i) + index = {old: new for new, old in enumerate(order)} + elements = np.array([atoms[i].GetAtomicNum() for i in order], dtype=np.uint8) + adj = np.zeros((len(order), len(order)), dtype=np.uint8) + for bond in mol.GetBonds(): + scaled = 2 * bond.GetBondTypeAsDouble() + if scaled != int(scaled) or not 0 <= scaled <= 255: + raise ValueError("Bond order cannot be represented in half units") + a, b = index[bond.GetBeginAtomIdx()], index[bond.GetEndAtomIdx()] + adj[a, b] = adj[b, a] = int(scaled) + degree = adj.sum(axis=1, dtype=np.int32) + by_type = np.lexsort((-degree, elements)) + neighbors, vertices = [], [] + for i in range(len(order)): + edges = sorted(((int(j), int(elements[j]), int(adj[i, j])) for j in np.flatnonzero(adj[i])), + key=lambda edge: (edge[1], -edge[2], edge[0])) + vertices.append((elements[i], degree[i], by_type[i], len(neighbors), len(edges))) + neighbors.extend(edges) + return _Graph(key, _readonly(elements), _readonly(adj), + _readonly(np.array(vertices, np.int32).reshape(-1, 5)), + _readonly(np.array(neighbors, np.int32).reshape(-1, 3)), + int(degree.sum() // 2), int(np.gcd.reduce(adj.ravel(), initial=0))) + + +@dataclass(frozen=True, eq=False) +class MolecularGraphs: + """Unique molecular graphs and a read-only index back to input order. + + An index of -1 represents a missing or unparseable structure. Bond orders + in each graph's adjacency matrix are doubled integers. Metadata sources + are tried in SMILES, then InChI order. + """ + + graphs: tuple + index: np.ndarray + + def __post_init__(self): + graphs = tuple(self.graphs) + if not all(isinstance(g, _Graph) for g in graphs): + raise TypeError("graphs must contain prepared molecular graphs") + ids = np.asarray(self.index) + if ids.ndim != 1 or ids.dtype.kind not in "iu": + raise ValueError("index must be a one-dimensional integer array") + if ids.size and (ids.min() < -1 or ids.max() >= len(graphs)): + raise ValueError("molecular graph index out of range") + object.__setattr__(self, "graphs", graphs) + object.__setattr__(self, "index", _readonly(ids.astype(np.int32))) + + def __len__(self): + return len(self.index) + + @classmethod + def from_smiles(cls, smiles_list): + """Prepare a sequence or iterable of SMILES strings.""" + return cls._prepare(smiles_list, "smiles") + + @classmethod + def from_mols(cls, mol_list): + """Prepare RDKit molecules without mutating caller-owned atoms.""" + return cls._prepare(mol_list, "mol") + + @classmethod + def from_spectra(cls, spectra): + """Read spectrum metadata, or accept already prepared graphs.""" + return cls._prepare(spectra, "auto") + + @classmethod + def _prepare(cls, items, kind): + if isinstance(items, cls): + return items + if isinstance(items, SpectraCollection): + metadata = items.metadata + items = (dict(zip(("smiles", "inchi"), row)) for row in + metadata.reindex(columns=["smiles", "inchi"]).itertuples(index=False, name=None)) + graphs, indices = [], [] + keys, parsed = {}, {} + + def register(mol): + if mol is None or not mol.GetNumAtoms(): + return -1 + try: + key = Chem.MolToSmiles(mol, allBondsExplicit=True) + if key not in keys: + graph = _graph(mol, key) + keys[key] = len(graphs) + graphs.append(graph) + return keys[key] + except (RuntimeError, ValueError, OverflowError): + return -1 + + def parse(value, inchi=False): + if not isinstance(value, str) or not value.strip(): + return -1 + token = value.strip() + key = (inchi, token) + if key not in parsed: + try: + mol = Chem.MolFromInchi(token) if inchi else Chem.MolFromSmiles(token) + parsed[key] = register(mol) + except (RuntimeError, ValueError): + parsed[key] = -1 + return parsed[key] + + for item in items: + idx = -1 + if kind != "smiles" and isinstance(item, Chem.Mol): + idx = register(item) + elif kind != "mol" and isinstance(item, str): + idx = parse(item) + elif kind == "auto" and hasattr(item, "get"): + idx = parse(item.get("smiles")) + if idx < 0: + idx = parse(item.get("inchi"), inchi=True) + indices.append(idx) + return cls(tuple(graphs), np.array(indices, dtype=np.int32)) diff --git a/simms/similarity/CudaMyopicMCES.py b/simms/similarity/CudaMyopicMCES.py new file mode 100644 index 0000000..5c60179 --- /dev/null +++ b/simms/similarity/CudaMyopicMCES.py @@ -0,0 +1,308 @@ +# SPDX-License-Identifier: MIT +"""Thresholded weighted molecular common-edge distances on CUDA.""" +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor +from itertools import islice, product +from operator import index + +import numpy as np +import torch +from matchms import Scores +from numba import cuda +from scipy.sparse import coo_array +from tqdm import tqdm + +from ..molecules import MolecularGraphs +from ..utils import get_device +from ._base import CudaSimilarity +from ._mces_milp import solve_milp +from ._mces_search import filter_kernel, pack, solve_kernel +from .vector_similarity_functions import kernel_stream, kernel_view + + +@cuda.jit +def _scatter(ids, values, flags, scores, exact): + k = cuda.grid(1) + if k < len(ids): + scores[ids[k]], exact[ids[k]] = values[k], flags[k] + + +@cuda.jit +def _retain(scores, exact, maximum, has_maximum, only_exact, ids, values, flags, count): + k = cuda.grid(1) + if k < len(scores): + if (not has_maximum or scores[k] <= maximum) and (not only_exact or exact[k]): + slot = cuda.atomic.add(count, 0, 1) + ids[slot], values[slot], flags[slot] = k, scores[k], exact[k] + + +def _launch(n): + threads = 32 + return (n + threads - 1) // threads, threads + + +def _library(left, right): + graphs, keys = [], {} + + def groups(container): + ids = [] + for graph in container.graphs: + if graph.key not in keys: + keys[graph.key] = len(graphs) + graphs.append(graph) + ids.append(keys[graph.key]) + remap = np.array(ids + [-1], np.int32) + axis = remap[container.index] + grouped = defaultdict(list) + for i, g in enumerate(axis): + grouped[int(g)].append(i) + return axis, grouped + + a = groups(left) + b = a if left is right else groups(right) + return graphs, a, b + + +def _coordinates(row, col, shape): + if row is None or col is None: + raise ValueError("idx_row and idx_col must be given together") + row, col = np.asarray(row), np.asarray(col) + if row.ndim != 1 or row.shape != col.shape: + raise ValueError("idx_row and idx_col must be aligned 1D arrays") + for axis, size in zip((row, col), shape): + if axis.size and axis.dtype.kind not in "iu": + raise TypeError("sparse coordinates must be integers") + if np.any(axis < 0) or np.any(axis >= size): + raise ValueError("sparse coordinate out of bounds") + return zip(row, col) + + +class _Pairs: + """Stream unique compound pairs and expand results back to spectrum coordinates.""" + + def __init__(self, a, b, symmetric, row, col): + (axis_a, self.left), (axis_b, self.right) = a, b + self.requested = None + if row is not None or col is not None: + self.requested = defaultdict(set) + for i, j in _coordinates(row, col, (len(axis_a), len(axis_b))): + key = tuple(sorted((axis_a[i], axis_b[j]))) + self.requested[key].add((i, j)) + if symmetric: + self.requested[key].add((j, i)) + + def __iter__(self): + if self.requested is not None: + yield from self.requested + return + for i in self.left: + for j in self.right: + if i > j and j in self.left and i in self.right: + continue + yield i, j + + def batches(self, graphs, batch_size): + def split(tile): + width = max((len(graphs[g].elements) for i, j in tile if i >= 0 and j >= 0 and i != j + for g in (i, j)), default=1) + # Bound concurrent LAP scratch without penalizing unrelated small pairs. + if len(tile) > 1 and len(tile) * 4 * width * width > (64 << 20): + mid = len(tile) // 2 + yield from split(tile[:mid]) + yield from split(tile[mid:]) + else: + yield tile, width + + pairs = iter(self) + while tile := list(islice(pairs, batch_size)): + yield from split(tile) + + def expand(self, tile, ids, records, predicate): + for k, pair_id in enumerate(ids): + if predicate is None or predicate(records[k]): + for i, j in self.locations(tile[pair_id]): + yield i, j, k + + def locations(self, pair): + if self.requested is not None: + yield from self.requested[pair] + return + i, j = pair + yield from product(self.left[i], self.right[j]) + if i != j and j in self.left and i in self.right: + yield from product(self.left[j], self.right[i]) + + +class CudaMyopicMCES(CudaSimilarity): + """Weighted edge-edit distance under an injective element-preserving atom map. + + A finite threshold returns exact optima through the threshold (inclusive). + Above it, score is the neighborhood lower bound if it rejected the pair + and always_stronger_bound is set, otherwise the threshold. Inspect 'exact' + to distinguish capped results, especially when filtering at the threshold. + Set threshold=None for unrestricted exact distances. Torch output planes + follow score_fields order. Sparse output preserves retained zero distances. + """ + + score_datatype = np.dtype([("score", np.float64), ("exact", np.bool_)]) + score_fields = score_datatype.names + + def __init__(self, threshold: float | None = 10.0, always_stronger_bound: bool = True, + batch_size: int = 2048, max_frames: int = 50_000, max_gpu_atoms: int = 64, + n_fallback_workers: int | None = None): + self.threshold = None if threshold is None else float(threshold) + if threshold is not None and (not np.isfinite(self.threshold) or self.threshold < 0): + raise ValueError("threshold must be nonnegative and finite, or None") + self.always_stronger_bound = bool(always_stronger_bound) + self.batch_size = index(batch_size) + self.max_frames = index(max_frames) + self.max_gpu_atoms = index(max_gpu_atoms) + self.n_fallback_workers = None if n_fallback_workers is None else index(n_fallback_workers) + if min(self.batch_size, self.max_frames, self.max_gpu_atoms, + 1 if n_fallback_workers is None else self.n_fallback_workers) < 1: + raise ValueError("batch_size, max_frames, max_gpu_atoms and n_fallback_workers must be positive") + self.device = get_device(require_cuda=True) + if not cuda.is_available(): + raise RuntimeError("MCES requires CUDA or NUMBA_ENABLE_CUDASIM=1") + + def pair(self, a, b): + def single(item): + if isinstance(item, MolecularGraphs): + if len(item) != 1: + raise ValueError("pair expects one molecule per input") + return item + return [item] + + return self.matrix(single(a), single(b), array_type="numpy", progress_bar=False).reshape(()) + + @staticmethod + def _upload(arrays): + return tuple(cuda.to_device(arr) for arr in arrays) + + def _solve(self, library, graphs, pairs, width, pool, maximum, only_exact, device_output): + n = len(pairs) + meta, vertices, adjacency, neighbors = library + device_pairs = cuda.to_device(np.asarray(pairs, np.int32)) + work = cuda.device_array((n, 7, width + 1), np.int32) + costs = cuda.device_array((n, width, width), np.int32) + seeds = cuda.device_array((n, 3, width), np.int32) + lower = cuda.device_array(n, np.int32) + stream = kernel_stream(self.device) if device_output else 0 + if device_output: + planes = (torch.empty(n, device=self.device, dtype=torch.float64), + torch.empty(n, device=self.device, dtype=torch.bool)) + scores, exact = map(kernel_view, planes) + else: + scores, exact = cuda.device_array(n, np.float64), cuda.device_array(n, np.bool_) + pending = cuda.device_array(n, np.int32) + count = cuda.to_device(np.zeros(1, np.int32)) + threshold = np.inf if self.threshold is None else self.threshold + blocks, threads = _launch(n) + filter_kernel[blocks, threads, stream](meta, vertices, neighbors, device_pairs, threshold * 2, + self.always_stronger_bound, costs, work, seeds, lower) + lanes = 1 if cuda.config.ENABLE_CUDASIM else 32 + solve_kernel[n, lanes, stream]( + meta, vertices, adjacency, neighbors, device_pairs, threshold, self.always_stronger_bound, + self.max_gpu_atoms, self.max_frames, lower, seeds, work, scores, exact, pending, count, + ) + if stream: + stream.synchronize() + size = int(count.copy_to_host()[0]) + if size: + ids = pending[:size].copy_to_host() + + def solve(k): + i, j = pairs[k] + return solve_milp(graphs[i], graphs[j], self.threshold) + + values, flags = zip(*pool.map(solve, ids)) + blocks, threads = _launch(size) + _scatter[blocks, threads, stream](pending[:size], cuda.to_device(np.array(values, np.float64)), + cuda.to_device(np.array(flags, bool)), scores, exact) + if device_output: + return range(n), *planes + if maximum is None and not only_exact: + return range(n), scores.copy_to_host(), exact.copy_to_host() + count.copy_to_device(np.zeros(1, np.int32)) + values = cuda.device_array_like(scores) + flags = cuda.device_array_like(exact) + _retain[_launch(n)](scores, exact, 0. if maximum is None else float(maximum), + maximum is not None, only_exact, pending, values, flags, count) + size = int(count.copy_to_host()[0]) + return (pending[:size].copy_to_host(), values[:size].copy_to_host(), flags[:size].copy_to_host()) + + def _compute(self, left, right, fields, progress_bar, array_type, row=None, col=None, + predicate=None, maximum=None, only_exact=False): + symmetric = right is None + same = symmetric or left is right + left = MolecularGraphs.from_spectra(left) + right = left if same else MolecularGraphs.from_spectra(right) + shape = (len(left), len(right)) + graphs, a, b = _library(left, right) + plan = _Pairs(a, b, symmetric, row, col) + dtype = np.dtype([(f, self.score_datatype[f]) for f in fields]) + sparse = array_type == "sparse" + if sparse: + chunks = [] + elif array_type == "torch": + result = torch.empty((len(fields), *shape), dtype=torch.float64, device=self.device) + elif array_type == "scores": + result = self._create_dense_result(*shape, fields) + else: + result = np.empty(shape, dtype) + if graphs: + library = self._upload(pack(graphs)) + else: + # Sentinel-only pairs leave the kernels before graph access. + library = tuple(cuda.to_device(arr) for arr in + (np.zeros((1, 5), np.int64), np.empty((0, 5), np.int32), + np.empty(0, np.uint8), np.empty((0, 3), np.int32))) + with ThreadPoolExecutor(self.n_fallback_workers) as pool, tqdm( + desc="Scoring molecular pairs", unit="pair", disable=not progress_bar + ) as progress: + for tile, width in plan.batches(graphs, self.batch_size): + ids, values, flags = self._solve(library, graphs, tile, width, pool, maximum, + only_exact, array_type == "torch") + if array_type == "torch": + records = {"score": values, "exact": flags} + else: + records = np.empty(len(values), self.score_datatype) + records["score"], records["exact"] = values, flags + locations = plan.expand(tile, ids, records, predicate) + while block := list(islice(locations, max(len(tile), 4096))): + i, j, k = np.asarray(block, np.intp).T + if sparse: + chunks.append((i, j, records[k])) + elif array_type == "torch": + i, j, k = (torch.as_tensor(x, device=self.device) for x in (i, j, k)) + for p, field in enumerate(fields): + result[p, i, j] = records[field][k].to(result.dtype) + else: + for field in fields: + result[field][i, j] = records[field][k] + progress.update(len(tile)) + if sparse: + if chunks: + i, j, values = map(np.concatenate, zip(*chunks)) + else: + i = j = np.empty(0, np.intp) + values = np.empty(0, self.score_datatype) + return Scores({f: coo_array((values[f], (i, j)), shape=shape) for f in fields}) + return Scores(result) if array_type == "scores" else result + + def matrix(self, left, right=None, score_fields=None, progress_bar=True, array_type="scores"): + if array_type not in ("scores", "numpy", "torch"): + raise ValueError("array_type must be 'scores', 'numpy' or 'torch'") + return self._compute(left, right, self._fields(score_fields), progress_bar, array_type) + + def keep_score(self, score): + """Retain all requested distances, including exact zeros and missing values.""" + return True + + def sparse_matrix(self, left, right=None, idx_row=None, idx_col=None, score_fields=None, + score_filter=None, progress_bar=True, max_distance=None, exact_only=False): + """Retain inclusive distance/exactness matches, then apply a full-record predicate.""" + if score_filter is None and getattr(self.keep_score, "__func__", None) is not CudaMyopicMCES.keep_score: + score_filter = self.keep_score + return self._compute(left, right, self._fields(score_fields), progress_bar, "sparse", + idx_row, idx_col, score_filter, max_distance, exact_only) diff --git a/simms/similarity/__init__.py b/simms/similarity/__init__.py index f86f3e2..758b7cc 100644 --- a/simms/similarity/__init__.py +++ b/simms/similarity/__init__.py @@ -4,6 +4,7 @@ from .CudaEntropyGreedy import CudaEntropyGreedy from .CudaFingerprintSimilarity import CudaFingerprintSimilarity from .CudaModifiedCosine import CudaModifiedCosine, CudaModifiedCosineGreedy +from .CudaMyopicMCES import CudaMyopicMCES from .CudaNeutralLossesCosine import CudaNeutralLossesCosine from .CudaTransitiveAlignment import CudaTransitiveAlignment as CudaTransitiveAlignment from .CudaTransitiveAlignment import TransitiveAlignmentResult as TransitiveAlignmentResult @@ -20,5 +21,6 @@ "CudaModifiedCosine", "CudaModifiedCosineGreedy", "CudaModifiedCosineLinear", + "CudaMyopicMCES", "CudaNeutralLossesCosine", ] diff --git a/simms/similarity/_mces_milp.py b/simms/similarity/_mces_milp.py new file mode 100644 index 0000000..175dfbc --- /dev/null +++ b/simms/similarity/_mces_milp.py @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: MIT +"""Sparse binary model for the weighted common-edge edit distance (SciPy/HiGHS).""" +from collections import defaultdict +from warnings import filterwarnings + +import numpy as np +from scipy.optimize import Bounds, LinearConstraint, milp +from scipy.sparse import csc_matrix + + +# SciPy forwards the native threads option. Scope the warning filter to this +# module: entering/exiting catch_warnings in concurrent workers races on 3.11. +filterwarnings("ignore", message=r"Unrecognized options detected: .*'threads'.*", category=RuntimeWarning, + module=r"^simms\.similarity\._mces_milp$") + + +def solve_milp(a, b, threshold): + """Return the certified optimum, or the threshold after certified infeasibility.""" + # Eliminate the unmatched-edge variables: an edge unused by a match pays + # its weight. A matched edge pair saves twice its smaller weight. + total = a.weight + b.weight + edge_a = list(zip(*np.nonzero(np.triu(a.adjacency, 1)))) + edge_b = list(zip(*np.nonzero(np.triu(b.adjacency, 1)))) + atom_vars = {} + objective = [] + rows = defaultdict(dict) + + for i, elem in enumerate(a.elements): + for j in np.flatnonzero(b.elements == elem): + var = len(objective) + atom_vars[i, j] = var + objective.append(0) + rows["atom_a", i][var] = rows["atom_b", j][var] = 1 + for e, (i, h) in enumerate(edge_a): + for f, (j, k) in enumerate(edge_b): + if not (((i, j) in atom_vars and (h, k) in atom_vars) + or ((i, k) in atom_vars and (h, j) in atom_vars)): + continue + var = len(objective) + objective.append(-2 * int(min(a.adjacency[i, h], b.adjacency[j, k]))) + rows["edge_a", e][var] = rows["edge_b", f][var] = 1 + # Incidence consistency, aggregated by (vertex, opposite edge). + for src in (i, h): + row = rows["inc_a", src, f] + row[var] = 1 + for dst in (j, k): + if (src, dst) in atom_vars: + row[atom_vars[src, dst]] = -1 + for dst in (j, k): + row = rows["inc_b", dst, e] + row[var] = 1 + for src in (i, h): + if (src, dst) in atom_vars: + row[atom_vars[src, dst]] = -1 + + if len(objective) == len(atom_vars): + score = total / 2 + return (score, True) if threshold is None or score <= threshold else (threshold, False) + if threshold is not None: + rows["limit",] = {i: c for i, c in enumerate(objective) if c} + + ri, ci, values, upper = [], [], [], [] + for r, (key, entries) in enumerate(rows.items()): + ri.extend([r] * len(entries)) + ci.extend(entries) + values.extend(entries.values()) + if key[0] == "limit": + upper.append(np.floor(2 * threshold) - total) + else: + upper.append(0 if key[0].startswith("inc") else 1) + matrix = csc_matrix((values, (ri, ci)), shape=(len(upper), len(objective))) + result = milp(np.asarray(objective, float), integrality=np.ones(len(objective), np.uint8), + bounds=Bounds(0, 1), constraints=LinearConstraint(matrix, -np.inf, upper), + options={"mip_rel_gap": 0.0, "threads": 1}) + if result.status == 2 and threshold is not None: + return threshold, False + if not result.success: + raise RuntimeError(f"HiGHS could not certify the MCES distance: {result.message}") + return (total + round(result.fun)) / 2, True diff --git a/simms/similarity/_mces_search.py b/simms/similarity/_mces_search.py new file mode 100644 index 0000000..f3b1200 --- /dev/null +++ b/simms/similarity/_mces_search.py @@ -0,0 +1,439 @@ +# SPDX-License-Identifier: MIT +"""Integer MCES bounds and depth-first search, specialized for CUDA or CPU JIT. + +Weights, lower bounds and distances inside the search use doubled bond order. +An overlapping edge saves its weight in *both* graphs. No connectivity +constraint is imposed on the matched edges. +""" +import numpy as np +from numba import cuda + + +def _objective_bound(total, lower, divisor_a, divisor_b): + """Round the search target to an attainable distance, preserving the public LAP bound.""" + while divisor_b: + divisor_a, divisor_b = divisor_b, divisor_a % divisor_b + step = max(1, 2 * divisor_a) + return lower + (total - lower) % step + + +def _incident(a, b, na, nb, left_after, occupied): + """Maximum incident overlap by neighbor element, optionally across a DFS cut.""" + p, q = a[3], b[3] + end_p, end_q = p + a[4], q + b[4] + value = 0 + while p < end_p and q < end_q: + if left_after >= 0 and na[p, 0] <= left_after: + p += 1 + elif left_after >= 0 and occupied[nb[q, 0]]: + q += 1 + elif na[p, 1] < nb[q, 1]: + p += 1 + elif na[p, 1] > nb[q, 1]: + q += 1 + else: + value += min(na[p, 2], nb[q, 2]) + p += 1 + q += 1 + return value + + +def _move_gain(atom, neighbors, adjacency, size, mapping, old, new, exclude): + """Change in conserved weight when moving one end of each incident edge.""" + gain = 0 + for k in range(atom[3], atom[3] + atom[4]): + other = neighbors[k, 0] + target = mapping[other] + if other != exclude and target >= 0: + weight = neighbors[k, 2] + if new >= 0: + gain += min(weight, int(adjacency[new * size + target])) + if old >= 0: + gain -= min(weight, int(adjacency[old * size + target])) + return gain + + +def _assignment(cost, size, w): + """Shortest augmenting path Hungarian LAP. w[2, j] gives row for column j.""" + u, v, owner, parent, slack, used = w[0], w[1], w[2], w[3], w[4], w[5] + for j in range(size + 1): + u[j] = v[j] = owner[j] = 0 + for i in range(1, size + 1): + owner[0] = i + for j in range(size + 1): + slack[j] = 2147483647 + used[j] = 0 + j = 0 + while True: + used[j] = 1 + row = owner[j] + delta, next_j = 2147483647, 0 + for k in range(1, size + 1): + if not used[k]: + reduced = cost[row - 1, k - 1] - u[row] - v[k] + if reduced < slack[k]: + slack[k], parent[k] = reduced, j + if slack[k] < delta: + delta, next_j = slack[k], k + for k in range(size + 1): + if used[k]: + u[owner[k]] += delta + v[k] -= delta + else: + slack[k] -= delta + j = next_j + if owner[j] == 0: + break + while j: + k = parent[j] + owner[j] = owner[k] + j = k + + +def _specialize(compile_fn, gpu=False): + incident = compile_fn(_incident) + assignment = compile_fn(_assignment) + move_gain = compile_fn(_move_gain) + + @compile_fn + def bounds(a, b, na, nb, total, limit, stronger, cost, w, seed, dual_a, dual_b): + # Zipped, degree-descending lists within equal-element groups. + p = q = overlap = 0 + while p < len(a) and q < len(b): + x, y = a[a[p, 2]], b[b[q, 2]] + if x[0] < y[0]: + p += 1 + elif x[0] > y[0]: + q += 1 + else: + overlap += min(x[1], y[1]) + p += 1 + q += 1 + weak = total - overlap + if weak > limit and not stronger: + return weak + for i in range(len(a)): + seed[i] = -1 + dual_a[i] = 0 + for j in range(len(b)): + dual_b[j] = 0 + p = q = overlap = 0 + while p < len(a) and q < len(b): + el, er = a[a[p, 2], 0], b[b[q, 2], 0] + if el < er: + p += 1 + continue + if er < el: + q += 1 + continue + end_p, end_q = p + 1, q + 1 + while end_p < len(a) and a[a[end_p, 2], 0] == el: + end_p += 1 + while end_q < len(b) and b[b[end_q, 2], 0] == el: + end_q += 1 + rows, cols = end_p - p, end_q - q + size = max(rows, cols) + for i in range(size): + for j in range(size): + value = 0 + if i < rows and j < cols: + value = incident(a[a[p + i, 2]], b[b[q + j, 2]], na, nb, -1, w[0]) + cost[i, j] = -value + assignment(cost, size, w) + for i in range(rows): + dual_a[a[p + i, 2]] = -w[0, i + 1] + for j in range(cols): + dual_b[b[q + j, 2]] = -w[1, j + 1] + i = w[2, j + 1] - 1 + if i < rows: + seed[a[p + i, 2]] = b[q + j, 2] + overlap -= cost[i, j] + p, q = end_p, end_q + return total - overlap + + @compile_fn + def feasible(a, b, na, adj_b, total, lower, seed, inverse): + size = len(b) + best = 0 + for i in range(len(a)): + j = seed[i] + if j >= 0: + for k in range(a[i, 3], a[i, 3] + a[i, 4]): + src = na[k, 0] + dst = seed[src] + if src < i and dst >= 0: + best += min(na[k, 2], int(adj_b[j * size + dst])) + if total - 2 * best == lower: + return best + # Improve the feasible LAP seed by element-preserving swaps, including + # moving into a free target. Strict improvements guarantee termination. + for j in range(size): + inverse[j] = -1 + for i in range(len(a)): + if seed[i] >= 0: + inverse[seed[i]] = i + while True: + gain, src, dst = 0, 0, 0 + for i in range(len(a)): + old = seed[i] + for j in range(size): + h = inverse[j] + if a[i, 0] != b[j, 0] or (h >= 0 and h <= i and old >= 0): + continue + delta = move_gain(a[i], na, adj_b, size, seed, old, j, h) + if h >= 0: + delta += move_gain(a[h], na, adj_b, size, seed, j, old, i) + if delta > gain: + gain, src, dst = delta, i, j + if not gain: + break + old, h = seed[src], inverse[dst] + if h >= 0: + seed[h] = old + if old >= 0: + inverse[old] = h + seed[src], inverse[dst] = dst, src + best += gain + if total - 2 * best == lower: + return best + + return best + + @compile_fn + def explore(a, b, na, nb, adj_b, wa, wb, lower, limit, cap, seed, dual_a, dual_b, + w, best, first, stride, shared): + size = len(b) + total = wa + wb + mapping, used, cursor = w[0], w[1], w[2] + matched, free_a, free_b = w[3], w[4], w[5] + for j in range(size): + used[j] = 0 + dual = w[6] + dual[0] = 0 + for i in range(len(a)): + dual[0] += dual_a[i] + for j in range(size): + dual[0] += dual_b[j] + depth = frames = 0 + cursor[0], matched[0] = first, 0 + free_a[0], free_b[0] = wa, wb + while depth >= 0: + candidate = cursor[depth] + if candidate > size: + depth -= 1 + if depth >= 0 and mapping[depth] >= 0: + used[mapping[depth]] = 0 + continue + cursor[depth] += stride if depth == 0 else 1 + # Visit the assignment seed first, followed by all other targets and deletion. + preferred = seed[depth] + if preferred >= 0: + if candidate == 0: + candidate = preferred + elif candidate <= preferred: + candidate -= 1 + atom = a[depth] + if candidate == size: + # With nonnegative edge rewards a maximal same-element injection + # always attains the optimum. Only a surplus source may be deleted. + remaining = 0 + for i in range(depth, len(a)): + if a[i, 0] == atom[0]: + remaining += 1 + for j in range(size): + if b[j, 0] == atom[0] and not used[j]: + remaining -= 1 + if remaining <= 0: + continue + candidate = -1 + elif used[candidate] or atom[0] != b[candidate, 0]: + continue + frames += 1 + if gpu and stride > 1: + used_frames = cuda.atomic.add(shared, 0, 1) + 1 + best = cuda.atomic.max(shared, 1, best) + if total - 2 * best == lower: + return lower, frames + else: + used_frames = frames + if used_frames >= cap: + return -1, frames + mapping[depth] = candidate + common = matched[depth] + left_weight, right_weight = free_a[depth], free_b[depth] + for k in range(atom[3], atom[3] + atom[4]): + other, weight = na[k, 0], na[k, 2] + if other > depth: + left_weight -= weight + elif mapping[other] >= 0 and candidate >= 0: + common += min(weight, int(adj_b[candidate * size + mapping[other]])) + if candidate >= 0: + used[candidate] = 1 + for k in range(b[candidate, 3], b[candidate, 3] + b[candidate, 4]): + if not used[nb[k, 0]]: + right_weight -= nb[k, 2] + # Any completion has three disjoint edge sets: fixed prefix edges, + # edges crossing the cut, and edges wholly in the two unused suffixes. + # Relax each frontier vertex to an independent neighbor assignment. + remaining_dual = dual[depth] - dual_a[depth] + if candidate >= 0: + remaining_dual -= dual_b[candidate] + frontier = 0 + for i in range(depth + 1): + j = mapping[i] + if j >= 0: + frontier += incident(a[i], b[j], na, nb, depth, used) + # The LAP dual prices bound incident overlap for every unassigned + # vertex pair. Each preserved edge is counted at both endpoints. + upper = common + min(frontier + min(left_weight, right_weight), + (frontier + remaining_dual) // 2) + if common > best: + best = common + if gpu and stride > 1: + cuda.atomic.max(shared, 1, best) + if total - 2 * best == lower: + return lower, frames + if upper > best and total - 2 * upper <= limit and depth + 1 < len(a): + depth += 1 + matched[depth], free_a[depth], free_b[depth] = common, left_weight, right_weight + dual[depth] = remaining_dual + cursor[depth] = 0 + elif candidate >= 0: + used[candidate] = 0 + return total - 2 * best, frames + + @compile_fn + def search(a, b, na, nb, adj_b, wa, wb, lower, limit, cap, seed, dual_a, dual_b, w): + best = feasible(a, b, na, adj_b, wa + wb, lower, seed, w[0]) + if wa + wb - 2 * best == lower: + return lower, 0 + return explore(a, b, na, nb, adj_b, wa, wb, lower, limit, cap, seed, dual_a, dual_b, + w, best, 0, 1, w[0]) + + return bounds, search, feasible, explore + + +gpu_objective_bound = cuda.jit(device=True)(_objective_bound) +gpu_bounds, gpu_search, gpu_feasible, gpu_explore = _specialize(cuda.jit(device=True), gpu=True) + + +def pack(graphs): + """One ragged, contiguous library. Adjacency and neighbor indices are graph-local.""" + offsets = np.zeros((len(graphs) + 1, 5), np.int64) + for i, g in enumerate(graphs): + offsets[i + 1, :3] = offsets[i, :3] + (len(g.elements), g.adjacency.size, len(g.neighbors)) + offsets[i, 3:] = g.weight, g.weight_gcd + return (offsets, np.concatenate([g.vertices for g in graphs]), + np.concatenate([g.adjacency.ravel() for g in graphs]), + np.concatenate([g.neighbors for g in graphs])) + + +@cuda.jit +def filter_kernel(meta, vertices, neighbors, pairs, limit, stronger, costs, work, seeds, lower): + k = cuda.grid(1) + if k < len(pairs): + i, j = pairs[k, 0], pairs[k, 1] + if i < 0 or j < 0 or i == j: + lower[k] = 0 + return + a = vertices[meta[i, 0]:meta[i + 1, 0]] + b = vertices[meta[j, 0]:meta[j + 1, 0]] + na = neighbors[meta[i, 2]:meta[i + 1, 2]] + nb = neighbors[meta[j, 2]:meta[j + 1, 2]] + lower[k] = gpu_bounds(a, b, na, nb, meta[i, 3] + meta[j, 3], limit, + stronger, costs[k], work[k], seeds[k, 0], seeds[k, 1], seeds[k, 2]) + + +@cuda.jit +def solve_kernel(meta, vertices, adjacency, neighbors, pairs, threshold, stronger, atom_cap, + frame_cap, lower, seeds, work, scores, exact, pending, count): + k = cuda.blockIdx.x + lane = cuda.threadIdx.x + stride = cuda.blockDim.x + i, j = pairs[k, 0], pairs[k, 1] + if i < 0 or j < 0 or i == j: + if lane == 0: + valid = i >= 0 and j >= 0 + scores[k] = 0.0 if valid else np.nan + exact[k] = valid + return + limit = threshold * 2 + lb = lower[k] + if lb > limit: + if lane == 0: + scores[k] = lb / 2 if stronger else threshold + exact[k] = False + return + a = vertices[meta[i, 0]:meta[i + 1, 0]] + b = vertices[meta[j, 0]:meta[j + 1, 0]] + distance = -1 + if max(len(a), len(b)) <= atom_cap: + lb = gpu_objective_bound(meta[i, 3] + meta[j, 3], lb, meta[i, 4], meta[j, 4]) + if lb > limit: + if lane == 0: + scores[k], exact[k] = threshold, False + return + na = neighbors[meta[i, 2]:meta[i + 1, 2]] + nb = neighbors[meta[j, 2]:meta[j + 1, 2]] + adj = adjacency[meta[j, 1]:meta[j + 1, 1]] + if max(len(a), len(b)) <= 64 and max(len(na), len(nb)) <= 256: + # Cache graph data once per pair for the cooperating search lanes. + vertex_cache = cuda.shared.array((2, 64, 5), np.int32) + neighbor_cache = cuda.shared.array((2, 256, 3), np.int32) + bond_cache = cuda.shared.array(4096, np.uint8) + prices = cuda.shared.array((3, 64), np.int32) + stack = cuda.shared.array((8, 7, 65), np.int32) + shared = cuda.shared.array(3, np.int32) + for v in range(lane, max(len(a), len(b)), stride): + for col in range(5): + if v < len(a): + vertex_cache[0, v, col] = a[v, col] + if v < len(b): + vertex_cache[1, v, col] = b[v, col] + if v < len(a): + prices[0, v] = seeds[k, 0, v] + prices[1, v] = seeds[k, 1, v] + if v < len(b): + prices[2, v] = seeds[k, 2, v] + for e in range(lane, max(len(na), len(nb)), stride): + for col in range(3): + if e < len(na): + neighbor_cache[0, e, col] = na[e, col] + if e < len(nb): + neighbor_cache[1, e, col] = nb[e, col] + for e in range(lane, len(adj), stride): + bond_cache[e] = adj[e] + cuda.syncthreads() + local_a, local_b = vertex_cache[0, :len(a)], vertex_cache[1, :len(b)] + wa, wb = meta[i, 3], meta[j, 3] + if lane == 0: + shared[0] = shared[2] = 0 + shared[1] = gpu_feasible(local_a, local_b, neighbor_cache[0], bond_cache, + wa + wb, lb, prices[0], stack[0, 0]) + cuda.syncthreads() + # Independent lanes enumerate disjoint root choices. All lanes + # share the incumbent and one frame budget for the entire pair. + lanes = min(stride, 8) + initial = cuda.atomic.add(shared, 1, 0) + if lane < lanes and wa + wb - 2 * initial > lb: + distance, _ = gpu_explore(local_a, local_b, neighbor_cache[0], neighbor_cache[1], + bond_cache, wa, wb, lb, limit, frame_cap, prices[0], + prices[1], prices[2], stack[lane], initial, lane, lanes, shared) + if distance < 0: + cuda.atomic.max(shared, 2, 1) + else: + cuda.atomic.max(shared, 1, (wa + wb - distance) // 2) + cuda.syncthreads() + distance = wa + wb - 2 * shared[1] + if shared[2] and distance > lb: + distance = -1 + elif lane == 0: + distance, _ = gpu_search(a, b, na, nb, adj, meta[i, 3], meta[j, 3], lb, + limit, frame_cap, seeds[k, 0], seeds[k, 1], seeds[k, 2], work[k]) + if lane == 0: + if distance < 0: + slot = cuda.atomic.add(count, 0, 1) + pending[slot] = k + else: + exact[k] = distance <= limit + scores[k] = distance / 2 if distance <= limit else threshold diff --git a/tests/similarity/test_myopic_mces.py b/tests/similarity/test_myopic_mces.py new file mode 100644 index 0000000..40c4b6a --- /dev/null +++ b/tests/similarity/test_myopic_mces.py @@ -0,0 +1,183 @@ +# SPDX-License-Identifier: MIT +"""MCES distances are weighted edit costs; exact zero is a meaningful sparse entry.""" +import importlib +import json +from itertools import islice + +import numpy as np +import pytest +from matchms import Scores, SpectraCollection, Spectrum, calculate_scores +from matchms.importing import load_from_mgf +from numba import cuda +from rdkit import Chem + +from simms import MolecularGraphs +from simms.similarity import CudaMyopicMCES + + +def spectrum(**metadata): + return Spectrum(np.array([80.]), np.array([1.]), metadata, metadata_harmonization=False) + + +@pytest.mark.github_ci +@pytest.mark.parametrize("a,b,distance", [ + ("CC", "CC", 0), ("CC", "NN", 2), ("C#N", "C=N", 1), ("C#N", "CN", 2), + ("c1ccccc1", "C1CCCCC1", 3), ("c1ccccc1", "C=C", 8), + ("c1ccoc1", "C1CCOC1", 2.5), ("CC.CC", "CCOCC", 2), ("CC.[Na+]", "CC.O", 0), + ("[He]", "[Na+].[Cl-]", 0), ("C", "CC", 1), + ("CC(=O)Oc1ccccc1C(=O)O", "O=C(O)c1ccccc1O", 4), + ("Cn1c(=O)c2c(ncn2C)n(C)c1=O", "Cn1c(=O)c2[nH]cnc2n(C)c1=O", 1), + ("NC(CO)C(=O)O", "CC(O)C(N)C(=O)O", 1), +]) +def test_exact_pairs(a, b, distance): + actual = CudaMyopicMCES(threshold=None).pair(a, b) + assert actual.shape == () + assert actual.dtype == np.dtype([("score", np.float64), ("exact", np.bool_)]) + assert actual.item() == (distance, True) + + +@pytest.mark.github_ci +def test_threshold_contract(): + assert CudaMyopicMCES(threshold=2).pair("CC", "NN").item() == (2, True) + a, b = "C1CCCCC1", "C1CC1.C1CC1" # same neighborhoods, different cycle topology + for stronger in (False, True): + assert CudaMyopicMCES(1, stronger).pair(a, b).item() == (1, False) + a, b = "CCCCCCCCCCC", "N#N" + assert CudaMyopicMCES().pair(a, b).item() == (13, False) + assert CudaMyopicMCES(always_stronger_bound=False).pair(a, b).item() == (10, False) + assert CudaMyopicMCES(None).pair(a, b).item() == (13, True) + + +@pytest.mark.github_ci +@pytest.mark.parametrize("config", [{"max_frames": 1}, {"max_gpu_atoms": 4}]) +def test_proven_fallback_before_filter(config, monkeypatch): + module = importlib.import_module("simms.similarity.CudaMyopicMCES") + original = module.solve_milp + calls = [] + + def observed(a, b, threshold): + calls.append((a.key, b.key)) + return original(a, b, threshold) + + monkeypatch.setattr(module, "solve_milp", observed) + s = CudaMyopicMCES(None, batch_size=1, **config) + a, b = "C1CCCCC1", "C1CC1.C1CC1" + result = s.sparse_matrix([a, b, a], idx_row=[0, 1], idx_col=[1, 2], max_distance=4, exact_only=True) + assert sorted(result.to_coo("score").data) == [4.] * 4 + assert len(calls) == 1 + s = CudaMyopicMCES(1, **config) + assert s.pair(a, b).item() == (1, False) + assert len(calls) == 2 + + +@pytest.mark.github_ci +def test_containers_calculate_scores_and_roundtrip(tmp_path, monkeypatch): + spectra = [spectrum(smiles="C(C)O"), spectrum(smiles="bad", inchi="InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3"), + spectrum(smiles="CC"), spectrum()] + graphs = MolecularGraphs.from_spectra(SpectraCollection(spectra)) + np.testing.assert_array_equal(graphs.index, [0, 0, 1, -1]) + assert MolecularGraphs.from_spectra(graphs) is MolecularGraphs.from_mols(graphs) is graphs + s = CudaMyopicMCES(batch_size=2) + expected = [[0, 0, 1, np.nan], [0, 0, 1, np.nan], [1, 1, 0, np.nan], [np.nan] * 4] + direct = calculate_scores(spectra, iter(spectra), s) + np.testing.assert_equal(direct.to_array("score"), expected) + monkeypatch.setattr(Chem, "MolFromSmiles", lambda *_: pytest.fail("reparsed a prepared graph")) + dense = s.matrix(graphs, array_type="numpy") + np.testing.assert_equal(dense["score"], expected) + np.testing.assert_equal(dense["exact"], np.isfinite(expected)) + for result in (direct, s.sparse_matrix(graphs)): + path = tmp_path / "distances.npz" + result.save(path) + loaded = Scores.load(path) + np.testing.assert_equal(loaded.to_array("score"), expected) + np.testing.assert_equal(loaded.to_array("exact"), dense["exact"]) + + +@pytest.mark.github_ci +def test_sparse_zero_projection_and_torch(): + s = CudaMyopicMCES(1.5, False) + mols = [Chem.MolFromSmiles(x) for x in ("CC", "NN", "CCC")] + g = MolecularGraphs.from_mols(mols) + assert s.pair(g.from_smiles(["CC"]), mols[1]).item() == (1.5, False) + r = s.sparse_matrix(g, idx_row=[1, 0, 2, 2], idx_col=[0, 0, 0, 0], max_distance=1.5, + exact_only=True, score_filter=lambda v: v["exact"], score_fields="score") + coo = r.to_coo() + assert sorted(zip(coo.row, coo.col, coo.data)) == [(0, 0, 0), (0, 2, 1), (2, 0, 1)] + dense = s.matrix(mols, score_fields=("exact", "score"), array_type="torch") + assert dense.is_cuda == (not cuda.config.ENABLE_CUDASIM) + np.testing.assert_array_equal(dense[0].cpu(), [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) + np.testing.assert_array_equal(dense[1].cpu(), [[0, 1.5, 1], [1.5, 0, 1.5], [1, 1.5, 0]]) + assert r.score_fields == ("score",) + params = json.loads(json.dumps(s.to_dict())) + assert params.pop("__Similarity__") == "CudaMyopicMCES" + assert CudaMyopicMCES(**params).to_dict() == s.to_dict() + + +@pytest.mark.github_ci +def test_coordinates_empty_and_invalid(): + s = CudaMyopicMCES() + assert s.matrix([], ["CC"]).shape == (0, 1) + assert s.sparse_matrix(["C"], [], idx_row=[], idx_col=[]).shape == (1, 0) + for invalid in ("", None, "not-smiles"): + score = s.pair(invalid, "C") + assert np.isnan(score["score"]) and not score["exact"] + for row, col, error in [([1], [0], ValueError), ([-1], [0], ValueError), + ([0.5], [0], TypeError), ([0], None, ValueError)]: + with pytest.raises(error): + s.sparse_matrix(["C"], idx_row=row, idx_col=col) + + +def test_mgf_generator(): + from simms.utils import download + + mgf = load_from_mgf(download("pesticides.mgf")) + graphs = MolecularGraphs.from_spectra(islice(mgf, 4)) + assert len(graphs) == 4 + actual = CudaMyopicMCES().matrix(islice(load_from_mgf(download("pesticides.mgf")), 4)) + expected = CudaMyopicMCES().matrix(graphs) + np.testing.assert_equal(actual.to_array("score"), expected.to_array("score")) + assert (actual.to_array("score").diagonal() == 0).all() + + +@pytest.mark.github_ci +def test_cpu_only_message(monkeypatch): + import torch + + monkeypatch.setattr(cuda.config, "ENABLE_CUDASIM", 0) + monkeypatch.setattr(torch.cuda, "is_available", lambda: False) + with pytest.raises(RuntimeError, match="NUMBA_ENABLE_CUDASIM=1"): + CudaMyopicMCES() + + +@pytest.mark.github_ci +def test_same_atom_degrees_different_neighbor_elements(): + assert CudaMyopicMCES(1).pair("CO.CO", "CC.OO").item() == (4, False) + assert CudaMyopicMCES(1, False).pair("CO.CO", "CC.OO").item() == (1, False) + + +@pytest.mark.github_ci +def test_rdkit_bond_orders_survive_deduplication(): + aromatic = Chem.MolFromSmiles("c1ccccc1") + alternating = Chem.Mol(aromatic) + Chem.Kekulize(alternating, clearAromaticFlags=False) + graphs = MolecularGraphs.from_mols([aromatic, alternating, aromatic]) + np.testing.assert_equal(graphs.index, [0, 1, 0]) + assert set(graphs.graphs[0].adjacency.ravel()) == {0, 3} + assert set(graphs.graphs[1].adjacency.ravel()) == {0, 2, 4} + assert CudaMyopicMCES().pair(aromatic, alternating).item() == (3, True) + + +def test_above_default_atom_limit_and_torch_stream(): + import torch + + chain = "C" * 65 + for cap in (64, 65): + s = CudaMyopicMCES(None, max_gpu_atoms=cap) + assert s.pair(chain, "CC").item() == (63, True) + if not cuda.config.ENABLE_CUDASIM: + stream = torch.cuda.Stream() + with torch.cuda.stream(stream): + tensor = CudaMyopicMCES(None, max_frames=1).matrix( + ["C1CCCCC1"], ["C1CC1.C1CC1"], array_type="torch", progress_bar=False + ) + np.testing.assert_equal(tensor.cpu().numpy().ravel(), [4, 1]) diff --git a/tests/similarity/test_workflow_edge_cases.py b/tests/similarity/test_workflow_edge_cases.py index 8365506..7c2bc5c 100644 --- a/tests/similarity/test_workflow_edge_cases.py +++ b/tests/similarity/test_workflow_edge_cases.py @@ -487,7 +487,9 @@ def test_nonfingerprint_scores_without_chemap(): from matchms import Spectrum s = Spectrum(np.array([1.]), np.array([1.]), {"precursor_mz": 100.}) for name in gpu.__all__: - if name not in ("CudaFingerprintSimilarity", "CudaModifiedCosine"): + if name == "CudaMyopicMCES": + assert np.isnan(gpu.CudaMyopicMCES().matrix([s]).to_array("score").item()) + elif name not in ("CudaFingerprintSimilarity", "CudaModifiedCosine"): scores = getattr(gpu, name)().matrix(iter([s]), progress_bar=False) assert scores.to_array("score").item() == 1., name """