potentialpaper

Flash-KMeans: Fast and Memory-Efficient Exact K-Means

Shuo Yang, Haocheng Xi, Yilong Zhao, Muyang Li, Xiaoze Fan, Jintao Zhang, Han Cai, Yujun Lin, Xiuyu Li, Kurt Keutzer, Song Han, Chenfeng Xu, Ion Stoica

NeurIPS 2026

Edit this page

Or clone it with git

Run in a terminal:

Needs Git LFS. To push, use an API key from your profile as the password.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

TL;DR. We propose a K-means algorithm that is fast and memory-efficient on GPUs without any approximation.

Abstract. k-means has historically been positioned primarily as an offline processing primitive, typically used for dataset organization or embedding preprocessing rather than as a first-class component in online systems. In this work, we revisit this classical algorithm under the lens of modern AI system design and enable k-means as an online primitive. We point out that existing GPU implementations of k-means remain fundamentally bottlenecked by low-level system constraints rather than theoretical algorithmic complexity. Specifically, the assignment stage suffers from a severe IO bottleneck due to the massive explicit materialization of the N × K distance matrix in High Bandwidth Memory (HBM). Simultaneously, the centroid update stage is heavily penalized by hardware-level atomic write contention caused by irregular, scatter-style token aggregations. To bridge this performance gap, we propose Flash-KMeans, an IO-aware and contention-free k-means implementation for modern GPU workloads. Flash-KMeans introduces two core kernel-level innovations: (1) FlashAssign, which fuses distance computation with an online argmin to completely bypass intermediate memory materialization; (2) Sort-Inverse Update, which explicitly constructs an inverse mapping to transform high-contention atomic scatters into high-bandwidth, segment-level localized reductions. Furthermore, we integrate algorithm-system co-designs, including chunked stream overlap and cache-aware compile heuristic, to ensure practical deployability. Extensive evaluations on NVIDIA H200 GPUs demonstrate that Flash-KMeans achieves up to 17.9× end-to-end speedup over best baselines. At the kernel level, FlashAssign and Sort-Inverse Update deliver up to 21.2× and 6.3× speedups. By systematically restructuring execution around underlying hardware constraints, Flash-KMeans delivers mathematically exact, scalable, and highly deployable acceleration across diverse AI workloads.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

edit · history

DateVersionSubmitted toPDFEvidence
3 May 2026NeurIPS 2026submittedNeurIPS 2026Accept (poster)reviews ↓[1]PDF[1]
Missing a version?

NeurIPS 2026

Accept (poster) · 3 reviews · OpenReview

Updated 25 Nov 2026, 03:46 UTC.

Program Chairs · DecisionOpenReview ↗
Decision
Accept (poster)
Read decision
Meta-review

The paper presents Flash-KMeans, an exact GPU implementation of Lloyd’s algorithm that avoids materializing the full distance matrix and reduces atomic contention during centroid updates. The reported speedups are substantial, and reviewers agree that the system is clearly motivated, well explained, and potentially useful.

Reivewers' main concerns are novelty and evaluation. Both FlashAssign and Sort-Inverse Update appear to be applications of established GPU optimization patterns, and the paper does not clearly explain how they differ from related techniques already used in baselines such as cuML/cuVS. Baseline fairness is also unclear, including precision, convergence criteria, iteration counts, setup costs, and timing methodology. The evaluation relies mainly on synthetic shape sweeps on one GPU architecture, with no real downstream workload showing that the kernel gains improve an end-to-end application. The paper also needs stronger ablations, correctness checks, and reporting of run-to-run variation.

The author's response may want to focus on clarifying the novelty over existing fused assignment and segmented-reduction implementations, explaining the sources of the headline speedups, and confirming that all baselines use matched settings.

Final justification

The rebuttal addresses many of the review concerns. This is a borderline accepted paper.

Area Chair FCLJ · Meta-reviewOpenReview ↗
Read meta-review
Meta-review

The paper presents Flash-KMeans, an exact GPU implementation of Lloyd’s algorithm that avoids materializing the full distance matrix and reduces atomic contention during centroid updates. The reported speedups are substantial, and reviewers agree that the system is clearly motivated, well explained, and potentially useful.

Reivewers' main concerns are novelty and evaluation. Both FlashAssign and Sort-Inverse Update appear to be applications of established GPU optimization patterns, and the paper does not clearly explain how they differ from related techniques already used in baselines such as cuML/cuVS. Baseline fairness is also unclear, including precision, convergence criteria, iteration counts, setup costs, and timing methodology. The evaluation relies mainly on synthetic shape sweeps on one GPU architecture, with no real downstream workload showing that the kernel gains improve an end-to-end application. The paper also needs stronger ablations, correctness checks, and reporting of run-to-run variation.

The author's response may want to focus on clarifying the novelty over existing fused assignment and segmented-reduction implementations, explaining the sources of the headline speedups, and confirming that all baselines use matched settings.

Final justification

The rebuttal addresses many of the review concerns. This is a borderline accepted paper.

Reviewer CC8gOpenReview ↗
Rating
4/6
Confidence
4/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
2/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper introduces Flash-KMeans, an exact GPU implementation of Lloyd k-means designed around memory and synchronization bottlenecks. It combines FlashAssign, which avoids materializing the N x K distance matrix via fused online argmin, with Sort-Inverse Update, which reduces atomic contention through sorted segment-level centroid reductions, plus out-of-core streaming and compile-time heuristics. Experiments report substantiareport substantial kernel and end-to-end speedups over GPU baselines, including scaling to one billion points.

