fused_maxmin#

nvmolkit.pickers.fused_maxmin(
x,
pick_size: int,
*,
metric: Literal['tanimoto', 'cosine', 'aap'] | TanimotoMetric | CosineMetric | AAPMetric = 'tanimoto',
first_picks: Sequence[int] = (),
seed: int = -1,
threshold: float | None = None,
stream: Stream | None = None,
output: OutputMode = OutputMode.DEVICE,
) → tuple[AsyncGpuResult | tuple[int, ...], float]#

Select a diverse subset by greedy MaxMin, computing distances as needed.

Equivalent to maxmin() on the matrix of 1 - similarity values, with memory that scales as O(N). Distances are computed in float32, so results can differ slightly from RDKit’s double-precision results.

Parameters:
  • x – Packed int32 or uint32 fingerprints of shape (N, num_words) for Tanimoto and cosine, or a sequence of RDKit molecules for AAP.

  • pick_size – Number of items to select, from 1 through N. All first_picks are retained even if they exceed this limit.

  • metric – Similarity metric.

  • first_picks – Unique indices that start the selection, in order. If empty, the first pick is drawn at random.

  • seed – Seed for the random first pick. Negative values use system entropy.

  • threshold – Stop before adding a candidate whose nearest-pick distance is at most this value. Distances and the threshold are compared in float32. Must be in [0, 1], or None for no threshold.

  • stream – CUDA stream to use. If None, uses the current stream.

  • output – Result representation.

Returns:

(indices, last_distance). indices is an AsyncGpuResult of int32 indices for OutputMode.DEVICE, or a tuple of indices for OutputMode.RDKIT. last_distance is the nearest-pick distance of the last item added, or -1 if none was added after first_picks.