Parameters (GPU)¶
The GPU-specific knobs. Everything else takes the bixverse.params bundles.
params
¶
Parameter bundles for the GPU twins.
One frozen dataclass per parameter bundle the twins take, flat as Rust sees
them; ScrubletGpuParams sits in its own module.
Twins with no GPU-specific knobs (PCA, SEACells, Bonsai, NMF, SCENIC) take
the CPU bundles from bixverse.params; bixverse.params.to_rust serialises
both.
ScrubletGpuParams
dataclass
¶
ScrubletGpuParams(
*,
sim_doublet_ratio: float = 1.5,
expected_doublet_rate: float = 0.1,
stdev_doublet_rate: float = 0.02,
n_bins_histogram: int = 100,
manual_threshold: float | None = None,
no_pcs: int = 30,
normalisation: NormDoubletsDefaults = NormDoubletsDefaults(),
hvg: HvgDefaults = HvgDefaults(),
knn_backend: Literal["gpu", "cpu"] = "gpu",
knn: KnnGpuDefaults | KnnDefaults | None = None,
)
GPU Scrublet doublet detection parameters.
The randomised SVD and the projection of the simulated doublets always run
on the GPU; knn_backend picks where the kNN runs. There is no
svd_solver: the GPU SVD is always randomised.
Attributes:
| Name | Type | Description |
|---|---|---|
sim_doublet_ratio |
float
|
Number of doublets to simulate relative to the observed cells. |
expected_doublet_rate |
float
|
Expected doublet rate. |
stdev_doublet_rate |
float
|
Uncertainty in the expected doublet rate. |
n_bins_histogram |
int
|
Number of histogram bins for the Otsu threshold. |
manual_threshold |
float | None
|
Manual doublet score threshold; |
no_pcs |
int
|
Number of principal components. |
normalisation |
NormDoubletsDefaults
|
The normalisation block. |
hvg |
HvgDefaults
|
The HVG block. |
knn_backend |
Literal['gpu', 'cpu']
|
|
knn |
KnnGpuDefaults | KnnDefaults | None
|
The kNN block, |
KnnGpuDefaults
dataclass
¶
KnnGpuDefaults(
*,
k: int = 15,
knn_method: Literal[
"exhaustive", "ivf", "nndescent", "cagra"
] = "exhaustive",
ann_dist: Literal["euclidean", "cosine"] = "euclidean",
n_list: int | None = None,
n_probe: int | None = None,
graph_k: int | None = None,
k_build: int | None = None,
n_tree: int | None = None,
delta: float = 0.001,
rho: float | None = None,
refine_knn: int | None = None,
beam_width: int | None = None,
max_beam_iters: int | None = None,
n_entry_points: int | None = None,
)
Default parameters for the GPU nearest neighbour backends
GPU sibling of KnnDefaults. The GPU indices take a different knob set: there
is no Annoy and no HNSW on the device, so what survives is exhaustive, IVF and
NN-descent.
Attributes:
| Name | Type | Description |
|---|---|---|
k |
int
|
Number of neighbours. |
knn_method |
Literal['exhaustive', 'ivf', 'nndescent', 'cagra']
|
The GPU index to use. |
ann_dist |
Literal['euclidean', 'cosine']
|
Manhattan is not supported by the GPU kernels. |
n_list |
int | None
|
IVF only. Number of clusters. |
n_probe |
int | None
|
IVF only. Clusters to probe. |
graph_k |
int | None
|
CAGRA only. Node degree of the graph after pruning. |
k_build |
int | None
|
NN-descent and CAGRA. Working degree of the descent. |
n_tree |
int | None
|
NN-descent and CAGRA. Trees seeding the descent. |
delta |
float
|
NN-descent and CAGRA. Termination criterium for the descent. |
rho |
float | None
|
NN-descent and CAGRA. Sampling rate for the descent. |
refine_knn |
int | None
|
NN-descent and CAGRA. 2-hop refinement sweeps after the descent.
Buys graph quality at a linear cost. |
beam_width |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Beam width when querying. |
max_beam_iters |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Beam search iterations. |
n_entry_points |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Entry points when querying. |
NebulaGpuParams
dataclass
¶
NebulaGpuParams(
*,
nebula_method: Literal["ln", "hl"] = "ln",
min_sigma: float = 0.0001,
min_phi: float = 0.0001,
max_sigma: float = 10.0,
max_phi: float = 1000.0,
cutoff_cell: float = 20.0,
kappa: float = 800.0,
cpc: float = 0.005,
mincp: int = 5,
min_subjects: int = 0,
eps: float = 1e-06,
gene_batch_size: int = 1000,
shrink_dispersion: bool = True,
)
Wrapper function for parameters for GPU NEBULA
GPU counterpart to NebulaParams. Same knobs and defaults, minus reml: the
device fit does not implement it. Stage two of NEBULA, the per-gene penalised
fits, runs in f32 on the device and is finished on the host in f64, so the
estimates sit close to the CPU ones rather than on them.
Attributes:
| Name | Type | Description |
|---|---|---|
nebula_method |
Literal['ln', 'hl']
|
Which variant to run. NEBULA downgrades |
min_sigma |
float
|
Lower bound on the subject-level overdispersion. |
min_phi |
float
|
Lower bound on the cell-level overdispersion. |
max_sigma |
float
|
Upper bound on the subject-level overdispersion. |
max_phi |
float
|
Upper bound on the cell-level overdispersion. |
cutoff_cell |
float
|
Refit both overdispersions when the product of the cells per
subject and the estimated |
kappa |
float
|
Threshold on NEBULA's |
cpc |
float
|
Drop a gene whose mean count per cell is at most this. |
mincp |
int
|
Drop a gene expressed in fewer than this many cells. |
min_subjects |
int
|
Drop a gene that fewer than this many subjects express, a
subject expressing it when its own mean count per cell is above |
eps |
float
|
Absolute stopping tolerance for the optimiser. |
gene_batch_size |
int
|
Genes read and fitted per batch. Bounds how much of the store is resident at once and changes nothing about the answer, since NEBULA is gene-independent. |
shrink_dispersion |
bool
|
Shrink the cell-level overdispersions towards an empirical Bayes prior once the sweep is done. |
BbknnGpuParams
dataclass
¶
BbknnGpuParams(
*,
neighbours_within_batch: int = 3,
set_op_mix_ratio: float = 1.0,
local_connectivity: float = 1.0,
trim: int | None = None,
knn_method: Literal[
"exhaustive", "ivf", "nndescent", "cagra"
] = "exhaustive",
ann_dist: Literal["euclidean", "cosine"] = "euclidean",
n_list: int | None = None,
n_probe: int | None = None,
graph_k: int | None = None,
k_build: int | None = None,
n_tree: int | None = None,
delta: float = 0.001,
rho: float | None = None,
refine_knn: int | None = None,
beam_width: int | None = None,
max_beam_iters: int | None = None,
n_entry_points: int | None = None,
)
Wrapper function for the GPU BBKNN parameters
GPU counterpart to BbknnParams. Same BBKNN knobs, but the kNN block is the GPU
one, see KnnGpuDefaults.
Attributes:
| Name | Type | Description |
|---|---|---|
neighbours_within_batch |
int
|
Number of neighbours to consider per batch. |
set_op_mix_ratio |
float
|
Mixing ratio between union (1.0) and intersection (0.0). |
local_connectivity |
float
|
UMAP connectivity computation parameter, how many nearest neighbours of each cell are assumed to be fully connected. |
trim |
int | None
|
Trim the neighbours of each cell to these many top connectivities. May
help with population independence and improve the tidiness of
clustering. If |
knn_method |
Literal['exhaustive', 'ivf', 'nndescent', 'cagra']
|
The GPU index to use. |
ann_dist |
Literal['euclidean', 'cosine']
|
Manhattan is not supported by the GPU kernels. |
n_list |
int | None
|
IVF only. Number of clusters. |
n_probe |
int | None
|
IVF only. Clusters to probe. |
graph_k |
int | None
|
CAGRA only. Node degree of the graph after pruning. |
k_build |
int | None
|
NN-descent and CAGRA. Working degree of the descent. |
n_tree |
int | None
|
NN-descent and CAGRA. Trees seeding the descent. |
delta |
float
|
NN-descent and CAGRA. Termination criterium for the descent. |
rho |
float | None
|
NN-descent and CAGRA. Sampling rate for the descent. |
refine_knn |
int | None
|
NN-descent and CAGRA. 2-hop refinement sweeps after the descent.
Buys graph quality at a linear cost. |
beam_width |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Beam width when querying. |
max_beam_iters |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Beam search iterations. |
n_entry_points |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Entry points when querying. |
FastClusterGpuParams
dataclass
¶
FastClusterGpuParams(
*,
n_centroids: int | None = None,
k_means_algorithm: Literal[
"emeans", "lloyd"
] = "emeans",
e_means_epochs: float | None = None,
k_means_iter: int = 50,
k_means_init: str | None = None,
fixed: bool = True,
quantise: bool = False,
dist: Literal["euclidean", "cosine"] = "euclidean",
cell_mediated: bool = False,
n_anchors: int = 5,
centroid_k: int = 15,
knn_sym: Literal["snn", "umap", "knn"] = "snn",
snn_similarity: Literal["jaccard", "rank"] = "jaccard",
pruning: float = 0.0625,
rescue: bool = True,
local_connectivity: float = 1.0,
mix_ratio: float = 1.0,
binary: bool = False,
algorithm: Literal["louvain", "leiden"] = "louvain",
n_iterations: int | None = None,
beta: float = 0.01,
min_gain: float = 0.0,
local_moving: Literal["queue", "coloured"]
| None = None,
node_order: Literal["bfs", "shuffle"] | None = None,
multi_level: bool = True,
max_evals: int = 10,
)
Default parameters for GPU fast clustering
GPU counterpart to FastClusterParams. Fast clustering coarsens the cells with
k-means, builds a graph over the centroids and runs Louvain or Leiden on it. The
community of each centroid is handed back to its cells. Only the k-means (and
the cell-mediated top-m search) run on the GPU. The mini-batch k-means knobs are
gone: the GPU runs e-means or full-batch Lloyd's.
Attributes:
| Name | Type | Description |
|---|---|---|
n_centroids |
int | None
|
Number of k-means centroids. If |
k_means_algorithm |
Literal['emeans', 'lloyd']
|
|
e_means_epochs |
float | None
|
e-means only. Passes over the data; |
k_means_iter |
int
|
Lloyd's only. Maximum number of k-means iterations. |
k_means_init |
str | None
|
Lloyd's only. Initialisation method. One of |
fixed |
bool
|
Shall k-means run for a fixed number of iterations, without checking for convergence. wgpu only; MLX always runs every iteration. |
quantise |
bool
|
Shall the data buffer be held at fp16 on the GPU. Halves the buffer and helps when the assignment kernels are memory bound. wgpu only. |
dist |
Literal['euclidean', 'cosine']
|
Distance for the k-means and the centroid graph. |
cell_mediated |
bool
|
Shall the cell-mediated centroid graph from Secuer be built
instead of the kNN graph on the centroids. Centroids are then linked by
the cells that sit near both, so two centroids that are close in space
but have no cells between them stay apart. If |
n_anchors |
int
|
Number of nearest centroids each cell links to in the cell-
mediated graph. Only used if |
centroid_k |
int
|
Neighbours per centroid in the exact centroid kNN. Only used if
|
knn_sym |
Literal['snn', 'umap', 'knn']
|
How to symmetrise the kNN into a graph. Clustering resolutions do
not carry over between the methods: the |
snn_similarity |
Literal['jaccard', 'rank']
|
|
pruning |
float
|
|
rescue |
bool
|
|
local_connectivity |
float
|
|
mix_ratio |
float
|
|
binary |
bool
|
|
algorithm |
Literal['louvain', 'leiden']
|
Community detection on the centroid graph. |
n_iterations |
int | None
|
Number of iterations of the community detection. A negative
value iterates until stable. If |
beta |
float
|
Leiden only. Randomness of the refinement step. |
min_gain |
float
|
With a negative |
local_moving |
Literal['queue', 'coloured'] | None
|
|
node_order |
Literal['bfs', 'shuffle'] | None
|
Visit order of the queue, |
multi_level |
bool
|
Shall the communities be aggregated and refined in levels. |
max_evals |
int
|
Cap on the node evaluations per local moving phase, in units of the number of nodes. |
FastmnnGpuParams
dataclass
¶
FastmnnGpuParams(
*,
ndist: float = 3.0,
cos_norm: bool = True,
k: int = 20,
knn_method: Literal[
"exhaustive", "ivf", "nndescent", "cagra"
] = "exhaustive",
ann_dist: Literal["euclidean", "cosine"] = "cosine",
n_list: int | None = None,
n_probe: int | None = None,
graph_k: int | None = None,
k_build: int | None = None,
n_tree: int | None = None,
delta: float = 0.001,
rho: float | None = None,
refine_knn: int | None = None,
beam_width: int | None = None,
max_beam_iters: int | None = None,
n_entry_points: int | None = None,
)
Wrapper function for the GPU fastMNN parameters
GPU counterpart to FastmnnParams. Same fastMNN knobs minus the PCA ones, since
the GPU path corrects the PCA already stored in the object. The kNN block is the
GPU one, see KnnGpuDefaults, with k and ann_dist defaulting to the CPU
values.
Attributes:
| Name | Type | Description |
|---|---|---|
ndist |
float
|
Number of median distances for the tricube kernel bandwidth. |
cos_norm |
bool
|
Apply cosine normalisation before computing distances. |
k |
int
|
Number of neighbours. |
knn_method |
Literal['exhaustive', 'ivf', 'nndescent', 'cagra']
|
The GPU index to use. |
ann_dist |
Literal['euclidean', 'cosine']
|
Manhattan is not supported by the GPU kernels. |
n_list |
int | None
|
IVF only. Number of clusters. |
n_probe |
int | None
|
IVF only. Clusters to probe. |
graph_k |
int | None
|
CAGRA only. Node degree of the graph after pruning. |
k_build |
int | None
|
NN-descent and CAGRA. Working degree of the descent. |
n_tree |
int | None
|
NN-descent and CAGRA. Trees seeding the descent. |
delta |
float
|
NN-descent and CAGRA. Termination criterium for the descent. |
rho |
float | None
|
NN-descent and CAGRA. Sampling rate for the descent. |
refine_knn |
int | None
|
NN-descent and CAGRA. 2-hop refinement sweeps after the descent.
Buys graph quality at a linear cost. |
beam_width |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Beam width when querying. |
max_beam_iters |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Beam search iterations. |
n_entry_points |
int | None
|
CAGRA only, which includes NN-descent on a cross-query. Entry points when querying. |
HarmonyV2GpuParams
dataclass
¶
HarmonyV2GpuParams(
*,
k: int | None = None,
sigma: tuple[float, ...] = (0.1,),
theta: tuple[float, ...] = (2.0,),
lambda_: tuple[float, ...] = (1.0,),
max_iter_kmeans: int = 4,
max_iter_harmony: int = 10,
epsilon_kmeans: float = 0.001,
epsilon_harmony: float = 0.01,
window_size: int = 3,
alpha: float = 0.2,
tau: float = 0.0,
batch_proportion_cutoff: float = 1e-05,
use_dynamic_lambda: bool = True,
k_means_algorithm: Literal[
"emeans", "lloyd"
] = "emeans",
e_means_epochs: float | None = None,
k_means_iter: int = 10,
k_means_init: str | None = None,
fixed: bool = True,
quantise: bool = False,
)
Default parameters for Harmony v2 GPU batch correction
Attributes:
| Name | Type | Description |
|---|---|---|
k |
int | None
|
Number of clusters for k-means clustering. If not provided, it will be
automatically determined as |
sigma |
tuple[float, ...]
|
Per-cluster diversity weights. Either a single value (broadcast to all clusters) or a vector of length k. |
theta |
tuple[float, ...]
|
Per-variable diversity penalty. Must be a single value; only one batch covariate is supported on the GPU path. |
lambda_ |
tuple[float, ...]
|
Ridge regression penalty for the linear model. Typically a single
value. Ignored when |
max_iter_kmeans |
int
|
Maximum number of k-means Jacobi sweeps per Harmony round. |
max_iter_harmony |
int
|
Maximum number of Harmony outer iterations. |
epsilon_kmeans |
float
|
Convergence threshold for k-means clustering. |
epsilon_harmony |
float
|
Convergence threshold for Harmony. |
window_size |
int
|
Number of previous iterations to consider when checking convergence. |
alpha |
float
|
Scaling factor for dynamic lambda estimation. Must be in (0, 1). Only
relevant when |
tau |
float
|
Scaling factor for theta based on batch size. A value of 0 disables batch-size scaling of theta. |
batch_proportion_cutoff |
float
|
Cutoff for pruning batches with small proportions during ridge regression. |
use_dynamic_lambda |
bool
|
If |
k_means_algorithm |
Literal['emeans', 'lloyd']
|
|
e_means_epochs |
float | None
|
e-means only. Passes over the data; |
k_means_iter |
int
|
Lloyd's only. Maximum number of k-means iterations for the initial centroid computation. |
k_means_init |
str | None
|
Lloyd's only. Initialisation strategy for k-means. |
fixed |
bool
|
Lloyd's only. If |
quantise |
bool
|
If |