Optimize experimental disk-backed t-SNE affinities
Source:R/massive_tsne_optimizer.R
massive_tsne_optimize.RdOptimizes a normalized symmetric CSR affinity graph from disk. The CPU optimizer retains only its float32 coordinates and update state in RAM, reuses the package's 2D or 3D FFT repulsion, and writes the final coordinates to a file. CUDA streams affinities through a 2D or 3D FFT optimizer. Metal maps the complete read-only graph into shared memory for its 2D or 3D FFT optimizer, or streams bounded graph chunks from SSD. Metal retains coordinates and update state in memory and reserves space for its FFT workspace. It checks the device working-set budget before allocation and during fitting. Graph streaming is not a fully streamed fit. This is a full-graph fit, not landmark projection. Optimization uses fixed iteration counts, without automatic KL stopping. Disk reads can be substantial. All routes can checkpoint optimizer state.
Usage
massive_tsne_optimize(
graph,
init,
output,
early_exaggeration_iter = 250L,
n_iter = 500L,
early_exaggeration = 12,
exaggeration = 1,
learning_rate = "auto",
initial_momentum = 0.8,
final_momentum = 0.8,
min_gain = 0.01,
max_step_norm = Inf,
memory_limit = fastembedr_memory_option(),
backend = "cpu",
n.cores = 1L,
checkpoint = FALSE,
resume = FALSE,
checkpoint_every = 100L,
devices = NULL,
graph_access = "auto",
edge_chunk_capacity = NULL
)Arguments
- graph
A result of
massive_tsne_affinities().- init
File-backed
.f32initial coordinates with two or three columns.- output
New
.f32output path.- early_exaggeration_iter, n_iter
Iterations in each phase.
- early_exaggeration, exaggeration
Phase affinity multipliers.
- learning_rate
Positive value or
"auto"forn / exaggeration.- initial_momentum, final_momentum
Phase momentum values.
- min_gain
Minimum per-coordinate adaptive gain.
- max_step_norm
Maximum update norm;
Infdisables clipping.- memory_limit
Host RAM budget. Coordinated CUDA fits reserve one bounded attraction-edge buffer per requested device.
- backend
"cpu","cuda", or"metal". CUDA supports 2D or 3D output with NCCL for multiple GPUs.- n.cores
CPU worker count for FFT, sparse attraction, and updates.
- checkpoint
Save coordinates and optimizer state periodically.
- resume
Continue a matching interrupted fit.
- checkpoint_every
Iterations between state snapshots.
- devices
CUDA device IDs. Multiple IDs run one coordinated fit.
- graph_access
Metal graph access:
"auto","mmap", or"stream". Auto maps the graph when it fits the host and Metal memory budgets, and streams otherwise.- edge_chunk_capacity
Maximum attraction edges per Metal SSD chunk.
NULLuses 8,388,608 edges. An explicit capacity also limits the graph size eligible for automatic mapping.