Strengths and weaknesses

Strengths:

  1. The paper emphasizes that GPU k-means pe The paper emphasizes that GPU k-means performance is often limited less by FLOP count than by memory movement and atomic-write behavior. The profiling discussion, including the very low effective bandwidth of the contended update stage, gives the design a concrete systems motivation.
  2. The two main kernel ideas are technically sound and well matched to the diagnosed bottlenecks. FlashAssign is a natural IO-aware fusion of distance computation and argmin, and Sort-Inverse Update is a sensible way to trade irregular scatter atomics for more regular segmented reductions.
  3. The experiments covers many relevant shape regimes by sweeping N, K, d, and batch size, and compares against several widely used GPU baselines. The kernel-level breakdown is especially useful because it separately validates the assignment and update optimizations rather than relying only on aggregate end-to-end speedups.

Weaknesses:

  1. Both core ideas are fairly direct applications of established GPU systems patterns. FlashAssign is online argmin via IO-aware tiling, which is a simplified case of FlashAttention's online softmax (argmin needs no rescaling/normalization). Sort-Inverse Update is the classic sort-then-segmented-reduce pattern that is standard practice for replacing scatter atomics in GPU computing, and the paper itself cites prior work (e.g., [29,30]) that transforms irregular atomic writes into sort+segmented reductions. The contribution is therefore primarily a well-executed engineering synthesis rather than a new idea. This makes the work feel closer in scope to a systems/MLSys contribution than to a core NeurIPS algorithmic contribution.
  2. Baseline fairness is insufficiently documented, and some comparisons are hard to interpret. It is not stated whether all methods run the same number of iterations, the same numerical precision (fp32 vs tf32/fp16), the same convergence criterion, and whether index-build / one-time setup costs (e.g., FAISS) are excluded from per-iteration latency.
  3. The motivation centers on online k-means inside LLM and video pipelines (KV-cache compression, semantic dedup, token merging), but all evaluation is synthetic micro benchmarking on random shapes. There is no demonstration that the kernel speedup translates into measurable improvement in any of the cited real workloads, which weakens the significance argument.
  4. There are writing issues (e.g., 'bes baselines' on line 290 should be 'best baselines'), and the abstract/conclusion headline numbers (200x, 33x) are not always tied to a specific figure, making them hard to locate and verify.
Questions
  1. For the headline comparisons (especially FAISS >200x and cuML 33x), can you confirm that all methods use the same number of Lloyd iterations, the same numerical precision (fp32 vs tf32/fp16), the same convergence/init, and that one-time index-build or setup costs are excluded from per-iteration latency? A table making these settings explicit would help. What explains the >200x gap vs FAISS specifically? 2. How many repetitions were run, and how were warm-up, outliers, and run-to-run variance handled? Could you add error bars (or report median with inter-quantile range) for the key speedup figures?
  2. Can you provide an end-to-end accounting that includes the per-iteration argsort and the sorted gather of features, and show how the 6.3x holds across regimes (small K with long segments vs large K with short segments, and large N where the sort itself becomes bandwidth-bound)?
  3. Can you show that the kernel speedup yields a measurable improvement in at least one of the motivating workloads (e.g., KV-cache compression or semantic dedup), rather than only on synthetic shapes?
Limitations

Not fully. The paper includes a short limitations discussion about specialized accelerators such as TPUs and Trainium, and the checklist discusses some compute and reproducibility items. However, several important limitations should be explicitly addressed in the paper: the per-iteration argsort overhead and regimes where it may be less favorable; the absence of timing variance; and the lack of validation in the downstream workloads used as motivation.

Final justification

The rebuttal substantially resolves my concerns about baseline fairness, reproducibility, full-path accounting, and transfer to real workloads through matched FP32 settings, repeated measurements with variance, complete sorting/gathering costs, and new end-to-end experiments. The remaining limitation is conceptual novelty, since the methods primarily combine established GPU primitives through careful systems engineering, and the headline speedups require precise qualification by setting. I therefore give strong positive weight to the improved empirical evidence but retain some reservation about novelty, and maintain my score of 4 (Borderline Accept).

Formatting concerns

No major formatting or anonymity concerns noticed. Minor typo: 'bes baselines' (Sec. 6 line 290) should read 'best baselines'.

3 comments
Authors · RebuttalOpenReview ↗
Rebuttal

Weakness 1

FlashAssign and Sort-Inverse appear to apply established GPU patterns, making their conceptual novelty and NeurIPS fit unclear.

We agree with the reviewer that online argmin and sort-then-segmented-reduce are established primitives. However, as our comparison with cuVS demonstrates, simply applying these primitives is insufficient to break the K-Means memory bottleneck. Although cuVS has proposed the fusedL2NN primitive for assignment, it does not deliver the corresponding speedup because its reduction state still round-trips through global memory under per-row locks. On the update side, no existing library ships a sort-based path; cuVS still uses an element-wise atomic scatter. Our core contribution is the execution architecture around these reductions—where their state lives, what interface the two stages share, and how the schedule adapts across (N, K, D, batch, architecture).

This architectural difference translates to substantial empirical gains: cuVS's fused assignment kernel runs 4–5× slower than FlashAssign at matched FP32 shapes—slower even than an unfused GEMM-then-argmin pipeline. On the update side, argsort is 24.5% of the optimized FP32 path, and the fully accounted Sort-Inverse update is still 4.23× faster (Question 3).

