crossTanimotoSimilarityMemoryConstrained#

nvmolkit.similarity.crossTanimotoSimilarityMemoryConstrained(
fingerprint_group_one: Tensor,
fingerprint_group_two: Tensor | None = None,
) ndarray#

Returns the Tanimoto similarity within a set of fingerprints or between two sets of fingerprints.

Computes results on the GPU, but returns a numpy array on the CPU. Will perform computation in chunks if necessary to avoid running out of memory on the GPU. Will still fail if the resulting matrix is too large to fit on the CPU.

Expects fingerprints generated by nvMolKit or as a torch tensor located on device 0, with the leading dimension corresponding to the number of fingerprints, and the second dimension representing the packed fingerprint bitfield.

The special case of fingerprint_group_1 as a 1 x n_bits tensor is equivalent to RDKit’s BulkTanimotoSimilarity.

Parameters:
  • fingerprint_group_one – A torch Tensor or AsyncGpuResult computed from nvMolKit fingerprints

  • fingerprint_group_two – A torch Tensor or AsyncGpuResult computed from nvMolKit fingerprints, or None for all-to-all similarity within fingerprint_group_one.

Returns:

A numpy array of Tanimoto similarities, with index [i, j] corresponding to the similarity between