Nvmolkit Usage 标志

Nvmolkit Usage

组织
NVIDIA-BioNeMo
nvmolkit-usage

Use when writing or debugging nvMolKit Python code for GPU-accelerated RDKit fingerprints, similarity, conformers, clustering, and molecular searches.

概览

发布者NVIDIA-BioNeMo
代码仓库bionemo-agent-toolkit
技能名称nvmolkit-usage
星标数
502
复刻数
78
附带文件
6
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 6 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 NVIDIA-BioNeMo 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Nvmolkit Usage AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/NVIDIA-BioNeMo/bionemo-agent-toolkit/tree/main/library-skills/nvmolkit-usage
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/NVIDIA-BioNeMo/bionemo-agent-toolkit.git /tmp/bionemo-agent-toolkit
mkdir -p .claude/skills
cp -r /tmp/bionemo-agent-toolkit/library-skills/nvmolkit-usage .claude/skills/nvmolkit-usage
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Nvmolkit Usage,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Nvmolkit Usage。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Nvmolkit Usage 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

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 torch install with CUDA support (nvMolKit returns GPU tensors via torch'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; pin cuda-version=12.6 or another CUDA version supported by the driver.
  • pip: send the user to the PyTorch install selector or previous-versions page to install torch for 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 Mol objects. 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, with int32 or uint32 words.
  • 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 SubstructMatchParameters options.

Instructions

  1. Run the smoke test below before writing nvMolKit code.
  2. Choose an API from the entry-point table and apply its input requirements.
  3. Handle its result as described below; synchronize asynchronous GPU results before host reads.

Verify the install before writing real code

python
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

TaskModulePrimary entry point
Morgan fingerprintsnvmolkit.fingerprintsMorganFingerprintGenerator(radius, fpSize).GetFingerprints(mols)
Bulk Tanimoto / cosine similaritynvmolkit.similaritycrossTanimotoSimilarity(...), crossCosineSimilarity(...), plus *MemoryConstrained variants for results too large to fit in GPU memory
ETKDG conformer embeddingnvmolkit.embedMoleculesEmbedMolecules(molecules, params, confsPerMolecule, ...)
MMFF94 optimization (one-shot)nvmolkit.mmffOptimizationMMFFOptimizeMoleculesConfs(molecules, ..., minimizerKind=..., fireOptions=...)
UFF optimization (one-shot)nvmolkit.uffOptimizationUFFOptimizeMoleculesConfs(molecules, ..., minimizerKind=..., fireOptions=...)
Forcefield with custom options + constraintsnvmolkit.batchedForcefieldMMFFBatchedForcefield(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 RMSDnvmolkit.conformerRmsdGetConformerRMSMatrix(mol), GetConformerRMSMatrixBatch(mols)
Torsion Fingerprint Deviation (TFD)nvmolkit.tfdGetTFDMatrix(mol), GetTFDMatrices(mols)
Butina clusteringnvmolkit.clusteringbutina(distance_matrix, cutoff) (precomputed matrix), fused_butina(fingerprints, cutoff) (memory-efficient, on-the-fly); both support explicit RDKit and device output modes
Substructure searchnvmolkit.substructurehasSubstructMatch, countSubstructMatches, getSubstructMatches
Maximum common substructurenvmolkit.mcsfindMCS(mols, ...) for all pairs, explicit pairs, or two paired molecule lists
Hardware tuning (batch size, GPU IDs)nvmolkit.typesHardwareOptions(...) passed to ETKDG / MMFF / UFF
Optional autotuningnvmolkit.autotunetune_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-copy torch.Tensor on 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.GetFingerprints
  • crossTanimotoSimilarity, crossCosineSimilarity, and their *MemoryConstrained variants
  • butina, fused_butina
  • GetConformerRMSMatrix, GetConformerRMSMatrixBatch

Other APIs (ETKDG, MMFF/UFF optimization, TFD, substructure search, MCS) are synchronous to the caller — no stream plumbing needed.

Typical pattern:

python
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: AsyncGpuResult of shape (total_atoms, 3) float64. Concatenated conformer coordinates in CSR-style layout.
  • atom_starts, mol_indices, conf_indices: AsyncGpuResult int32 buffers describing the layout (values[atom_starts[i]:atom_starts[i+1]] is conformer i's atoms).
  • energies, converged: AsyncGpuResult buffers populated only for MMFF/UFF minimization (not for plain ETKDG).
  • gpu_id: device the buffers live on. The targetGpu argument on each API picks this; targetGpu=-1 uses the default consolidation device.
  • .per_molecule() returns nested list[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

python
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

python
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

python
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

python
import torch
from rdkit import Chem
from rdkit.Chem.rdDistGeom import EmbedMultipleConfs
from nvmolkit.clustering import OutputMode, 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=OutputMode.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=OutputMode.DEVICE, returns cluster IDs, centroids, and sizes.
  • output=OutputMode.RDKIT returns 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:

python
from rdkit import Chem
from nvmolkit.clustering import OutputMode, fused_dise

molecules = [Chem.MolFromSmiles(smiles) for smiles in ["CCCC", "CCCO", "CCOC"]]
device_result = fused_dise(molecules, 1 - 0.217, metric="aap")
rdkit_clusters = fused_dise(molecules, 1 - 0.217, metric="aap", output=OutputMode.RDKIT)

device_result has cluster_ids, centroids, and cluster_sizes fields; cluster IDs are zero-based and contiguous. OutputMode.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

python
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

SymptomLikely causeAction
torch.cuda.is_available() is falseGPU access, driver compatibility, or the torch CUDA build is missingCheck the GPU and driver, then follow the installation guidance above to select a compatible torch build.
RuntimeError: invalid device ordinalA requested gpuIds entry is not visibleUse device indices below torch.cuda.device_count() or the API's documented GPU defaults.
An RDKit option is rejectedThe option is unsupported by that nvMolKit APIUse supported options only if they preserve the requested behavior; otherwise use RDKit for that operation.

Going deeper

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Nvmolkit Usage AI 技能有什么作用?

Use when writing or debugging nvMolKit Python code for GPU-accelerated RDKit fingerprints, similarity, conformers, clustering, and molecular searches.

为什么在 TypingMind 中使用 Nvmolkit Usage?

因为您只需安装一次,就能搭配任何模型使用。Nvmolkit Usage 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Nvmolkit Usage?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/NVIDIA-BioNeMo/bionemo-agent-toolkit/tree/main/library-skills/nvmolkit-usage。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Nvmolkit Usage?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Nvmolkit Usage 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Nvmolkit Usage 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Nvmolkit Usage AI 技能免费吗?

是的。NVIDIA-BioNeMo 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