Regarding venue fit, just as FlashAttention (NeurIPS 2022) revealed that IO-awareness is critical for softmax, our work demonstrates that for K-Means, avoiding materialization is insufficient if the reduction state still round-trips to HBM. K-Means today is a high-frequency online primitive in KV-cache compression, semantic dedup, and token merging. The practical significance of this specific execution design is evidenced by its ongoing adoption: cuVS's maintainers have publicly made replacing their existing fused implementation with this execution design a P0-priority roadmap item; specifics are shared with the AC in a confidential comment because the reference would compromise anonymity.

Weakness 2

Please clarify whether baselines use matched precision, iterations, convergence criteria, initialization, and setup-cost accounting.

Thank you for raising this concern. All latency comparisons use FP32, the same data, and the same fixed number of Lloyd iterations. End-to-end measurements include the complete public API, including random initialization and per-call setup for all methods. Per-iteration and kernel measurements use identical pre-set centroids and exclude one-time setup. This choice does not drive the result: stripping initialization and setup still leaves ~19× at fixed iteration counts, and removing batching leaves a 5–7× per-iteration gap (Reviewer LLwd, Question 1). In the separate 100-trial convergence study, both methods use the same stopping criterion and converge in all trials, averaging 24.19 and 24.79 iterations for PyTorch Lloyd and Flash-KMeans. The mean paired final-WCSS gap is 1.91×10⁻⁴. We will make these settings explicit.

Weakness 3 & Question 4

Please show that the kernel gains transfer from synthetic shapes to the motivating real AI workloads.

Yes. We ran controlled engine swaps in three real K-Means consumers: everything in each pipeline is held fixed—same data, same initial centroids (cuVS run with init_method="Array"), same iteration counts, FP32—and only the K-Means engine is switched between Flash-KMeans and cuVS. Output quality is identical (final inertia on SIFT1M: 44,441.8 versus 44,443.2; H100):

K-Means consumer (engine swap, all else fixed) Flash-KMeans cuVS Slowdown
GPU IVF-Flat index build, SIFT1M, nlist=4096, 20 iters 108 ms 577 ms 5.3×
GPU IVF-PQ index build, SIFT1M, m=16, ksub=256 122 ms 684 ms 5.6×
PQ codebook stage: one batched B=16 call vs. 16 sequential fits 9.2 ms 98.2 ms 10.7×
Video-DiT per-step semantic clustering, B=32 heads×75,600 tokens, K=1000, 10 iters 43.1 ms 279.6 ms 6.5×

Two observations. The PQ row is structural: cuVS exposes no batched interface, so the m=16 sub-quantizers must be trained as 16 sequential fits, whereas Flash-KMeans trains them in a single batched call—the batched design pays off directly inside a standard build recipe. The video row is one of the motivating workloads: semantic clustering runs at every denoising step, so over a 50-step generation the clustering stage alone costs about 2 s with Flash-KMeans versus about 14 s with cuVS. We will include end-to-end pipeline measurements in the revision.

The table uses the matched-initialization protocol, which is conservative: with cuVS's default initialization path (k-means++), the IVF-Flat build slowdown grows to ~30× (3.26 s versus 108 ms on SIFT1M).

Weakness 4

Please fix the writing errors and tie the 200× and 33× headline numbers to specific figures and settings.

Thank you for catching these issues. We will correct the typo and tie each headline speedup to its corresponding figure and setting in the camera-ready version.

Question 1

Please state the matched settings behind the 200× FAISS and 33× cuML results and explain the FAISS gap.

Thank you for requesting clarification. We use the following protocol for the headline comparisons:

Setting Protocol
Precision FP32 for all methods
Lloyd iterations Same fixed number for latency comparisons
Initialization End-to-end: random initialization for all methods; kernel-level: identical pre-set centroids
Convergence Same stopping criterion in the convergence study
One-time setup Included end to end; excluded from per-iteration and kernel measurements
Timing Mean of 50 runs after 10 warm-up runs

We will add this protocol table to the revision. Stripping initialization and per-call setup still leaves ~19× at fixed iteration counts (Reviewer LLwd, Question 1).

On FAISS specifically, we profiled GPU faiss.Kmeans at B=1, N=8M, K=1024, and D=128 in FP32, with subsampling disabled and matched initial centroids. FAISS takes 712 ms per iteration versus 12.4 ms for a complete Flash-KMeans iteration—57× at fixed iteration counts. Its own statistics attribute 82% to generic 1-NN search, which materializes distance tiles, performs top-k, and re-streams the host-resident dataset; the remaining 18% is CPU centroid updates and transfers. The bridge from 57× to the >200× headline is native batching and per-call index setup; we will document it at the exact headline setting.

Question 2

Please report repetitions, warm-up, variance, outlier handling, and error bars for the key speedups.

Thank you for the suggestion. We report the mean ± standard deviation over 50 timed runs after 10 warm-up runs. Measurement order is rotated across methods, and no samples are removed as outliers.

Implementation Assign Update Other All
Standard assign + atomic update 117.016 ± 0.145 ms 6.088 ± 0.010 ms 0.0151 ± 0.0005 ms 123.119 ± 0.152 ms
FlashAssign + Sort-Inverse 6.287 ± 0.097 ms 1.0416 ± 0.0023 ms 0.0151 ± 0.0005 ms 7.343 ± 0.097 ms
Phase speedup 18.61× 5.84× 1.00× 16.77×

The end-to-end coefficient of variation is 0.12% for the standard implementation and 1.33% for Flash-KMeans. We will add these variance statistics to the revision.

Question 3

Please include argsort and feature gathering in the update accounting and test whether the 6.3× gain holds across N/K regimes.

Thank you for the suggestion. We profiled the complete update path on an NVIDIA H200 at B=1, N=2²⁵ (33M), K=4096, and D=128 under FP32 precision. Results are mean ± standard deviation over 50 runs after 10 warm-up runs.

Update component Latency Share
Argsort 1.366 ± 0.002 ms 24.5%
Index preparation 0.0983 ± 0.0004 ms 1.8%
Buffer initialization 0.0072 ± 0.0003 ms 0.1%
Indexed gather + localized reduction 4.075 ± 0.001 ms 73.2%
Normalization 0.0203 ± 0.0003 ms 0.4%
Sort-Inverse total 5.567 ± 0.003 ms 100%
Atomic-update total 23.545 ± 0.010 ms —

Thus, the fully accounted FP32 update speedup is 4.23×. Argsort contributes 24.5% at this large N and does not erase the benefit. Indexed gathering and localized reduction are fused in our Triton kernel and are therefore reported together. The controlled sweep from Reviewer LLwd, Question 3 is reproduced below:

N K D N/K Assign speedup Update speedup
1M 1K 128 1024 17.63× 3.63×
4M 1K 128 4096 18.29× 5.22×
16M 1K 128 16384 18.32× 6.28×

At fixed K=1K and D=128, the Update speedup rises from 3.63× to 5.22× to 6.28× as N/K increases from 1024 to 4096 to 16384. We will include this detailed analysis in the paper.

Authors · CommentOpenReview ↗

Dear Reviewer CC8g,

As the discussion period deadline approaches, we would greatly appreciate your feedback on our response. If you feel your concerns have been resolved, we would greatly appreciate it if you would consider raising the score.

Best, Authors

Reviewer CC8g · CommentOpenReview ↗

Thank you for the detailed rebuttal and for carefully addressing the reviewers' comments. I appreciate the authors' effort in providing additional explanations and clarifications. The rebuttal has helped me better understand several aspects of the work. I will maintain my score to Borderline accept.

Reviewer YLVMOpenReview ↗
Rating
3/6
Confidence
4/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
2/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper presents Flash-KMeans, a GPU implementation of k-means that reduces memory traffic and synchronization overhead. It avoids materializing the full distance matrix through fused assignment, replaces atomic-heavy centroid updates with sorted segment reductions, and adds out-of-core execution and cache-aware compilation.

Strengths and weaknesses

The paper addresses an important practical bottleneck: exact k-means can be expensive in modern GPU workloads, especially when the assignment step materializes a large distance matrix and the update step suffers from atomic contention. The proposed implementation is cleanly motivated, and the separation between assignment, update, and system-level optimizations makes the paper easy to follow. The reported speedups are large and suggest that the implementation could be practically useful for workloads where exact k-means is invoked frequently.

However, the evaluation has some limitations. Most experiments are synthetic shape sweeps varying (N), (K), (D), and batch size, rather than real datasets or real AI-pipeline workloads. Also, the main ideas are natural applications of known GPU systems patterns: fused computation with online reduction to avoid intermediate materialization, and sort/segment-reduction to reduce scattered atomic writes. These are reasonable and effective engineering choices, but the paper does not sufficiently establish why these techniques are conceptually novel beyond applying established IO-aware kernel design principles to k-means.

Questions

Q1. Can the authors clarify what aspects of FlashAssign are novel relative to standard fused distance-plus-argmin GPU kernels and the general IO-aware design pattern popularized by FlashAttention? Q2. The evaluation is conducted on an NVIDIA H200 GPU. Since the proposed gains depend heavily on memory bandwidth, cache hierarchy, asynchronous prefetching, and kernel configuration choices, can the authors discuss or evaluate how the speedups transfer to other GPU architectures?

Limitations

yes

Formatting concerns

None observed

2 comments
Authors · RebuttalOpenReview ↗
Rebuttal

Weakness 1

Most experiments use synthetic shape sweeps rather than real datasets or end-to-end AI workloads.

Thank you for pointing this out; we added both real-dataset and real-pipeline evaluations.

Real datasets. We rebuilt our controlled engine-swap comparison on SIFT1M. At fixed shapes and iteration counts, K-Means latency is essentially data-independent—every kernel is a dense computation with no data-dependent branching—and the measurements confirm this: the controlled engine-swap gap on SIFT1M matches the synthetic-data gap at the same shape (5.6× versus 5.7× for the coarse-training stage of an IVF-Flat build). Shape sweeps are therefore the representative axis for this workload; we will nonetheless report the real-dataset numbers alongside them.

Real AI-pipeline workloads. We swapped the K-Means engine (Flash-KMeans ↔ cuVS) inside three real consumers, holding data, initial centroids, and iteration counts fixed (H100):

K-Means consumer Flash-KMeans cuVS Slowdown
GPU IVF-Flat index build (SIFT1M, nlist=4096) 108 ms 577 ms 5.3×
GPU IVF-PQ index build (SIFT1M; PQ codebook stage alone: 10.7×) 122 ms 684 ms 5.6×
Video-DiT per-step semantic clustering (B=32×75,600, K=1000) 43.1 ms 279.6 ms 6.5×

Output quality is identical under the matched protocol (SIFT1M inertia 44,441.8 versus 44,443.2). End-to-end pipeline measurements will be added in the revision.

Weakness 2

The optimizations appear to apply established GPU systems patterns, leaving their conceptual novelty over prior IO-aware designs unclear.

We agree with the reviewer that the individual GPU patterns—online argmin and sort-reduce—are established primitives. However, as our comparison with cuVS demonstrates, simply applying these primitives is insufficient to break the K-Means memory bottleneck. The missing principle in GPU K-Means is that fusion which leaves the reduction state in global memory saves capacity, not time; execution must be organized around the online reduction so that its state never leaves registers. No existing K-Means system delivers exact, fast, and materialization-free simultaneously: eager PyTorch is exact and fast until the N×K matrix stops fitting; cuVS applies precisely the established patterns the reviewer names—fused distance-plus-argmin and avoided materialization—and obtains the memory but not the time.

This architectural difference translates to substantial empirical gains: at matched FP32 shapes, cuVS's fused assignment runs 4–5× slower than FlashAssign—and slower than an unfused GEMM-then-argmin pipeline—because its reduction state round-trips global memory through per-row locks in a GEMM epilogue (see Question 1). On the update side, no library ships a sort-based path at all: cuVS's update is an element-wise atomic scatter, and its source describes it as “Keeping it simple—not optimized.” Swapping only the K-Means engine inside three real consumers costs 5.3–10.7× (see Weakness 1). The 2×2 ablation shows the two stages are a joint design rather than two independent tricks (9.89× alone, 16.77× composed).

On conceptual novelty specifically, we claim two things. First, the two data-movement bottlenecks of an exact Lloyd iteration—the N×K write in assignment and the scattered writes in update—are two halves of one problem, and we eliminate both through a shared intermediate representation: the compact per-point label, which is exactly the minimal input Sort-Inverse consumes. Second, the distinction “fusion is not speed; where the reduction lives is speed” is itself conceptual and non-obvious—cuVS is the counterexample. Nor is the design a one-off trick: the identical dataflow runs unchanged across GPU generations, and on the newest one (Blackwell B200) the shipped configuration heuristic lands within 1–2% (geomean) of an exhaustive per-shape oracle with exact correctness on every shape.

This is also why we believe the contribution matters to this community: K-Means is now a high-frequency, latency-critical online primitive inside modern AI pipelines (KV-cache compression, semantic dedup, and sparse routing in video DiTs), where our formulation achieves 33× over cuML, >200× over FAISS, and 17.9× over PyTorch baselines with exact outputs. Indeed, cuVS's maintainers have publicly made adopting this execution design for their K-Means a P0-priority roadmap item; specifics are shared with the AC in a confidential comment because the reference would compromise anonymity. We will rewrite the contribution statement at this dataflow level and explicitly attribute the underlying primitives.

Question 1

What is novel about FlashAssign relative to fused distance–argmin kernels and FlashAttention-style IO-aware design?

We agree with the reviewer that online argmin itself is not new: cuVS fusedL2NN already fuses L2-distance computation with a 1-NN reduction. However, fusedL2NN only avoids materializing the N×K matrix; it does not deliver the corresponding speedup because its reduction state still round-trips global memory under per-row locks. FlashAssign's contribution is the K-Means-specific execution schedule and dataflow that keep this state in registers and turn avoided materialization into realized speedup.

FlashAssign keeps a point tile and its running (minimum, index) state on chip while streaming centroid tiles through a staged pipeline. It selects tile sizes, warp count, and pipeline depth according to N, K, D, dtype, and GPU architecture, supports split-D register accumulation and batched Lloyd iterations, and emits exactly the compact labels consumed by Sort-Inverse Update. FlashAttention supplies the general IO-aware principle, but not this Lloyd-specific schedule or assignment-to-update design.

Most importantly, the gain remains when the baseline is already fused. On an NVIDIA H200 at B=1, N=4,194,304, K=1000, and D=128 with FP32 inputs, the actual cuML/cuVS assignment path (including FusedDistanceNN launch support) takes 29.64 ms, versus 5.47 ms for FlashAssign:

Assignment implementation Latency Relative speed
cuML/cuVS FusedDistanceNN path 29.64 ms 1.00×
FlashAssign 5.47 ms 5.42×

Assignment is 93.7% of cuML's CUDA device time at this setting, so this comparison addresses its dominant path directly. The result is fused versus fused, not fusion versus materialization.

The decisive difference is where the reduction lives. At K=1024, fusedL2NN performs four lock-guarded state updates per point; at N=8M this exceeds 33 million global updates. At that shape (D=128, FP32 on H100), fusedL2NN takes 51.8 ms—slower than unfused GEMM-then-argmin at 28.5 ms—whereas FlashAssign takes 10.6 ms by keeping the same online argmin on chip and writing once. Avoiding materialization saves memory; keeping the reduction in registers saves time. The same dataflow is instantiated across H200, H100, A100, and GB10.

We will revise the paper to claim this K-Means-specific execution and system design rather than novelty for online argmin itself, and cite fusedL2NN explicitly.

Question 2

How well do the H200 speedups transfer to other GPU architectures?

Thank you for the question. Flash-KMeans supports A100, H100, H200, B200, and GB10, among other GPUs: the kernels are identical across architectures, and per-architecture performance comes from a cache-aware heuristic that re-selects tile sizes for each GPU's memory hierarchy. The reviewer is right that the gains depend on bandwidth, cache, and configuration choices—which is exactly why these choices are an explicit, per-architecture degree of freedom of the design rather than a hidden assumption.

The strongest transfer test is the newest generation, Blackwell. We ran the identical kernels on B200 with no redesign: re-selecting tile sizes with the cache-aware heuristic alone yields up to 7.5× over reusing the previous generation's choices, and the heuristic lands within 0.8–1.6% (geomean; p95≤5.6%) of an exhaustive per-shape oracle on randomized validation shapes—including batched problems and feature dimensions up to 2560—with exact label correctness on every shape.

The speedups themselves also transfer—and widen. Against the standard eager PyTorch baseline (fast_pytorch_kmeans), with FP16 inputs and matched settings for both implementations, Flash-KMeans on B200 achieves:

N K D Flash-KMeans (ms/iter) Standard (ms/iter) Speedup
1M 16,384 128 5.04 248.2 49.2×
1M 16,384 1,024 36.6 514.2 14.0×
2M 8,192 128 5.00 256.8 51.4×
2M 8,192 1,024 34.3 504.9 14.7×
2M 4,096 128 2.73 125.4 45.9×
2M 4,096 1,024 18.5 243.1 13.1×
4M 4,096 128 5.39 238.4 44.2×
4M 4,096 1,024 36.9 493.0 13.4×

These gaps are wider than their H200 counterparts for two reasons: the shapes sit in the large-K regime, where the baseline's N×K materialization dominates its runtime, and B200's compute throughput grew faster than its memory bandwidth—which rewards fused execution and penalizes the materializing baseline. The D-scaling behavior mirrors the H200 analysis (Reviewer LLwd, Question 3): ratios narrow as D grows because every correct implementation converges to the GEMM bound.

We will add a cross-architecture results table to the revision.

Authors · CommentOpenReview ↗

Dear Reviewer YLVM,

As the discussion period deadline approaches, we would greatly appreciate your feedback on our response. If you feel your concerns have been resolved, we would greatly appreciate it if you would consider raising the score.

Best, Authors

Reviewer LLwdOpenReview ↗
Rating
4/6
Confidence
4/5
Quality
3/4
Clarity
4/4
Significance
3/4
Originality
2/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper introduces Flash-KMeans, a new GPU hardware-aware implementation of the classical Lloyd K-means algorithm, with 17.9x speedup over baseline implementations. The bottlenecks in standard implementations are the materialization of the NxK distance matrix in HBM, as well as heavy write contention during the update stage. Both of them are subsequently alleviated by the paper's optimizations FlashAssign and sort-inverse update.

Strengths and weaknesses

Review of the submitted manuscript:

Strengths The paper has impressive performance improvements in a Lloyd's equivalent implementation of K-means without resorting to approximations. This is an important area, and there is a need for faster GPU based K-means implementations, which could have significant impact both for online applications, but also for offline k-means e.g. for vector search index building. The explanation of the implementations and writing is clear, although empirical proof of correctness in the experimental section is lacking.

Weaknesses The paper's main weakness is its limited experimental analysis, which is insufficient to prove correctness in support of the claims made in the text. Most of the text is devoted to implementation details of optimizations that have each already been discussed and utilized by prior work, potentially even on the baselines the work compares against (see questions). Thus the novelty is in question and is limited to an engineering focused contribution. Given this, and the absence of open-source code in the submission, I was expecting a much more detailed experimental section, with clear comparative analysis and discussion of limitations. The experiments should be considerably more thoroughly and carefully designed to isolate effects, including a proper ablation study across parameters, and breakdown of time across phases. This would be necessary both to empirically prove correctness of the paper's claims, and justify the quality and significance of the work.


Review update after authors' response:

I thank the authors for their detailed response to all reviewer concerns, including my own, which increases my final recommendation to 4.

My new breakdown of the final score is as follows: Quality: 3, assuming all the promised clarifications and improvements especially to the experimental analysis and baseline comparison (e.g., fusedL2ANN) are included in the CR version. Clarity: unchanged. Significance: 3, given increased confidence in the results due to being backed up by detailed breakdown and code comparison, and the increasing importance of k-means as a foundational operation on GPUs. Originality: 2. While the clearer fusedL2ANN comparison strengthens the case, the algorithmic contribution remains limited. Nevertheless, the engineering/implementation contribution directly addressing bottlenecks in a foundational algorithm is important and worthy of publication.

Questions

I would increase my score, but there are major changes required for the score to be 4/5. Specifically, a clear explanation of the novelty over baselines, empirical showcase of the exact sources of speedup, and the effect of parameters. These all need to be clear in the experiments section, given the engineering focus of the contribution, so that the quality and significance of the work is more clearly justified.

  • Q1 : The headline FlashAssign contribution, fusing distance computation with an online argmin to avoid materializing the N×K distance matrix. To my understanding, this appears to already exist in the baselines, contrary to the claim that it is the bottleneck of standard implementations. cuML's K-Means runs on cuVS, whose assignment step (minClusterAndDistanceCompute) invokes the fusedL2NN primitive [1]. Given this: (i) What does FlashAssign do differently from fusedL2NN? (ii) The paper reports up to ~33× speedup over cuML. Since cuML/cuVS already appears to avoid materialization, what are the sources of the speedup? (iii) Why use cuML instead of directly using cuVS?
    [1] https://github.com/rapidsai/raft/blob/branch-24.12/cpp/include/raft/cluster/detail/kmeans_common.cuh#L429-L440

  • Q2 : There should be an ablation study that shows how much each optimization contributes to the final result. How much of the speedup is from FlashAssign versus the sort-inverse update versus other factors. The baselines should also be broken down into their constituent phases (assign,update,other...), as was nicely done in Figure 1b. This would empirically show where the sources of speedup come from and how much is attributed per optimization.

  • Q3: It is unclear how the different parameters affect your implementation from the figure and there is a lack of discussion on the topic. Figure 4 does not properly isolate parameter effects. For example the N/k ratio in each figure varies greatly, and dimensionality only checked at 128 and partly for 512 in the top left figure, what about high dimensionality e.g. 1024? What is the reasoning behind these parameter choices?

  • Q4 : In Figure 4, which of the baselines is the "standard" implementation you are comparing to?

  • Q5 : Paper claims identical results to Lloyd. Could you provide a short empirical proof of convergence and equivalence to Lloyd's? You could report in the text or a table number of iterations to converge per baseline, and the final within-cluster sum of squares or silhouette score upon convergence.

  • Q6 : The explanation of the experimental setup needs to be extended :

    • Important: Are all methods using the same precision ( fp16, fp32 ) across all measurements?
    • Are you reporting mean/median and if so over how many iterations?
    • Which version of the baseline libraries are you using?
    • Is the initialization overhead correctly removed from all baselines (kmeans++ or random init)?
  • Q7: You mention additional optimisations for out-of-core and dynamic-shape co-design. Are these utilised in any of your main experiments in the paper? If so to what extent are they shown to be useful.

Limitations

there is no limitations subsection, besides the authors saying the code needs to be implemented

Final justification

The initial submission was incomplete, as noted in my original review. However, the authors’ response and effort in addressing my concerns merit a score increase, assuming the main manuscript incorporates the additional work (fusedL2NN comparison, time and speedup breakdown, controlled parameter sweep, experimental setup explanation). My final recommendation is Weak Accept: 4, given the limited algorithmic originality, and that I am increasing with the expectation that effort will be spent to improve the main manuscript to incorporate all reviewer requests.

The sub-score breakdown is provided in my comment to the authors response.

Formatting concerns

n/a

2 comments
Authors · RebuttalOpenReview ↗
Rebuttal

Weakness 1

The evaluation is too limited to establish correctness, isolate optimization gains, or support the claimed novelty.

Thank you for this summary. Due to the rebuttal length limit, we address the novelty concern in our response to Reviewer CC8g (Weakness 1) and refer to our detailed answers to Questions 1–7 below for the experimental concerns.

The full implementation is already open source and in production use; we withhold the link for anonymity and will include it in the camera-ready. We also note that cuVS's maintainers have publicly made adopting this execution design for their K-Means a P0-priority roadmap item; specifics are shared with the AC in a confidential comment.

Question 1

How does FlashAssign differ from cuVS fusedL2NN, what explains the reported ~33× cuML speedup, and why not compare directly with cuVS?

i. FlashAssign vs. fusedL2NN. fusedL2NN relates to FlashAssign the way memory-efficient attention relates to FlashAttention: it avoids N×K materialization without converting the saved memory into saved time, because it attaches the 1-NN reduction to the GEMM epilogue. Each point's running state resides in global memory, requiring lock-guarded read-modify-writes per centroid tile (e.g., 4 round-trips/point at K=1024; >33M locked updates at N=8M). Consequently, at N=8M, K=1024, D=128 (FP32, H100), fusedL2NN takes 51.8 ms—slower than unfused GEMM-then-argmin (28.5 ms); profiling shows 1.7% of HBM bandwidth and under 10% of matrix throughput, so the time goes to synchronization, not arithmetic. FlashAssign instead keeps the running reduction in registers within the streaming main loop, writing only the final 4-byte label. It requires no locks, overlaps reduction with asynchronous loads, and takes 10.6 ms (a 4.9× speedup over fusedL2NN). Avoiding materialization saves capacity; keeping the reduction on-chip saves time. The 4-byte label is exactly the interface Sort-Inverse Update consumes, and the dataflow is epilogue-independent—instantiated across H200, H100, A100, and GB10, including an SM90 TMA + WGMMA path.

N K D fusedL2NN FlashAssign Speedup
1M 1,024 128 6.55 ms 1.38 ms 4.7×
8M 1,024 128 51.8 ms 10.6 ms 4.9×
4M 4,096 128 111.1 ms 22.2 ms 5.0×

ii. 33× cuML speedup breakdown. We understand that headline speedups like 33× can appear surprising. This is not a single kernel-level multiplier, but the compounding product of algorithmic, structural, and hardware-level optimizations. cuVS avoids materialization in assignment, but its update remains an atomic scatter.

(1) Initialization/setup (~1.7×): Fixed per-call costs: the end-to-end ratio at N=8M rises from ~5× at 50 iterations to 7.5× at a single iteration. Stripping these leaves ~19× at fixed iteration counts.

(2) Native batching (2.7×): For independent per-head problems (B=32, N=75,600, K=1000, D=128), one batched Flash-KMeans call takes 43.1 ms; looping our own kernels costs 117.7 ms, while looped cuVS takes 279.6 ms.

(3) Per-iteration execution (~5–7×): Under strict matched protocols (N=8M, K=1024, D=128, H100), one cuVS iteration takes 66.1 ms versus 12.4 ms for Flash-KMeans (5.3×). This combines FlashAssign's ~5× gain and Sort-Inverse's ~6× gain, and remains 4.4–5.3× across N=8M–33M and K=1K–64K. At N=4M, K=4096, a complete Flash-KMeans iteration (23.2 ms) is 4.8× faster than fusedL2NN assignment alone (111.1 ms). We will add the exact 33× accounting to the revision.

iii. cuML vs. cuVS. cuML is the public interface practitioners use. We will explicitly add the cuVS fit comparison (66.1 ms versus 12.4 ms) and fusedL2NN kernel comparison to the revision; all three levels yield the same conclusion.

Question 2

Please separate the speedups from FlashAssign, Sort-Inverse Update, and other work.

We added a single-iteration 2×2 ablation on an H200 (B=1, N=8M, K=1024, D=128, FP32), isolating the marginal effects of each optimization:

Assignment Update Iteration Speedup vs. standard
Standard Atomic 123.077 ms 1.00×
FlashAssign Atomic 12.443 ms 9.89×
Standard Sort-Inverse 117.972 ms 1.04×
FlashAssign Sort-Inverse 7.341 ms 16.77×

FlashAssign provides the majority of the absolute latency reduction (9.89× alone). Once enabled, Sort-Inverse remains critical, reducing the remaining iteration latency from 12.443 ms to 7.341 ms and increasing the overall speedup to 16.77×. The common “Other” work takes ~0.015 ms across all settings. We will add this factorial ablation to the revision.

Question 3

Please isolate the effects of N, K, and D—including D=1024—and explain the chosen settings.

We added a controlled one-factor-at-a-time sweep on an H200 (reference: B=1, N=1M, K=1K, D=128), covering N/K from 256 to 16384 and D up to 1024:

N K D N/K Assign speedup Update speedup
1M 1K 128 1024 17.63× 3.63×
4M 1K 128 4096 18.29× 5.22×
16M 1K 128 16384 18.32× 6.28×
1M 2K 128 512 18.51× 3.53×
1M 4K 128 256 19.65× 3.31×
1M 1K 256 1024 8.63× 4.35×
1M 1K 512 1024 5.48× 2.45×
1M 1K 1024 1024 3.95× 3.43×

FlashAssign is consistently faster (3.95–19.65×). The ratio against the standard baseline narrows as D grows because the baseline's N×K materialization traffic is independent of D, while the shared distance computation grows linearly. As the problem becomes compute-bound, every implementation converges to the GEMM bound. Importantly, FlashAssign stays at the GEMM roofline, and its advantage over fused cuVS remains 5.5–9.5× at N=1M, K=1024, D=128–2048 (FP16 inputs, H100). Sort-Inverse Update consistently provides 2.45–6.28× speedups. In the controlled N-sweep with K=1K and D=128 fixed, its speedup increases from 3.63× to 5.22× to 6.28× as N/K grows from 1024 to 4096 to 16384. We emphasized D=128 in Fig. 4 because online LLM workloads operate on per-head vectors, but we will add this higher-dimensional sweep to the revision.

Question 4

What “standard” implementation is used as the Figure 4 baseline?

Figure 4 is a kernel-level comparison on a single H200. The “standard” assignment is eager PyTorch that materializes the FP32 N×K distance matrix before argmin, while the “standard” update uses token-wise atomic scatter with FP32 accumulation. Both are evaluated under identical settings (CUDA 12.8, D=128), isolating our techniques from external library differences. This eager implementation is the strongest baseline we evaluate—as Question 1 shows, even a two-pass eager assignment outperforms cuVS's fused kernel at matched shapes. We will clarify this in the caption.

Question 5

Please verify Lloyd-equivalent convergence using iteration counts and final clustering quality.

We ran 100 independent, shared-initialization trials on an H200 (B=1, N=8192, K=32, D=128, FP32, tolerance 0.1).

Method Iterations (mean ± std) Final WCSS (mean ± std) Converged
PyTorch Lloyd 24.19 ± 4.04 996,815.74 ± 1,628.05 100/100
Flash-KMeans 24.79 ± 4.58 996,780.47 ± 1,636.28 100/100

Across paired trials, the final relative WCSS gap averages 1.91×10⁻⁴, and the mean iteration-count difference is 0.60. Flash-KMeans performs the same nearest-centroid and cluster-mean operations; minor trajectory differences stem from floating-point reduction order near assignment ties. We will replace “identical” with “numerically equivalent convergence.”

Question 6

Please clarify precision, timing protocol, library versions, and initialization accounting.

(i) All methods are evaluated in FP32. (ii) We report the mean of 50 timed runs after 10 warm-ups. (iii) We use cuML 26.02, the latest release at the time of our experiments. (iv) End-to-end comparisons use random initialization and include per-call setup; per-iteration/kernel measurements use identical pre-set centroids and exclude one-time setup. Stripping initialization/setup still leaves ~19× speedup at fixed iteration counts, and removing the batching effect leaves a 5–7× per-iteration gap (Question 1).

Question 7

Are the out-of-core and dynamic-shape optimizations used in the main experiments, and what benefit do they provide?

Both features are evaluated in Appendix A and play different roles:

Cache-aware compile heuristic: Used in every experiment in the paper. All reported numbers are out-of-the-box performance produced by heuristic-selected configurations, not oracle-tuned. Appendix A shows it matches the exhaustively tuned oracle within 0.3% while reducing time-to-first-run by up to 175×.

Out-of-core streaming: Not exercised in the main sweeps, which operate on in-VRAM data to isolate kernel effects. It is evaluated in Appendix A on workloads up to 1 billion points: at N=10⁹, K=32768, D=128, one iteration takes 41.4 s versus 261.8 s for fastkmeans (the strongest out-of-core baseline, as standard PyTorch OOMs), a 6.3× speedup. At N=400M, K=16384, the speedup reaches 10.5×.

We will promote a summary of both results into the main experimental section.

Authors · CommentOpenReview ↗

Dear Reviewer LLwd,

As the discussion period deadline approaches, we would greatly appreciate your feedback on our response. If you feel your concerns have been resolved, we would greatly appreciate it if you would consider raising the score.

Best, Authors

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Missing a submission?

Loading the discussion…