Nvmolkit Usage
NVIDIAOfficialCreated by Kevin Boyd (@scal444)Distributed by NVIDIA
- Skill
- Tool integration
- Software development
- Apache-2.0
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
nvMolKit provides a Python API for high-throughput molecular operations by leveraging NVIDIA GPUs. It mirrors RDKit's API structure while enabling parallel processing of large batches of molecules. The library is designed for scenarios where throughput is prioritized over per-molecule latency, such as fingerprinting large libraries, bulk conformer embedding, or pairwise similarity calculations. It integrates with PyTorch for GPU-resident data handling, allowing for efficient chaining of operations without host-side round-trips.
What it does
- Generates Morgan fingerprints in parallel on GPU.
- Performs bulk Tanimoto and cosine similarity calculations.
- Executes ETKDG conformer embedding and MMFF/UFF forcefield optimizations.
- Calculates pairwise conformer RMSD and Torsion Fingerprint Deviation (TFD).
- Provides GPU-accelerated Butina clustering and substructure searching.
- Supports custom geometric constraints and forcefield configurations.
When to use it
- When processing large batches of molecules (thousands or more).
- When the same operation is repeated identically across a large dataset.
- When you need to chain multiple molecular operations while keeping data on the GPU.
- When optimizing for total wall-clock time across a batch.
Advantages
- Significant throughput improvements for batch-oriented cheminformatics tasks.
- Seamless integration with PyTorch for zero-copy GPU data exchange.
- Supports asynchronous execution and custom CUDA stream control.
- Provides flexible hardware tuning and autotuning capabilities.
Usage examples
- “How do I calculate Morgan fingerprints for a list of SMILES strings using nvMolKit?”
- The agent provides code to initialize a MorganFingerprintGenerator, process the list of RDKit Mol objects, and retrieve the results as a GPU-resident torch tensor.
- “Can I perform MMFF94 minimization on a batch of conformers?”
- The agent demonstrates using MMFFOptimizeMoleculesConfs to update conformer coordinates in-place on the GPU, returning optimized energies.
- “How do I run a substructure search on a large library?”
- The agent explains how to use the substructure module, including configuring batch sizes and worker threads for optimal GPU performance.
- “How can I chain ETKDG embedding and similarity scoring without moving data to the CPU?”
- The agent shows how to use CoordinateOutput.DEVICE to keep conformer coordinates on the GPU and pass them directly into downstream similarity or clustering functions.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/nvidia/nvmolkit-usage/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip nvmolkit-usage.zip -d .agents/skills
Documentation by Kevin Boyd (@scal444)
nvMolKit usage
Purpose
GPU-accelerated, batched implementations of common RDKit operations. APIs mirror RDKit where possible but are batch-oriented: they take lists of rdkit.Chem.Mol (or lists of fingerprints) and process them in parallel on one or more GPUs. nvMolKit links against RDKit at build time; inputs and outputs are real RDKit Mol objects.
This skill covers the installed Python API. Building nvMolKit from source is out of scope.
Where nvMolKit does well
Reach for nvMolKit when:
The workload is a large batch of molecules processed together (typically thousands or more).
The metric is throughput / total wall time across the batch, not per-molecule latency.
The same operation is repeated identically across the batch (fingerprinting a library, embedding/minimizing many conformers, bulk pairwise similarity), so the GPU stays saturated.
Requirements
An NVIDIA GPU with compute capability 7.0 (V100) or higher
A CUDA driver compatible with CUDA 12.6+.
A working
torchinstall with CUDA support (nvMolKit returns GPU tensors viatorch's CUDA array interface).
When helping with installation, make the user choose a PyTorch CUDA backend that the host driver supports before installing nvMolKit. nvMolKit's PyPI wheels are built with CUDA Toolkit 12.9 and depend on CUDA 12 runtime packages, but pip/uv can still select a CUDA 13 PyTorch wheel unless the install command says otherwise.
Conda: prefer conda-forge
pytorch-gpu; pincuda-version=12.6or another CUDA version supported by the driver.pip: send the user to the PyTorch install selector or previous-versions page to install
torchfor a CUDA 12.x backend before installing nvMolKit.uv: install nvMolKit with an explicit backend, e.g.
uv pip install --torch-backend=cu128 nvmolkit.
Inputs
Required: choose an operation and supply molecules or fingerprints from the user's code or molecular dataset. Parse SMILES with RDKit and reject failed parses (
None).Molecular operations use RDKit
Molobjects. Add hydrogens for ETKDG; minimization and conformer comparisons need existing conformers.Fingerprint similarity takes packed
AsyncGpuResult, torch tensors, or NumPy arrays: one molecule per row, withint32oruint32words.Optional: take conformer counts, fingerprint settings, cutoffs, output modes, and hardware options from the user's requested workflow; otherwise use the documented API defaults.
Limitations
CUDA is required; there is no CPU fallback. Use RDKit directly when CPU execution is needed.
Plain RDKit is usually preferable for single-molecule work or operations that cannot be batched.
ETKDG does not support custom bounds matrices, custom CPCI, coordinate maps, or separate-fragment embedding.
Substructure search does not support chirality-aware matching, enhanced stereochemistry, or other advanced RDKit
SubstructMatchParametersoptions.
Instructions
Run the smoke test below before writing nvMolKit code.
Choose an API from the entry-point table and apply its input requirements.
Handle its result as described below; synchronize asynchronous GPU results before host reads.
Verify the install before writing real code
import nvmolkit
import torch
from rdkit import Chem
from nvmolkit.fingerprints import MorganFingerprintGenerator
print("nvmolkit:", nvmolkit.__version__)
print("cuda available:", torch.cuda.is_available())
print("device count:", torch.cuda.device_count())
mols = [Chem.MolFromSmiles(smi) for smi in ["CCO", "c1ccccc1", "CC(=O)O"]]
fpgen = MorganFingerprintGenerator(radius=2, fpSize=1024)
result = fpgen.GetFingerprints(mols)
torch.cuda.synchronize()
fps = result.torch()
print("fps shape:", tuple(fps.shape), "dtype:", fps.dtype)
# Expected: shape (3, 32), dtype torch.int32 (1024 bits packed into 32 int32s per row)If this fails, point the user at the installation guide rather than guessing.
Entry points
| Task | Module | Primary entry point |
|---|---|---|
| Morgan fingerprints | nvmolkit.fingerprints | MorganFingerprintGenerator(radius, fpSize).GetFingerprints(mols) |
| Bulk Tanimoto / cosine similarity | nvmolkit.similarity | crossTanimotoSimilarity(...), crossCosineSimilarity(...), plus *MemoryConstrained variants for results too large to fit in GPU memory |
| ETKDG conformer embedding | nvmolkit.embedMolecules | EmbedMolecules(molecules, params, confsPerMolecule, ...) |
| MMFF94 optimization (one-shot) | nvmolkit.mmffOptimization | MMFFOptimizeMoleculesConfs(molecules, ..., minimizerKind=..., fireOptions=...) |
| UFF optimization (one-shot) | nvmolkit.uffOptimization | UFFOptimizeMoleculesConfs(molecules, ..., minimizerKind=..., fireOptions=...) |
| Forcefield with custom options + constraints | nvmolkit.batchedForcefield | MMFFBatchedForcefield(mols, properties=..., nonBondedThreshold=..., ignoreInterfragInteractions=..., hardwareOptions=...), UFFBatchedForcefield(mols, vdwThreshold=..., ...). Per-molecule view ff[i] exposes add_distance_constraint, add_position_constraint, add_angle_constraint, add_torsion_constraint. Methods: .compute_energy(), .compute_gradients(), .minimize(maxIters, forceTol, minimizerKind=..., fireOptions=...) |
| Pairwise conformer RMSD | nvmolkit.conformerRmsd | GetConformerRMSMatrix(mol), GetConformerRMSMatrixBatch(mols) |
| Torsion Fingerprint Deviation (TFD) | nvmolkit.tfd | GetTFDMatrix(mol), GetTFDMatrices(mols) |
| Butina clustering | nvmolkit.clustering | butina(distance_matrix, cutoff) (precomputed matrix), fused_butina(fingerprints, cutoff) (memory-efficient, on-the-fly); both support explicit RDKit and device output modes |
| Substructure search | nvmolkit.substructure | hasSubstructMatch, countSubstructMatches, getSubstructMatches |
| Maximum common substructure | nvmolkit.mcs | findMCS(mols, ...) for all pairs, explicit pairs, or two paired molecule lists |
| Hardware tuning (batch size, GPU IDs) | nvmolkit.types | HardwareOptions(...) passed to ETKDG / MMFF / UFF |
| Optional autotuning | nvmolkit.autotune | tune_embed_molecules, tune_mmff_optimize, tune_uff_optimize, tune_batched_forcefield, tune_substructure, tune_mcs. Requires the optuna package |
Result types and execution model
Two return shapes carry GPU-resident output, depending on what the operation produces.
AsyncGpuResult
Used by operations that return a single flat tensor (fingerprints, similarity matrices, RMSD/TFD vectors, Butina inputs). Key behaviors:
Asynchronous. The kernel may not have completed when the call returns.
result.torch()returns a zero-copytorch.Tensoron the GPU. Caller is responsible for synchronizing before reading values on the host.result.numpy()synchronizes and returns a CPU numpy array.Exposes
__cuda_array_interface__, so it can be passed directly into other nvMolKit functions (e.g. fingerprints → similarity) with no host round-trip.
CUDA stream control
A subset of the AsyncGpuResult-returning APIs accept an optional stream: torch.cuda.Stream | None = None argument so callers can submit nvMolKit work to a non-default stream and overlap it with their own kernels. When omitted, the call uses the current torch stream.
APIs that take a stream argument:
MorganFingerprintGenerator.GetFingerprintscrossTanimotoSimilarity,crossCosineSimilarity, and their*MemoryConstrainedvariantsbutina,fused_butinaGetConformerRMSMatrix,GetConformerRMSMatrixBatch
Other APIs (ETKDG, MMFF/UFF optimization, TFD, substructure search, MCS) are synchronous to the caller — no stream plumbing needed.
Typical pattern:
import torch
from rdkit import Chem
from nvmolkit.fingerprints import MorganFingerprintGenerator
from nvmolkit.similarity import crossTanimotoSimilarity
stream = torch.cuda.Stream()
fpgen = MorganFingerprintGenerator(radius=2, fpSize=1024)
mols = [Chem.MolFromSmiles(smi) for smi in ["CCO", "c1ccccc1", "CC(=O)O"]]
with torch.cuda.stream(stream):
fps = fpgen.GetFingerprints(mols, stream=stream)
sim = crossTanimotoSimilarity(fps, stream=stream)
stream.synchronize()
print(sim.torch())Device3DResult
Used by ETKDG embedding and MMFF/UFF optimization (one-shot and BatchedForcefield) when called with output=CoordinateOutput.DEVICE. The GPU-resident equivalent of writing conformers back to Mol objects. Fields:
values:AsyncGpuResultof shape(total_atoms, 3)float64. Concatenated conformer coordinates in CSR-style layout.atom_starts,mol_indices,conf_indices:AsyncGpuResultint32 buffers describing the layout (values[atom_starts[i]:atom_starts[i+1]]is conformeri's atoms).energies,converged:AsyncGpuResultbuffers populated only for MMFF/UFF minimization (not for plain ETKDG).gpu_id: device the buffers live on. ThetargetGpuargument on each API picks this;targetGpu=-1uses the default consolidation device..per_molecule()returns nestedlist[list[torch.Tensor]]of per-conformer views;.dense(pad_value=nan)materializes a padded(n_mols, max_confs, max_atoms, 3)tensor.
The default mode (CoordinateOutput.RDKIT_CONFORMERS) still writes optimized coordinates back into each Mol and returns Python lists of energies/convergence flags. Reach for CoordinateOutput.DEVICE when chaining downstream GPU work (e.g. ETKDG → MMFF → similarity scoring) without host round-trips.
MCSBatchResult
findMCS is synchronous and returns an MCSBatchResult backed by CPU NumPy
arrays. Results are always flat: result[k] (or result.get_result(k))
materializes the result at pair position k, not generally the result for
molecule k. Use result.pairs[k] to identify that pair. In all_pairs mode
these are the generated pairs over mols; in pairs mode they exactly preserve
the supplied pair sequence; in paired_lists mode item k compares mols[k]
with mols_b[k], while result.pairs[k] uses the combined-table indices
(k, len(mols) + k). Each MCSResult has pair, num_atoms, num_bonds,
canceled, atom_mapping, and bond_mapping; the two columns of each mapping
index the first and second molecule of that result pair, respectively.
Configuration
For ETKDG, forcefield, substructure, or MCS tuning, read the advanced configuration reference. It lists configuration fields, defaults, GPU selection, and autotuning APIs.
Examples
Morgan fingerprints + bulk Tanimoto similarity
import torch
from rdkit import Chem
from nvmolkit.fingerprints import MorganFingerprintGenerator
from nvmolkit.similarity import crossTanimotoSimilarity
smiles = ["CCO", "CCN", "c1ccccc1", "CC(=O)O", "CCOCC"]
mols = [Chem.MolFromSmiles(smi) for smi in smiles]
fpgen = MorganFingerprintGenerator(radius=2, fpSize=1024)
fps = fpgen.GetFingerprints(mols)
sim = crossTanimotoSimilarity(fps)
torch.cuda.synchronize()
print(sim.torch())Inputs are list[Mol]. Output of GetFingerprints is an AsyncGpuResult wrapping an (n_mols, fpSize / 32) int32 tensor of packed bits. Pass it straight into crossTanimotoSimilarity for an (n, n) similarity matrix; pass two fingerprint sets for an (n, m) cross-matrix. For sets too large to materialize on the GPU, use crossTanimotoSimilarityMemoryConstrained (chunked compute, returns numpy on CPU).
ETKDG conformer embedding
from rdkit.Chem import AddHs, MolFromSmiles
from rdkit.Chem.rdDistGeom import ETKDGv3
from nvmolkit.embedMolecules import EmbedMolecules
mols = [AddHs(MolFromSmiles(smi)) for smi in ["C1CCCCC1", "C1CCCCC2CCCCC12", "COO"]]
params = ETKDGv3()
EmbedMolecules(mols, params, confsPerMolecule=10, maxIterations=-1)
for mol in mols:
print(mol.GetNumConformers())Inputs are sanitized list[Mol] with hydrogens added (AddHs). Conformers are added in-place; see Limitations for unsupported embedding options.
MMFF94 minimization of a batch of conformers
from rdkit.Chem import AddHs, MolFromSmiles
from rdkit.Chem.rdDistGeom import ETKDGv3
from nvmolkit.embedMolecules import EmbedMolecules
from nvmolkit.mmffOptimization import MMFFOptimizeMoleculesConfs
mols = [AddHs(MolFromSmiles(smi)) for smi in ["CCO", "CCN", "c1ccccc1"]]
params = ETKDGv3()
EmbedMolecules(mols, params, confsPerMolecule=5)
energies = MMFFOptimizeMoleculesConfs(mols, maxIters=500)
for mol, mol_energies in zip(mols, energies):
print(mol.GetNumConformers(), mol_energies)Inputs are list[Mol] with conformers already populated (typically by ETKDG, RDKit's EmbedMultipleConfs, or a prior nvMolKit call). Coordinates are updated in place; the return is list[list[float]] of optimized energies aligned with the input molecule order and conformer index. UFF is identical in shape: swap in from nvmolkit.uffOptimization import UFFOptimizeMoleculesConfs.
BFGS is the default minimizer. To use FIRE, pass minimizerKind="FIRE";
optionally customize it with a
nvmolkit.types.FireOptions instance through fireOptions=. The one-shot MMFF
and UFF functions and both batched-forcefield .minimize() methods accept the
same selector.
If any input molecule is None or lacks MMFF/UFF atom types, the call raises ValueError. The exception's args[1] is a dict with keys "none" and "no_params" listing the offending indices - useful for filtering a noisy input set.
Conformer RMSD and Butina clustering
import torch
from rdkit import Chem
from rdkit.Chem.rdDistGeom import EmbedMultipleConfs
from nvmolkit.clustering import ButinaOutputMode, butina
from nvmolkit.conformerRmsd import GetConformerRMSMatrixBatch
mols = [Chem.AddHs(Chem.MolFromSmiles(smi)) for smi in ["CCCCCC", "c1ccccc1"]]
for mol in mols:
EmbedMultipleConfs(mol, numConfs=10)
# Remove hydrogens after embedding for heavy-atom RMSD.
heavy_mols = [Chem.RemoveHs(mol) for mol in mols]
# Default RMSD output is RDKit-compatible condensed lower-triangle form.
condensed = GetConformerRMSMatrixBatch(heavy_mols)
# Butina expects a square distance matrix, so request square GPU tensors.
square = GetConformerRMSMatrixBatch(heavy_mols, output_format="square")
results = [
butina(distance_matrix, cutoff=0.5, output=ButinaOutputMode.DEVICE)
for distance_matrix in square
]
torch.cuda.synchronize()
for result in results:
print(result.cluster_ids.torch().cpu().tolist())Both Butina functions return GPU-resident results by default:
The default,
output=ButinaOutputMode.DEVICE, returns cluster IDs, centroids, and sizes.output=ButinaOutputMode.RDKITreturns RDKit cluster tuples on the host. The first element of each cluster is its centroid.
The device output fields are AsyncGpuResult objects. Use .torch() to access
their CUDA tensors without a host copy or .numpy() to synchronize and copy a
field to the host.
GetConformerRMSMatrix(mol) and GetConformerRMSMatrixBatch(mols) default to output_format="condensed", returning AsyncGpuResult objects that wrap RDKit-style flat vectors of length N * (N - 1) // 2. Use output_format="square" when chaining into butina() or any other API that expects an N x N distance matrix. Both forms live on the GPU; call .numpy() on condensed results or synchronize before moving square tensors to the CPU.
Atom-Atom Path similarity and directed sphere exclusion clustering
Atom-Atom Path (AAP) similarity with directed sphere exclusion (DISE) clustering provides device and RDKit-style output modes:
from rdkit import Chem
from nvmolkit.clustering import DISEOutputMode, aap_dise
molecules = [Chem.MolFromSmiles(smiles) for smiles in ["CCCC", "CCCO", "CCOC"]]
device_result = aap_dise(molecules)
rdkit_clusters = aap_dise(molecules, output=DISEOutputMode.RDKIT)device_result has cluster_ids, centroids, and cluster_sizes fields;
cluster IDs are zero-based and contiguous. DISEOutputMode.RDKIT describes
the centroid-first RDKit cluster representation, not an RDKit implementation
of the AAP+DISE algorithm. The current DISE control loop synchronizes before
returning either mode; DEVICE describes the stable schema and where the
result resides, not asynchronous execution of the overall call.
Maximum common substructure search
from rdkit import Chem
from nvmolkit.mcs import findMCS
mols = [Chem.MolFromSmiles(smi) for smi in ["CCO", "CCN", "c1ccccc1O"]]
result = findMCS(mols, mode="pairs", pairs=[(0, 1), (0, 2)])
for pair_idx, pair in enumerate(result.pairs):
item = result[pair_idx]
print(pair, item.num_atoms, item.num_bonds, item.atom_mapping)The default mode="all_pairs" generates the upper triangle including the
diagonal. mode="pairs" preserves an explicit pair list exactly, including
duplicates and reversed pairs. mode="paired_lists" zips mols with an
equally sized mols_b. Timeouts are per pair; inspect item.canceled because a
timed-out result can contain the best partial MCS found.
Matching options include atom_compare, bond_compare, valence/formal-charge
matching, and atom/bond ring-only matching. Unsupported RDKit fMCS options
raise instead of silently changing semantics. For repeated representative
explicit-pair workloads, nvmolkit.autotune.tune_mcs returns a TuneResult.
Its best_config is the tuned MCSConfig to pass to
findMCS(..., config=result.best_config).
Custom forcefield options + constraints (BatchedForcefield)
For per-molecule forcefield settings, geometric constraints, or separate energy and gradient calls, read the advanced forcefield recipe.
Troubleshooting
| Symptom | Likely cause | Action |
|---|---|---|
torch.cuda.is_available() is false | GPU access, driver compatibility, or the torch CUDA build is missing | Check the GPU and driver, then follow the installation guidance above to select a compatible torch build. |
RuntimeError: invalid device ordinal | A requested gpuIds entry is not visible | Use device indices below torch.cuda.device_count() or the API's documented GPU defaults. |
| An RDKit option is rejected | The option is unsupported by that nvMolKit API | Use supported options only if they preserve the requested behavior; otherwise use RDKit for that operation. |
Going deeper
Full feature list, API reference, and guides: https://nvidia-bionemo.github.io/nvMolKit/
What changed in each release: https://nvidia-bionemo.github.io/nvMolKit/changelog.html
Worked examples (Jupyter notebooks): the examples/ directory in the GitHub repo
Files
- ATTRIBUTION.mdAdded by AutoGineer931 B
- BENCHMARK.md8.3 KiB
- LICENSELicence file added by AutoGineer11.2 KiB
- SKILL.md18.8 KiB
- evals/evals.json21.4 KiB
- evals/trigger_evals.json1.1 KiB
- references/advanced-usage.md4.5 KiB
- skill-card.md4.4 KiB
- skill.oms.sig4.9 KiB
evals/evals.json
{
"skill_name": "nvmolkit-usage",
"evals": [
{
"id": "nvmolkit-usage-001",
"prompt": "Set up nvMolKit from scratch in a fresh conda-managed environment on a CUDA-capable Linux workstation. Include install commands and a small Python smoke test that verifies the installed package can process a batch of RDKit molecules on GPU.",
"expected_output": "The agent creates and activates a conda environment, installs nvMolKit and GPU-enabled PyTorch from conda-forge with a CUDA version compatible with the host driver, and supplies a smoke test that checks CUDA and computes batched Morgan fingerprints.",
"assertions": [
"The agent read or referenced the nvmolkit-usage SKILL.md for installation and runtime requirements",
"The agent creates and activates a conda, mamba, or micromamba environment with a supported Python version",
"The agent installs nvmolkit from conda-forge and ensures that PyTorch is GPU-enabled rather than silently accepting a CPU-only solve",
"The agent explains how to choose a cuda-version compatible with the driver reported by nvidia-smi",
"The smoke test imports nvMolKit, torch, and RDKit and checks torch.cuda.is_available()",
"The smoke test calls MorganFingerprintGenerator.GetFingerprints once on a list of RDKit molecules and safely inspects the AsyncGpuResult with .numpy() or synchronization before a host read through .torch()",
"The agent does not recommend building nvMolKit from source for this package-install task"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-002",
"prompt": "Set up nvMolKit from scratch in a uv-managed Python environment. Include commands to create the environment, install nvMolKit from its Python package distribution, and run a small Python smoke test that verifies the installed package can process a batch of RDKit molecules on GPU.",
"expected_output": "The agent creates a uv environment with a supported Python version, selects a compatible CUDA 12 PyTorch backend while installing nvmolkit, and supplies a CUDA-aware batched Morgan fingerprint smoke test.",
"assertions": [
"The agent read or referenced the nvmolkit-usage SKILL.md for uv installation and runtime requirements",
"The agent uses uv venv or uv init with a supported Python version",
"The agent installs nvmolkit through uv and explicitly selects or preinstalls a PyTorch CUDA backend compatible with the host driver",
"The agent states that nvMolKit requires a supported CUDA-capable NVIDIA GPU and GPU-enabled torch",
"The smoke test imports nvMolKit, torch, and RDKit and checks CUDA availability",
"The smoke test calls MorganFingerprintGenerator.GetFingerprints once on a molecule list and safely inspects the result",
"The agent does not switch the requested uv workflow to conda or a source build"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-003",
"prompt": "Port the following RDKit code to nvMolKit. Preserve the behavior.\n\n```python\nfrom rdkit import Chem, DataStructs\nfrom rdkit.Chem import rdFingerprintGenerator\nfrom rdkit.ML.Cluster import Butina\nimport numpy as np\n\nsmiles = [\n \"CCO\", \"CCN\", \"CC(=O)O\", \"CCCCCC\", \"C1CCCCC1\",\n \"c1ccccc1\", \"Cc1ccccc1\", \"Oc1ccccc1\",\n \"CC(=O)Oc1ccccc1C(=O)O\", \"c1ccncc1\",\n]\nmols = [Chem.MolFromSmiles(s) for s in smiles]\nfpgen = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)\nfps = [fpgen.GetFingerprint(m) for m in mols]\nsim = np.array([DataStructs.BulkTanimotoSimilarity(fp, fps) for fp in fps])\ndist = 1.0 - sim\nclusters = Butina.ClusterData(\n dist[np.tril_indices(len(mols), -1)], len(mols), 0.35, isDistData=True\n)\n```",
"expected_output": "The agent provides a complete batched nvMolKit port that parses RDKit molecules, computes packed Morgan fingerprints once for the collection, keeps fingerprint-to-similarity processing on GPU, and clusters with the nvMolKit Butina API using its required input type and shape.",
"assertions": [
"The agent uses nvmolkit.fingerprints.MorganFingerprintGenerator(radius=2, fpSize=2048) and calls GetFingerprints once on the molecule collection rather than once per molecule",
"The agent feeds the GPU-resident fingerprint result directly to crossTanimotoSimilarity without an intervening NumPy conversion",
"The agent uses nvmolkit.clustering.butina with a full square GPU distance matrix or fused_butina with a CUDA torch tensor of packed fingerprints",
"The agent does not pass an RDKit-style condensed lower triangle or a CPU NumPy matrix to nvmolkit.clustering.butina",
"The agent handles the 0.35 distance cutoff consistently, converting similarity to distance when using butina",
"Any host read uses blocking .numpy() or synchronizes before reading values through .torch()",
"The resulting code reports cluster assignments aligned with the input molecules"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-004",
"prompt": "Port the following RDKit code to nvMolKit. Preserve the behavior.\n\n```python\nfrom rdkit import Chem\nfrom rdkit.Chem import AllChem\nfrom rdkit.Chem.rdDistGeom import ETKDGv3\n\nsmiles = [\n \"CCO\", \"CCN\", \"CC(=O)O\", \"CCCCCC\", \"C1CCCCC1\",\n \"c1ccccc1\", \"Cc1ccccc1\", \"Oc1ccccc1\",\n \"CC(=O)Oc1ccccc1C(=O)O\", \"c1ccncc1\",\n]\nmols = [Chem.AddHs(Chem.MolFromSmiles(s)) for s in smiles]\nparams = ETKDGv3()\nparams.randomSeed = 7\nfor mol in mols:\n AllChem.EmbedMultipleConfs(mol, numConfs=20, params=params)\n AllChem.MMFFOptimizeMoleculeConfs(mol, maxIters=500)\n rms = AllChem.GetConformerRMSMatrix(Chem.RemoveHs(mol))\n```",
"expected_output": "The agent provides a complete nvMolKit port using batched embedding, batched MMFF optimization, and the batch conformer RMSD API, with nvMolKit-compatible ETKDG parameters and safe result handling.",
"assertions": [
"The agent creates explicit-hydrogen RDKit molecules with Chem.AddHs before embedding",
"The agent creates ETKDGv3 parameters without setting useRandomCoords",
"The agent calls nvmolkit.embedMolecules.EmbedMolecules once on the molecule collection with confsPerMolecule=20",
"The agent calls MMFFOptimizeMoleculesConfs once on the molecule collection with maxIters=500 instead of retaining the RDKit per-molecule optimization loop",
"The agent calls GetConformerRMSMatrixBatch on the heavy-atom molecule collection",
"The agent treats GetConformerRMSMatrixBatch output as one AsyncGpuResult per input molecule rather than calling .numpy() or .torch() on the returned list",
"The agent safely converts or synchronizes each asynchronous RMSD result before host inspection"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-005",
"prompt": "Port the following RDKit code to nvMolKit. Preserve the behavior, including the all-match counting convention used by the RDKit code.\n\n```python\nfrom rdkit import Chem\n\nsmiles = [\n \"CCO\", \"CCN\", \"CC(=O)O\", \"CCCCCC\", \"C1CCCCC1\",\n \"c1ccccc1\", \"Cc1ccccc1\", \"Oc1ccccc1\",\n \"CC(=O)Oc1ccccc1C(=O)O\", \"c1ccncc1\",\n]\nquery = Chem.MolFromSmarts(\"c1ccccc1\")\nrows = []\nfor smi in smiles:\n mol = Chem.MolFromSmiles(smi)\n matches = mol.GetSubstructMatches(query, uniquify=False)\n rows.append((smi, bool(matches), len(matches)))\n```",
"expected_output": "The agent provides a batched nvMolKit substructure workflow using a target collection and a one-element SMARTS query collection, with uniquify disabled and both boolean and count results reported in input order.",
"assertions": [
"The agent parses target molecules with Chem.MolFromSmiles and constructs the query with Chem.MolFromSmarts('c1ccccc1')",
"The agent uses nvMolKit hasSubstructMatch plus countSubstructMatches, or getSubstructMatches and derives both values from the returned matches",
"The agent passes target and query collections to the nvMolKit API, using [query] for the one-query batch",
"The agent preserves the all-match convention by leaving SubstructSearchConfig.uniquify false",
"The agent does not duplicate the query once per target and incorrectly interpret a target-by-target diagonal as the result",
"The agent emits one boolean/count row per input target in input order, including false/zero rows"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-006",
"prompt": "Write a from-scratch nvMolKit workflow that computes Morgan fingerprints with radius 2 and fpSize 2048, computes an all-pairs Tanimoto similarity matrix, clusters molecules with Butina at distance cutoff 0.35, and reports cluster assignments. Fill in the `<your code here>` section; keep the loading header and printing footer intact.\n\n```python\nimport argparse\nimport json\nfrom pathlib import Path\nfrom rdkit import Chem\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--input\", default=\"input.smi\")\nargs, _ = parser.parse_known_args()\n\nsmiles = [\n line.split()[0]\n for line in Path(args.input).read_text().splitlines()\n if line.strip() and not line.startswith(\"#\")\n]\nmols = [Chem.MolFromSmiles(smi) for smi in smiles]\n\n# <your code here>\n\nprint(json.dumps({\n \"similarity\": similarity_matrix.tolist(),\n \"clusters\": cluster_assignments,\n}, sort_keys=True))\n```",
"expected_output": "The agent writes a complete batch-oriented nvMolKit fingerprint, similarity, and clustering workflow with correct GPU dataflow, cutoff semantics, and JSON reporting.",
"assertions": [
"The code reads SMILES, parses them into RDKit molecules, and validates or handles failed parses",
"The code computes all fingerprints with one MorganFingerprintGenerator.GetFingerprints call over the collection or suitably large chunks",
"The code computes all-pairs similarity with crossTanimotoSimilarity on GPU-resident packed fingerprints",
"The code clusters with nvMolKit butina using a square GPU distance matrix, or with fused_butina using a CUDA torch tensor of packed fingerprints",
"The code handles the distinction between a 0.35 distance cutoff and Tanimoto similarity correctly",
"The code delays host conversion until after nvMolKit GPU operations and handles AsyncGpuResult host reads safely",
"The code prints valid JSON containing a serializable square similarity matrix and cluster assignments"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-007",
"prompt": "Write a from-scratch nvMolKit workflow for conformer analysis. Add explicit hydrogens, generate ETKDGv3 conformers, MMFF-optimize the conformers, compute conformer RMSD matrices for each molecule, and report per-molecule energy and RMSD summaries. Fill in the `<your code here>` section; keep the loading header and printing footer intact.\n\n```python\nimport argparse\nimport json\nfrom pathlib import Path\nfrom rdkit import Chem\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--input\", default=\"input.smi\")\nargs, _ = parser.parse_known_args()\n\nsmiles = [\n line.split()[0]\n for line in Path(args.input).read_text().splitlines()\n if line.strip() and not line.startswith(\"#\")\n]\nmols = [Chem.MolFromSmiles(smi) for smi in smiles]\n\n# <your code here>\n\nprint(json.dumps({\n \"summaries\": conformer_summaries,\n}, sort_keys=True))\n```",
"expected_output": "The agent writes a complete batch-oriented nvMolKit conformer workflow using compatible ETKDG parameters, batched MMFF and RMSD calls, invalid-molecule handling, and structured summaries.",
"assertions": [
"The code parses the SMILES and adds explicit hydrogens before ETKDG and MMFF",
"The code uses ETKDGv3; eigenvalue-based and random-coordinate initialization are both valid",
"The code calls EmbedMolecules once on the valid molecule collection with an explicit positive confsPerMolecule value",
"The code calls MMFFOptimizeMoleculesConfs once on the collection and handles molecules lacking MMFF parameters or reports the indexed ValueError cleanly",
"The code calls GetConformerRMSMatrixBatch on heavy-atom molecules rather than using the single-molecule API as its primary loop",
"The code iterates over the list of RMSD AsyncGpuResult objects and safely converts each result",
"The code reports conformer counts, finite energy summaries, and RMSD summaries for every retained input molecule as valid JSON"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-008",
"prompt": "Write a from-scratch nvMolKit substructure-search workflow that reports whether each input molecule contains an aromatic benzene ring and how many SMARTS matches each molecule has, counting all atom-mapping matches for the benzene SMARTS pattern. Produce one substructure_rows entry for every input SMILES in input order, including nonmatches as false/0 rows. Fill in the `<your code here>` section; keep the loading header and printing footer intact.\n\n```python\nimport argparse\nimport json\nfrom pathlib import Path\nfrom rdkit import Chem\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--input\", default=\"input.smi\")\nargs, _ = parser.parse_known_args()\n\nsmiles = [\n line.split()[0]\n for line in Path(args.input).read_text().splitlines()\n if line.strip() and not line.startswith(\"#\")\n]\nmols = [Chem.MolFromSmiles(smi) for smi in smiles]\n\n# <your code here>\n\nprint(json.dumps({\n \"rows\": substructure_rows,\n}, sort_keys=True))\n```",
"expected_output": "The agent writes a complete batched nvMolKit substructure workflow with a one-element query batch, all-match counting, and complete ordered JSON output.",
"assertions": [
"The code parses every target SMILES and constructs the benzene query with Chem.MolFromSmarts('c1ccccc1')",
"The code uses nvMolKit substructure APIs over the target collection and [query], not an RDKit per-molecule matching loop",
"The code uses SubstructSearchConfig and preserves uniquify=False for all atom-mapping matches",
"The code obtains counts through countSubstructMatches or by counting getSubstructMatches results",
"The code reports a boolean and integer count for every target in input order, including false and zero for nonmatches",
"The code prints valid JSON with one substructure row per input molecule"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-009",
"prompt": "Diagnose why this nvMolKit fingerprinting code performs poorly, then rewrite it with the right API usage. Do not run or benchmark the code; diagnose from the code only. Explain the performance bugs briefly and provide corrected code.\n\n```python\nfrom rdkit import Chem\nfrom nvmolkit.fingerprints import MorganFingerprintGenerator\n\n# smiles contains about 10,000 SMILES strings loaded from a file.\ngen = MorganFingerprintGenerator(radius=2, fpSize=2048)\nfingerprints = []\nfor smi in smiles:\n mol = Chem.MolFromSmiles(smi)\n fp = gen.GetFingerprints([mol]).numpy()\n fingerprints.append(fp)\n```",
"expected_output": "The agent identifies the repeated tiny GPU batches and per-iteration host transfers, then rewrites the code to parse a collection and call GetFingerprints once or in large chunks before any required host conversion.",
"assertions": [
"The agent recognizes from static inspection that GetFingerprints([mol]) in a 10,000-iteration loop creates tiny GPU workloads whose launch and setup overhead cannot be amortized",
"The agent explains that .numpy() in the hot loop synchronizes and transfers each result to the host",
"The corrected code parses a molecule collection and calls one GetFingerprints over the collection or a small number of large chunks",
"The corrected code delays any required host conversion until after batched GPU work",
"The agent does not run a benchmark or suggest changing to another per-molecule loop"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-010",
"prompt": "Here is an existing good nvMolKit ETKDG embedding script. Modify it to use nvMolKit autotuning for the HardwareOptions used by EmbedMolecules. Do not run or benchmark it; provide the updated script only.\n\n```python\nfrom pathlib import Path\nimport json\nimport time\n\nimport torch\nfrom rdkit import Chem\nfrom rdkit.Chem import AddHs\nfrom rdkit.Chem.rdDistGeom import ETKDGv3\n\nfrom nvmolkit.embedMolecules import EmbedMolecules\n\nsmiles_path = Path(\"molecules.smi\")\nsmiles = [\n line.split()[0]\n for line in smiles_path.read_text().splitlines()\n if line.strip() and not line.startswith(\"#\")\n]\nmols = [AddHs(Chem.MolFromSmiles(smi)) for smi in smiles]\n\nparams = ETKDGv3()\nparams.randomSeed = 0xC0FFEE\n\nstart = time.perf_counter()\nEmbedMolecules(mols, params, confsPerMolecule=10, maxIterations=-1)\ntorch.cuda.synchronize()\nelapsed = time.perf_counter() - start\n\nsummary = {\n \"molecules\": len(mols),\n \"conformers\": sum(mol.GetNumConformers() for mol in mols),\n \"elapsed_seconds\": elapsed,\n}\nPath(\"embedding_summary.json\").write_text(\n json.dumps(summary, indent=2, sort_keys=True)\n)\n```",
"expected_output": "The agent preserves the existing workflow, calls the supported tune_embed_molecules API on a representative workload, applies TuneResult.best_config through hardwareOptions= to the full EmbedMolecules call, and retains summary output.",
"assertions": [
"The updated script preserves SMILES loading, AddHs, ETKDGv3, full-workload embedding, and embedding_summary.json output",
"The script imports and calls nvmolkit.autotune.tune_embed_molecules or an equivalent supported import of that function",
"The script may tune on a representative subset while keeping the full collection for the production EmbedMolecules call",
"The script reads TuneResult.best_config and passes it to the full EmbedMolecules call via hardwareOptions=",
"The script does not invent an Autotuner class, merely hand-pick HardwareOptions, or run the requested code"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-011",
"prompt": "A user says this nvMolKit fingerprinting code uses the recommended batched API but is not faster than their RDKit version. Do not run or benchmark the code; explain what is happening and what to tell the user.\n\n```python\nfrom rdkit import Chem\nfrom nvmolkit.fingerprints import MorganFingerprintGenerator\n\nsmiles = [\"CCO\", \"c1ccccc1\", \"CC(=O)O\"]\nmols = [Chem.MolFromSmiles(s) for s in smiles]\ngen = MorganFingerprintGenerator(radius=2, fpSize=2048)\nfps = gen.GetFingerprints(mols)\narr = fps.numpy()\n```",
"expected_output": "The agent explains that the API usage is already correctly batched but three molecules cannot amortize GPU launch, setup, synchronization, and transfer overhead, and recommends benchmarking representative high-throughput batches.",
"assertions": [
"The agent recognizes that GetFingerprints(mols) is already the correct batched nvMolKit API pattern",
"The agent explains that a three-molecule workload is too small to amortize GPU launch, setup, synchronization, and host-transfer overhead",
"The agent states that speedup should not be expected for this tiny workload",
"The agent recommends measuring throughput with many molecules or representative large batches",
"The agent does not recommend a per-molecule nvMolKit loop or claim the code demonstrates an nvMolKit performance regression"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
},
{
"id": "nvmolkit-usage-012",
"prompt": "Write nvMolKit code that finds maximum common substructures for the explicit molecule pairs [(0, 1), (2, 3), (0, 2)]. Preserve that pair order, allow any atom and any bond to match, set a 5-second timeout for each pair, and report atom/bond counts plus whether each search timed out.",
"expected_output": "The agent constructs RDKit molecules, calls nvmolkit.mcs.findMCS once in explicit-pairs mode, and reads the ordered MCSBatchResult correctly, including each MCSResult's counts and canceled flag.",
"assertions": [
"The code imports findMCS from nvmolkit.mcs and calls it once for the batch",
"The code passes mode='pairs' and the explicit pairs [(0, 1), (2, 3), (0, 2)] without reordering or deduplicating them",
"The code uses atom_compare='any', bond_compare='any', and timeout_seconds=5",
"The code iterates in result.pairs order and materializes each item with result[pair_idx] or result.get_result(pair_idx)",
"The code reports num_atoms, num_bonds, and canceled for every requested pair",
"The agent explains that timeout_seconds is a per-pair budget and that a canceled result may contain the best partial MCS found"
],
"expected_skill": "nvmolkit-usage",
"expected_script": null
}
]
}
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
What our scanner noticed· Medium risk
- Large base64-encoded blobs
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Kevin Boyd (@scal444)
- Publisher
- NVIDIA (Official)
- Distributed by
- NVIDIA
- Source
- NVIDIA/skills · skills/bionemo-nvmolkit-usage · commit fce3cca
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE-APACHE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Kevin Boyd (@scal444) or NVIDIA.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nvmolkit-usage.zip