Skip to content

Python bindings and benchmark for substructlib - #360

Merged
scal444 merged 1 commit into
NVIDIA-BioNeMo:mainfrom
scal444:substructlib-3c-python-api
Oct 8, 2026
Merged

scal444 merged 1 commit into
NVIDIA-BioNeMo:mainfrom
scal444:substructlib-3c-python-api

Conversation

@scal444

@scal444 scal444 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

PR 5 of 6 for #350

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds GPU-accelerated substructure search library with Python bindings.

Cap the Python query workers before merging to prevent thread exhaustion with small batches and many concurrent queries.

Findings

  1. P1 Queries exhaust host threads ▶
Summary

Adds Python access to persistent GPU substructure libraries and a benchmark against RDKit.

  • Provides background queries and synchronous convenience methods.
  • Adds API documentation and tests for library growth, query results, and failed finalization.
  • Records backend settings and build/query timings.
  • The Python worker count needs a host-side cap before merging.
  • Both unnumbered previous findings are addressed: the docs explain the chiral SMARTS limit, and saved rows include the requested settings.

Reviews (3) · Last reviewed commit: "Expose SubstructLibrary to Python and be..." · Reviewed by Greptile

Comment thread nvmolkit/substruct_library.py Outdated
Comment thread benchmarks/substruct_library_bench.py
@scal444
scal444 force-pushed the substructlib-3c-python-api branch from 3a7526a to dc6b75f Compare October 8, 2026 14:55
nvmolkit.substruct_library.SubstructLibrary wraps the native library:
queries return concurrent.futures.Future objects from an executor sized
to maxConcurrentQueries, with blocking *Sync variants. finalize() swaps in
a resized executor without draining queued queries, so done-callbacks may
submit queries or finalize again. The bindings release the GIL around
every call that can wait on the library lock.

substruct_library_bench.py adds and finalizes one library per backend
configuration, then times has/count/get query sweeps against it, serially
or with all queries in flight, alongside RDKit's SubstructLibrary with a
MolHolder or a pattern-fingerprint CachedMolHolder. nvMolKit results are
validated against RDKit over the queries RDKit completed before its
deadline, and rows are printed or written as CSV.
@scal444
scal444 requested a review from evasnow1992 October 8, 2026 15:31
@scal444
scal444 force-pushed the substructlib-3c-python-api branch from dc6b75f to fbda3d8 Compare October 8, 2026 15:31
Comment thread nvmolkit/substruct_library.py

@evasnow1992 evasnow1992 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.

@scal444
scal444 merged commit 03db673 into NVIDIA-BioNeMo:main Oct 8, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants