A Batched Hartigan's $k$-Means Clustering
Edward Raff, Michael Slawinski
TL;DR. Hartigan's $k$-means is slow because it is sequential, despite being theoretically supperior to the common Lloyd variant. We show how to make Hartigan's algorithm fast for the first time.
Abstract. Hartigan's -means algorithm has theoretical advantages over the standard Lloyd's variant, which has become synonymous with ``-means''. Yet, Hartigan's algorithm is far slower in practice due to its inherently sequential calculations. We devise a Batched Hartigan's method that enables vectorized calculation by exploiting the triangle inequality to expose a set of parallel-safe updates and a smaller set of sequential updates. This makes Hartigan's method competitive with Lloyd's in execution speed for the first time.
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 paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:49 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
The paper proposes an accelerated variant of Hartigan’s k-means algorithm. Standard Hartigan in some cases achieves better quality than Lloyd, but is inherently sequential. The paper uses triangle-inequality bounds on centroid drift to identify batches of point reassignments that can be safely executed in parallel via matrix operations, while the ambiguous cases are still treated sequentially.
All reviewers recognize the strong points of the paper: The problem is well motivated and the technical contributions are original, solid, and yield substantial speedups over standard Hartigan while preserving its clustering quality.
Following the author response and the reviewer discussion phase:
- The authors evaluated additional sparse high-dimensional datasets demonstrating up to an 18% improvement in clustering inertia over Lloyd-based methods addressing comments by reviewers on weak evidence of practical advantage in that setting.
- In response to the detailed feedback by the reviewers on the presentation of the paper, the authors provided a clear, actionable revision plan: adding a notation reference table, a concrete step-by-step example walkthrough (Figure 3), defining all undefined acronyms, removing inaccurate references to LAPACK, and improving the pseudocode formatting. This alleviated most concerns by the reviewers, but understandably there is doubt on how all these changes will be put together, and we will rely on the public accountability (Public OpenReview Accountability) towards the authors to make a meaningful effort to improve the presentation of their paper.
- The paper did not achieve a consensus in a positive evaluation as one reviewer maintained a borderline reject stance primarily due to presentation density and desiring a problem-dependent theoretical runtime analysis. Indeed, such an analysis explaining in further depth what causes the improved behavior of the implementation and in what settings would have substantially improved the contribution of the paper. However, as noted during the discussion with the reviewers, it is not uncommon for heuristic accelerations of existing algorithms to maintain worst-case asymptotic bounds while delivering substantial practical speedups. I think a >10x speedup and clean geometric bounding idea is worth publishing despite the lack of an in-depth theoretical justification.
Mandate for Camera-Ready: The authors are required to incorporate all promised revisions into the final camera-ready version, including the notation reference table, worked example walkthrough, defined terminology, dataset summary table, and expanded high-dimensional empirical results.
Final justification
Overall, two reviewers support acceptance (scores: 5 and 4) and one leans borderline reject (score: 3). The significance of making Hartigan's method computationally competitive on a fundamental, widely-used machine learning routine justifies acceptance.
Read meta-review
Meta-review
The paper proposes an accelerated variant of Hartigan’s k-means algorithm. Standard Hartigan in some cases achieves better quality than Lloyd, but is inherently sequential. The paper uses triangle-inequality bounds on centroid drift to identify batches of point reassignments that can be safely executed in parallel via matrix operations, while the ambiguous cases are still treated sequentially.
All reviewers recognize the strong points of the paper: The problem is well motivated and the technical contributions are original, solid, and yield substantial speedups over standard Hartigan while preserving its clustering quality.
Following the author response and the reviewer discussion phase:
- The authors evaluated additional sparse high-dimensional datasets demonstrating up to an 18% improvement in clustering inertia over Lloyd-based methods addressing comments by reviewers on weak evidence of practical advantage in that setting.
- In response to the detailed feedback by the reviewers on the presentation of the paper, the authors provided a clear, actionable revision plan: adding a notation reference table, a concrete step-by-step example walkthrough (Figure 3), defining all undefined acronyms, removing inaccurate references to LAPACK, and improving the pseudocode formatting. This alleviated most concerns by the reviewers, but understandably there is doubt on how all these changes will be put together, and we will rely on the public accountability (Public OpenReview Accountability) towards the authors to make a meaningful effort to improve the presentation of their paper.
- The paper did not achieve a consensus in a positive evaluation as one reviewer maintained a borderline reject stance primarily due to presentation density and desiring a problem-dependent theoretical runtime analysis. Indeed, such an analysis explaining in further depth what causes the improved behavior of the implementation and in what settings would have substantially improved the contribution of the paper. However, as noted during the discussion with the reviewers, it is not uncommon for heuristic accelerations of existing algorithms to maintain worst-case asymptotic bounds while delivering substantial practical speedups. I think a >10x speedup and clean geometric bounding idea is worth publishing despite the lack of an in-depth theoretical justification.
Mandate for Camera-Ready: The authors are required to incorporate all promised revisions into the final camera-ready version, including the notation reference table, worked example walkthrough, defined terminology, dataset summary table, and expanded high-dimensional empirical results.
Final justification
Overall, two reviewers support acceptance (scores: 5 and 4) and one leans borderline reject (score: 3). The significance of making Hartigan's method computationally competitive on a fundamental, widely-used machine learning routine justifies acceptance.
- Rating
- 5/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes geometric methods (based on the distance bounds from the triangle inequality) that can be used to accelerate the Hartigan-Wong clustering algorithm. The paper uses these distance bounds to prove when some computations which are sequential in the original algorithm can be provably parallelized, allowing faster computations via matrix multiplications. The approach works, and gives significant speedup compared with the sequential Hartigan algorithm as well as Lloyd's algorithm and some of its accelerated variants.
Strengths and weaknesses
-
Strengths
- This opens a new approach on accelerating a classic algorithm for optimizing the k-means criterion. It already seems to work well and may improve as others look at the topic, as Hartigan's algorithm tends to have fewer iterations (which is beneficial for overall efficiency).
- The paper appears to provide plenty of detail so that a practitioner could implement the algorithms described.
- The experimental evidence
- The paper reads fairly well.
-
Weaknesses
- Equation 2 defines the Hartigan cost. In that paragraph, it would be helpful to the reader to explain that the Hartigan algorithm (Algorithm 1) chooses the cluster reassignment that minimizes this quantity (over all point/center pairs). The last sentence (line 80) hints at this but is not clear how Equation 2 fits.
- Line 101 claims that there is a slowdown of 3-10x of Hartigan's algorithm compared to Lloyd's algorithm despite having the same asymptotic complexity. Two comments: first, it strikes me as strange to give a specific numeric speedup factor for "large k and/or high D" without specifying those ranges. Second, couldn't the matrix multiplication algorithm be faster due to fast matrix algorithms (not just finely tuned, but asymptotically faster)? In this case, they do not actually have the same asymptotic complexity; Lloyd's would be faster by a non-constant amount.
- Algorithm 2 uses a number of variables before defining or explaining what they are for.
- On line 120, the notation "/B/ = {1,...,B}" does not make sense (here I'm using /B/ to represent "curly B"). I think B is the cardinality of /B/, but the values of /B/ are not 1 to B, right? Otherwise each batch is just the first B points of the dataset.
- Line 123 refers to the "Hartigan cost" without referring to equation 2 where it is defined as the "Hartigan weighted distance". This is confusing.
- Lemma 4.1 assumes that the reader knows that m is the currently assigned cluster. That is clear if the reader looks at Algorithm 3, but the Lemma should be self-contained (just define what m is).
- Algorithm 3 has a variable on line 17 ("changed") that is set to TRUE, but never initialized or used elsewhere.
- This phrase (line 177) is unclear: "despite technically doing equal or greater work in all cases (bounded by doing 2×the calculations, the batch set and re-calculating all individually).". The "equal or greater work" -- is that an asymptotic measurement? If so, please say that. And the parenthetical note does not really parse for me; I'm not sure what it is saying (e.g. re-calculating all what individually?).
- Definition 4.3 refers to "Algorithm 1, lines 8-22", but there are only 11 lines in Algorithm 1.
- Lines 207-209 refer to L as "leave decisions" and J as "move decisions". It makes more sense to call J "join decisions" (for the letter J, but also because L also represents moves).
- On line 212, since S^- is a strict subset of C_j, it's not necessary to point out that n_j - |S^-| >= 1.
- The lemmas given without proofs in the body of the paper leaves the reader wondering why these are true. The paper could give guidance on why these are true and refer to the appendices for full proofs.
- In Lemma 4.3, it's unclear what "T(b) touches C_j" means. The term "touch' has not been defined. (Indeed, it's still unclear what T(b) means exactly, as Definition 4.3 refers to lines of Algorithm 1 that don't exist.)
- The following terms are used but not defined:
- GEMM
- EMA
- m(i)
- Line 272 - why is "(64-256)" the minimum GEMM size worth calling? Give some justification for these numbers.
- Line 288: shouldn't this be per-batch updates? (It's O(N) across the dataset, but the term "per-batch" implies the cost of one batch, which is of size B.)
- For the results in Figure 1 (on the number of iterations compared to Lloyd's algorithm), do all algorithms begin with the same initialization?
- The results in Table 1 probably use too much precision. I doubt these experiments were run 10^6 times to support 6 digits after the decimal. I
- Timing results given as exponential notation (2^0.9, 2^-5.1) in Table 2 is hard to read and compare. Why not just give decimal or scientific notation?
- It would be good to report not only the wall-clock running time of the proposed algorithm, but also experimental statistics on how often each of the different pruning methods were effective in the proposed algorithm.
- According to Andrew Moore (and others), it is "hardest" to accelerate clustering on data that has a uniform distribution (no natural clusters). Did you try this as a worst-case scenario?
Questions
The questions I posed are listed in the strengths/weaknesses section.
Limitations
Yes
Formatting concerns
- Don't use a citation to begin a sentence. This happens in several places.
- Typos:
- Line 50: Hammerly => Hamerly
- Line 60: paralleization => parallelization
- Line 126: "cluster's"
- Line 127 ends a sentence with a colon.
- Line 172: s/deffer it's/defer its/
- Line 308: "...on an Apple M4 Pro"
- Line 322: s/Hartigran's/Hartigan's/
- There are math mode markers in the references ("")
- "Better designing triangle-inequality pruning..." does not parse easily; please reword.
- Several of the algorithm listings have lines that wrap (including comments), making the code harder to read.
- Making the text columns narrow to fit the algorithms means that the text columns can be difficult to read (especially when the math wraps lines).
2 comments
The authors have addressed all of the issues I raised, and I appreciate the care they have shown in doing that. I still believe that this paper is worth accepting, so I am not changing my score.
- Rating
- 3/6
- Confidence
- 3/5
- Quality
- 2/4
- Clarity
- 1/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper proposes an accelerated version of Hartigan's k-means. The main idea is to compute distances for groups of points and use triangle-inequality bounds to decide which point reassignments can be made without recomputing all distances immediately. The authors provide correctness arguments showing monotone decrease and convergence to a Hartigan fixed point, and evaluate the method against sequential Hartigan implementations and Lloyd-family accelerations including Elkan and Hamerly.
Strengths and weaknesses
Strengths:
The paper addresses a relevant computational limitation of Hartigan's method. Unlike Lloyd-style updates, Hartigan's sequential point moves and immediate centroid updates make vectorized distance computation difficult. The use of triangle-inequality bounds to certify groups of safe decisions is an interesting way to recover some batched computation while preserving Hartigan-style descent.
The empirical results seems to be promising. The evaluation covers several datasets, a range of k values, and relevant baselines. The reported speedups over existing Hartigan implementations are substantial, and the comparison to Elkan and Hamerly is appropriate for assessing practical relevance.
Weaknesses
My main concern is that the manuscript is much harder to follow than the underlying idea seems to require. As I understand it, the central idea is to use triangle-inequality drift bounds to certify which point reassignment decisions remain safe after batch distance computation, allowing many Hartigan updates to be grouped while sending ambiguous cases to a sequential fallback. This is a clean idea, but the presentation obscures it. The main obstacle is the notation: many symbols are introduced across several subsections, reused in slightly different roles, and then required to understand the algorithms, lemmas, and proofs. This makes the reader constantly track batch indices, cluster sizes, drift bounds, lower/upper cost bounds, screening bounds, and aggregate flows. The pseudocode is also dense, visually hard to parse, and overloaded with implementation details. A simpler high-level description, followed by a more modular derivation of the bounds and a clearer separation between algorithmic ideas and implementation details, would substantially improve readability.
The manuscript also shows several signs of insufficient care in the exposition, which compounds the readability issue. The pseudocode formatting is not good, making already dense algorithms harder to parse. Several important terms are also used without definition. For example, the results section reports SSE ratios without explicitly defining SSE or stating that it corresponds to the k-means objective in Eq. (1). Similarly, the paper uses numerical linear algebra terminology such as BLAS, LAPACK, level-3 BLAS, and GEMM without defining the acronyms. Since these terms are central to the motivation and claimed speedup, this lack of definition creates unnecessary friction. If LAPACK is mentioned as part of the computational motivation, it is also unclear whether the implementation actually relies on LAPACK rather than only BLAS/GEMM.
A general difficulty with this kind of empirical comparison is that the baselines come from different libraries and programming languages. This makes it hard to separate algorithmic effects from implementation effects. This difficulty is not unique to this paper, but it is aggravated here by the fact that the authors' implementation is not available.
Questions
Could the autors simplify the notation and pseudocode presentation? The central idea seems relatively simple, but the paper is hard to follow because many symbols must be remembered across several subsections and the pseudocode is visually dense. A clearer high-level algorithm, a more modular derivation of the bounds, and cleaner pseudocode would make the correctness argument much easier to assess. This would materially improve my evaluation of the paper
Is it possible to provide a more explicit cost analysis for the proposed speedup? The current text presents local costs, such as O(BkD) for batch distance computation and O(Bk) for safety checks, but it is difficult to understand the end-to-end cost per epoch.
Could the authors provide results as a function of k instead of mainly aggregating over powers-of-two k values? Since distance computation and many overheads scale with k, aggregating across k can hide important behavior; in particular, large k values may dominate summary statistics.
Can make the dataset-dependent trends easier to interpret? A compact table with at least N, D, and N x D for every dataset, together with a consistent ordering of datasets across result tables, would help substantially. For example, ordering by number of instances N, or by N x D, would make it easier to see when the method helps. The experimental setup should also clearly state preprocessing and normalization choices.
Limitations
The discussion would be stronger if it more explicitly covered the regimes where the method may not help
Final justification
find the core idea interesting, but my main concerns remain. The presentation is dense, especially the notation and pseudocode, and it is hard to judge from the rebuttal how much the promised changes will improve the paper.
Since this is mainly an acceleration paper, I would expect a clearer computational analysis. This should account not only for N, D, and k, but also for problem-dependent quantities, at least some of which are directly related to the effectiveness of the bounds: cluster separation, assignment margins, centroid movement, or the fraction of points near decision boundaries. These quantities directly affect pruning and fallback rates, and would also help clarify the limitations of the method.
I also find the empirical evidence hard to interpret because it compares different implementations/libraries without code available during review.
Given these unresolved issues, I do not think the paper should be accepted in its current form. I have updated my recommendation from reject to borderline reject.
Formatting concerns
No mayor issue
3 comments
Rebuttal
Clarity and Notation
"The manuscript is much harder to follow than the underlying idea seems to require."
We agree clarity can always be improved and have made targeted revisions. We take as a compliment that we were abel to get the core idea distiled to the point of being "simple", but disagree that it means the proof and thorough testing is quite as simple as the intution. We note that our algorithms are already decomposed into three separate self-contained procedures (BuildBatch, PartialParallelBatch, SequentialFallback) each with distinct purposes. The changes:
- Notation reference table added to the start of §4. The full table:
| Symbol | Domain | Meaning |
|---|---|---|
| B | ℕ | Batch size (points per GEMM) |
| 𝓑 = {1,…,B} | index set | Indices within current batch |
| μⱼ⁽⁰⁾ | ℝᴰ | Centroid of cluster j at batch start |
| μⱼ⁽ᵇ⁾ | ℝᴰ | Centroid of cluster j after b-th item processed |
| nⱼ⁽ᵇ⁾ | ℕ | Size of cluster j after b-th item |
| d̂ᵦⱼ | ℝ≥0 | Precomputed ‖xᵦ − μⱼ⁽⁰⁾‖² (from GEMM) |
| δⱼ⁽ᵇ⁾ | ℝ≥0 | Cumulative drift bound for cluster j after b items |
| Hⱼˡᵒ, Hⱼʰⁱ | ℝ | Lower/upper bounds on Hartigan cost to cluster j |
| uᵢ, ℓᵢ | ℝ≥0 | Per-point upper/lower distance bounds (cross-batch screening) |
| σⱼ | ℝ≥0 | Cumulative centroid displacement since last batch touching point i |
| U | ||
| A |
- Worked example added as Figure 3 with concrete numbers. The walkthrough:
Setup: N=100 points in 2D, k=3, batch size B=8. Centroids μ₁=(2,1), μ₂=(5,4), μ₃=(8,2).
Step 1 — Screening: Of the 8 candidate points, 3 have cross-batch bounds satisfying uᵢ < ℓᵢ (their nearest centroid hasn't moved enough to matter). These are skipped. 5 points enter the batch.
Step 2 — GEMM distance: Compute all 5×3 = 15 squared distances in one matrix multiply: D̂ = ‖X‖² − 2X·μᵀ + ‖μ‖². Cost: one BLAS call.
Step 3 — Safety certification: For each point, check S1 (safe to move) and S2 (safe to stay) using drift bounds δⱼ. Result: 4 points certified safe (3 stay, 1 moves to cluster 2). 1 point is ambiguous (d̂ᵢ₁ − δ₁ < d̂ᵢ₂ + δ₂ — can't certify).
Step 4 — Bulk update: The 4 safe decisions are applied. Centroids updated: μ₂ shifts by 0.03 (one point absorbed into cluster of size 34).
Step 5 — Sequential fallback: The 1 ambiguous point is processed with exact recomputed distances against the updated centroids. It stays in cluster 1.
-
Pseudocode formatting improved: Increased whitespace, added grouping lines between logical sections, and ensured variable names in pseudocode match the notation table exactly.
-
Structural clarifications: We believe the derivation's logical order is sound (define drift → bound distances → define safe conditions → prove commutativity → bound aggregate drift → prove bulk correctness). To improve it we will:
- The notation paragraph defining 6 symbols in continuous prose is replaced by the table above — symbols are now scannable, not buried in sentences.
- Algorithms 3 and 4 appear as wrapfigures alongside their justifying theory due to LaTeX layout constraints, which means the reader encounters pseudocode before the lemmas that justify it. We add a 2-sentence "purpose and guarantee" preamble to each algorithm caption so the reader knows what it does and why it's correct before parsing the lines.
- Subsection transitions now explicitly connect results: §4.1 closes with "Having established safe certification for individual points, §4.2 shows how to partition an entire batch and execute the safe majority in bulk," and §4.2 closes with the analogous bridge to adaptive sizing.
Undefined Terms
"SSE, BLAS, LAPACK, GEMM used without definition. Since these terms are central to the motivation and claimed speedup, this creates unnecessary friction. It is unclear whether the implementation relies on LAPACK."
All terms are now defined at first use:
- SSE: "sum of squared errors (SSE), the k-means objective ∑ᵢ‖xᵢ − μₐᵢ‖² from Eq. (1)"
- BLAS: "Basic Linear Algebra Subprograms (BLAS), the standard compiled routines for vectorized linear algebra available in every scientific computing environment"
- GEMM: "GEneral Matrix Multiply, the level-3 BLAS operation computing C = αAB + βC, which achieves near-peak CPU throughput via cache-blocking and SIMD"
We have removed the LAPACK reference — it was inaccurate. Our method uses only BLAS (specifically GEMM for batch distance computation via the identity ‖x−c‖² = ‖x‖² − 2x·c + ‖c‖²). Stating "BLAS+LAPACK" is a habbit, and corrected.
End-to-End Cost Analysis
"The current text presents local costs but it is difficult to understand the end-to-end cost per epoch."
We add §4.5 "Per-Epoch Cost Analysis" with a formal comparison:
| Method | Distance computation | Centroid update | Overhead |
|---|---|---|---|
| Lloyd | O(NkD) | O(ND) | — |
| Elkan | O(N'kD), N' ≤ N | O(ND + k²D) | O(Nk) |
| Batched Hartigan | O($\approx$0.1 · NkD) | O($\approx$0.1 · ND) | O(N) |
The $\approx$0.1 constants represents the fraction of points not eliminated by cross-batch screening. After early epochs, most points are stable (their nearest centroid hasn't moved enough to invalidate the assignment). Our ablation Table 6 shows removing screening causes 2–19× slowdown on large datasets, meaning screening eliminates 50–95% of work. We use 0.1 (90% screened) as a conservative representative for epochs 3+.
Per-k Results
"Could the authors provide results as a function of k instead of mainly aggregating over powers-of-two k values?"
We add a per-k heatmap (new Figure 5, dataset × k) and report the per-k speedup statistics. We can see that Elkan and Batched Hartigan are in the same range and similar speedup, as reflected in our current results, and that the old Hartigan algorthm is generally slower than Lloyd's method.
| k | Prior Hartigan (C++) | Elkan | Batched Hartigan (ours) |
|---|---|---|---|
| 2 | 2.6× (0.3–4.6) | 12.8× (2.6–23.7) | 8.5× (1.2–21.3) |
| 4 | 2.3× (0.3–5.9) | 13.2× (4.0–23.4) | 10.6× (2.0–26.0) |
| 8 | 1.6× (0.5–3.1) | 12.0× (3.8–19.6) | 9.9× (0.8–21.9) |
| 16 | 0.9× (0.2–1.2) | 9.6× (2.8–16.8) | 9.4× (0.7–19.4) |
| 32 | 0.7× (0.3–1.2) | 8.6× (3.7–13.0) | 8.4× (1.2–17.2) |
| 64 | 0.6× (0.2–0.9) | 7.3× (4.5–11.4) | 6.5× (2.3–11.8) |
| 128 | 0.4× (0.1–1.2) | 6.0× (4.4–8.4) | 4.6× (3.0–6.9) |
Dataset Table
"A compact table with at least N, D, and N×D for every dataset..."
We add Table 1 at the start of §5:
| Dataset | N | D | N×D |
|---|---|---|---|
| phishing | 11,055 | 68 | 752K |
| MAGIC Gamma | 19,020 | 10 | 190K |
| Letter | 20,000 | 16 | 320K |
| Superconductivity | 21,263 | 81 | 1.7M |
| Shuttle | 58,000 | 7 | 406K |
| cod-rna | 59,535 | 8 | 476K |
| mnist | 60,000 | 780 | 46.8M |
| connect-4 | 67,557 | 126 | 8.5M |
| aloi | 108,000 | 128 | 13.8M |
| Sepsis | 110,341 | 3 | 331K |
| skin-nonskin | 245,057 | 3 | 735K |
| covtype | 581,012 | 54 | 31.4M |
| SUSY | 5,000,000 | 18 | 90M |
Datasets are ordered by N throughout all tables and figures. Preprocessing: all features standardized to zero mean, unit variance. No other preprocessing applied.
Cross-Language Baselines
"A general difficulty is that baselines come from different libraries and programming languages. This makes it hard to separate algorithmic effects from implementation effects."
The computational bottleneck for ALL methods is GEMM (batch distance computation), and BLAS is standard in every NumPy/SciPy installation. Whether called from Python, C++, or Fortran, the identical compiled BLAS library (OpenBLAS, MKL, or Accelerate) performs most of the work.
Our primary timing comparison is against scikit-learn's Elkan (Table 4), which shares the exact same Python + compiled BLAS backend as our implementation. This is an apples-to-apples comparison where the only variable is the algorithm.
The C++ baselines (Table 3) are included to show that prior Hartigan implementations are slow regardless of language, and our competitiveness with Hamerly's C++ code. Our Python implementation beats compiled C++ Hartigan by 17× on covtype — a result that can only be explained by algorithmic superiority (GEMM batching + screening), since the language handicap works against us.
We add a "Language" column to all timing tables for transparency.
Code Availability
We commit to releasing our complete implementation as open-source upon acceptance.
Limitations
"The discussion would be stronger if it more explicitly covered the regimes where the method may not help."
We expand the limitations discussion in §6. The only limitation is multi-core scaling: because the sequential fallback processes ambiguous points one-at-a-time with immediate centroid updates, parallelism beyond the GEMM level requires careful synchronization. Our multi-core experiments show diminishing returns beyond ~4 threads due to the Amdahl's-law effect of the sequential fraction. This is an inherent property of Hartigan's method (immediate updates are what give it superior convergence) and represents the key trade-off our batching approach partially — but not fully — resolves. While our work is the first to expose any paralleism/effiency in this otherwise sequential algroithm, we hope others will be inspired to bild on our approach and devise new techniqus to avoid this bottleneck.
Beyond the reviewer's questions, we strengthen the empirical case with additional sparse high-dimensional datasets (new Appendix). As Reviewer u22a noted, Hartigan's theoretical superiority in solution quality is well-established. We now demonstrate it empirically across 11 additional sparse datasets with D up to 100k, please see our reply to them.
I appreciate the effort the authors have put into addressing the reviewers' comments. The proposed changes to improve clarity may indeed help, although this is difficult to assess from the rebuttal alone, and I expect the notation to remain fairly heavy.
However, some of my main concerns remain insufficiently addressed. In particular, the primary contribution of the paper is its computational acceleration and I am still not convinced by the proposed per-iteration cost analysis.
For these reasons, I am maintaining my original score.
What is missing?
Could you provide us with some clarity on what is missing in your concerns? For per-iteration costs specifically, we have the algorithm runtime in the paper; we have added a summary big-O table in the rebuttal. If you can tell us what you are looking for in particular, we can help clarify. But without further clarity -- we would just be guessing at the source of your need.
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 4/4
- Clarity
- 4/4
- Significance
- 2/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
Hartigan’s k-means is a known variant of the well-known Lloyd k-means algorithm. It has some theoretical advantages over Lloyd’s algorithm, and there is growing experimental evidence that, in some settings, it produces superior clusterings. It is, however, rarely used in practice.
The paper argues that the reason for this is the algorithm’s computational speed. Even though the two variants have the same asymptotic complexity, standard Hartigan updates cluster assignments and centroids after processing each individual point. This makes the method inherently sequential and prevents efficient vectorized computation.
The paper proposes Batched Hartigan. The method computes point-to-centroid distances in batches and uses triangle-inequality bounds on centroid drift to identify assignments that can be safely processed in parallel, while handling ambiguous cases sequentially. Experiments indicate substantial speedups over existing Hartigan implementations and runtimes competitive with accelerated Lloyd variants in some regimes, while generally preserving Hartigan’s slightly better clustering objective values.
Strengths and weaknesses
Positive:
There are many aspects in which the paper is very strong. The motivation is clear, the proposed algorithm is technically substantial, and the use of centroid-drift bounds to expose batch-safe Hartigan updates appears original. The paper provides careful correctness arguments and an extensive experimental comparison with existing Hartigan implementations and accelerated Lloyd variants. The presentation is generally clear despite the complexity of the method.
Negative:
My main concern is the significance of the contribution. The paper shows convincingly that Batched Hartigan is substantially faster than previous Hartigan implementations. However, the improvement in clustering objective over Lloyd-based methods is generally very small in the reported experiments. At the same time, the proposed method is considerably more complex to implement than either standard Hartigan or Lloyd’s algorithm, involving adaptive batching, drift bounds, screening, safe-update tests, and sequential fallbacks. It is therefore unclear whether the modest objective improvement is sufficient to justify the additional implementation complexity in practice. The significance of the work would be stronger if the paper demonstrated important settings in which Hartigan provides a materially larger practical advantage, perhaps the high-dimensional and sparse regimes identified in [15].
Questions
-
The empirical improvement in the k-means objective over Lloyd-based methods is generally small on the datasets considered. Are there particular data regimes in which the authors expect the advantage of Hartigan fixed points to be substantially larger, perhaps the high-dimensional or sparse settings discussed in [15]?
-
Can Batched Hartigan be used as a refinement step after Lloyd’s algorithm has converged? Would this strategy provide a better quality–runtime tradeoff than using the same additional computation for more independent k-means++ initializations followed by Lloyd’s algorithm?
Limitations
YES.
Final justification
I would like to thank the authors. The rebuttal strengthened my positive view of the paper.
Formatting concerns
No.
1 comment
Rebuttal
Q1: Are there particular data regimes in which the authors expect the advantage of Hartigan fixed points to be substantially larger, perhaps the high-dimensional or sparse settings discussed in [15]
Yes, this was an oversight on our part. Our Batched approach works well for sparse datasets too, and so we have run the same settings/tests on several datasets from the LibSVM webpage. The general theme is that high- datasets increasingly have cases where Hartigan K-means produces significantly improved Inertia, but up to 18% (see table below), and in no cases is Batch Hartigan produce a worse inertia. Depending on the dataset alternative may produce more similar results, reflecting the variation/intrinsic distribution differences between the datasets. This gives a stronger example of the value of Batched Hartigan today, as it allows capturing a superior frontier of solution qualities.
| Dataset | N | D | Density | Inertia Ratio | at k |
|---|---|---|---|---|---|
| breast-cancer | 683 | 10 | 1.0000 | 0.9504 | 128 |
| leukemia | 38 | 7,129 | 1.0000 | 0.9134 | 16 |
| duke | 44 | 7,129 | 1.0000 | 0.8201 | 4 |
| bibtex | 7,395 | 1,836 | 0.0374 | 0.9639 | 4 |
| sector | 6,412 | 55,197 | 0.0030 | 0.9866 | 256 |
| news20 | 15,935 | 62,061 | 0.0013 | 0.9030 | 8 |
| rcv1_multi | 15,564 | 47,236 | 0.0014 | 0.9933 | 256 |
| E2006-tfidf | 16,087 | 150,360 | 0.0083 | 0.9891 | 32 |
| scotus | 7,800 | 126,405 | 0.0107 | 0.9775 | 256 |
| Wiki10-31K | 20,762 | 104,374 | 0.0065 | 0.9845 | 256 |
| real-sim | 72,309 | 20,958 | 0.0024 | 0.9794 | 256 |
We will add a graphical plot to the revision that better illustrates the range of producing improvement on each dataset.
Q2: Can Batched Hartigan be used as a refinement step after Lloyd’s algorithm has converged? Would this strategy provide a better quality–runtime tradeoff than using the same additional computation for more independent k-means++ initializations followed by Lloyd’s algorithm?
Yes, it can be used as a refinement step to Lloyds, as Hartigans solutions are a subset of the Lloyd solutions. However, it does not appear to be an "improvement" Using Hart to refine Lloyd's tends to produce better solutions than Lloyd, but, Hart from the intial k-means++ seed selection converges to better quality solutions when an advantage is available. This is reasonable, since Lloyd has already converged to a potentially worse minima. This also seems to cause Hartigan's to have to do the same or even more work to converge to a new solution, where running Batch Hartigan from scratch is faster than running Lloyds on all bu the smallest datasets in this example.
| Dataset | N | D | Density | k | Hart(km++) | Hart(refine) | Refine Overhead (%) |
|---|---|---|---|---|---|---|---|
| breast-cancer | 683 | 10 | 1.0000 | 128 | 0.9504 | 0.9754 | 44.1% |
| leukemia | 38 | 7,129 | 1.0000 | 16 | 0.9134 | 0.9407 | 305.4% |
| duke | 44 | 7,129 | 1.0000 | 4 | 0.8201 | 0.9551 | 298.5% |
| bibtex | 7,395 | 1,836 | 0.0374 | 4 | 0.9639 | 0.9864 | 75.7% |
| sector | 6,412 | 55,197 | 0.0030 | 256 | 0.9866 | 0.9869 | 77.2% |
| news20 | 15,935 | 62,061 | 0.0013 | 8 | 0.9030 | 0.9305 | 493.8% |
| rcv1_multi | 15,564 | 47,236 | 0.0014 | 256 | 0.9933 | 0.9934 | 63.5% |
| E2006-tfidf | 16,087 | 150,360 | 0.0083 | 32 | 0.9891 | 1.0073 | 130.1% |
| scotus | 7,800 | 126,405 | 0.0107 | 256 | 0.9775 | 0.9801 | 392.9% |
| Wiki10-31K | 20,762 | 104,374 | 0.0065 | 256 | 0.9845 | 0.9917 | 362.7% |
| real-sim | 72,309 | 20,958 | 0.0024 | 256 | 0.9794 | 0.9843 | 81.6% |
While we wouldn't recommend this as the approach going forward, we agree this was a worthwhile question and exploration, and we will add it to the article.
more complex to implement than either standard Hartigan or Lloyd’s algorithm, involving adaptive batching,
We do wish to make a note that Hamerly or Elkan's variant of Lloyd's is the more appropriate comparison, since they also do the extra work to prune out distance calculations. In that regard, we do not feel our method is any more or less complicated than other triangle inequality based pruning method.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
We thank the reviewer for their careful reading and constructive suggestions. Below we address each point with the specific changes made.
"explain that the Hartigan algorithm chooses the cluster reassignment that minimizes this quantity"
Added after Eq. 2: "Algorithm 1 reassigns xᵢ to the cluster j* = argmin_j Δ²_H(xᵢ, Cⱼ) whenever Δ²_H(xᵢ, Cⱼ*) < Δ²_H(xᵢ, Cₘ), i.e., the greedy move that maximally decreases the k-means objective (Eq. 1)."
"strange to give a specific numeric speedup factor for 'large k and/or high D' without specifying ranges"
Clarified to "k ≥ 32, D ≥ 50" with citation to our Table 3 empirical data.
"couldn't the matrix multiplication algorithm be faster due to fast matrix algorithms?"
Sub-cubic algorithms (Strassen, Coppersmith-Winograd) have large constant factors and are numerically unstable — no production BLAS library uses them (that we are aware of). The constant-factor advantage of GEMM over sequential scalar operations comes entirely from cache-blocking and SIMD vectorization, not asymptotic improvements. We clarify this distinction.
"Algorithm 2 uses a number of variables before defining or explaining what they are for"
We add a notation reference table (Table 2) directly before Algorithm 2, and add inline comments marking where each variable is defined in subsequent subsections.
"the notation 𝓑 = {1,...,B} does not make sense... the values of 𝓑 are not 1 to B, right?"
Correct — 𝓑 indexes positions within the batch, not dataset indices. The batch is a subsequence of [N]; we relabel as 1…B for notational convenience within each batch. Clarified: "𝓑 denotes the ordered set of B point indices selected for the current batch; we index within the batch as b = 1,…,B for notational simplicity."
"Line 123 refers to 'Hartigan cost' without referring to equation 2"
Added explicit "(Eq. 2)" cross-reference. Both "Hartigan cost" and "Hartigan weighted distance" now point to the same definition.
"Lemma 4.1 assumes the reader knows that m is the currently assigned cluster"
Added "where m denotes the index of xᵦ's currently assigned cluster" to the lemma statement.
"Algorithm 3 has a variable 'changed' that is set to TRUE, but never initialized or used elsewhere"
This was a typo/artifact — the
changedflag is used by the outer loop (Algorithm 2) to detect convergence but was incorrectly shown in Algorithm 3's scope. Removed from Algorithm 3; the return value (number of moves) already communicates this to Algorithm 2."'despite technically doing equal or greater work in all cases (bounded by doing 2× the calculations)'"
Rewritten: "The sequential kernel performs at most 2× the arithmetic of a plain Hartigan sweep: once for the batch GEMM distances (O(BkD)), and at most once more for exact recomputation of ambiguous points. In practice <5% of points require recomputation, so overhead is negligible."
"Definition 4.3 refers to 'Algorithm 1, lines 8-22', but there are only 11 lines"
Typo — should reference lines 4–9 (the inner loop computing Δ²ⱼ and argmin). Fixed.
"It makes more sense to call J 'join decisions'"
Agreed. Changed "move" to "join" throughout.
"since S⁻ is a strict subset of Cⱼ, it's not necessary to point out that nⱼ - |S⁻| ≥ 1"
Correct — strict subset already guarantees the denominator is nonzero. Removed the redundant statement.
"The lemmas given without proofs leaves the reader wondering why these are true"
We add a one-sentence proof sketch after each lemma in the main text, e.g., "Proof sketch: follows from repeated application of the triangle inequality to the telescoping sum of centroid displacements (full proof in Appendix C)."
"it's unclear what 'T(b) touches Cⱼ' means"
Defined explicitly: "'T(b) touches Cⱼ' means T(b) either removes b from Cⱼ (b ∈ Lⱼ) or adds b to Cⱼ (b ∈ Jⱼ)."
"The following terms are used but not defined: GEMM, EMA, m(i)"
All now defined at first use:
"why is '(64-256)' the minimum GEMM size worth calling? Give some justification"
Below B ≈ 64, the fixed overhead of a GEMM call (memory allocation, dispatch, thread synchronization) exceeds the arithmetic time for small matrices. Our ablation (Table 5) confirms: fixing B = 64 produces 1.4–9× slowdown from excessive per-batch overhead. The 64–256 range balances GEMM efficiency against drift accumulation.
"Line 288: shouldn't this be per-batch updates?"
Reviewer is correct. The per-batch centroid update cost is O(BD); the O(N) figure refers to the full-epoch aggregate. Clarified: "O(BD) per batch, O(ND) across all batches in one epoch."
"do all algorithms begin with the same initialization?"
Yes — all algorithms share identical k-means++ initial centers per trial (selected externally and shared via intial conditions).
"I doubt these experiments were run 10⁶ times to support 6 digits"
Reduced to 4 significant figures. The 6-digit precision was an artifact of automated CSV export, not meaningful.
"Timing results given as exponential notation (2^0.9, 2^-5.1) is hard to read"
Replaced with decimal seconds. Original motivation was log-scale compression for the wide dynamic range across datasets, but readability suffers — changed.
"report experimental statistics on how often each pruning method was effective"
Added to the ablation appendix. Summary: cross-batch screening eliminates 50–95% of points after epoch 2; of the remainder, the parallel safety path resolves 70–99.9% via bulk GEMM certification. The sequential fallback handles <5% of points in steady state.
"it is 'hardest' to accelerate clustering on data that has a uniform distribution. Did you try this?"
We did not include uniform data in the original experiments. Uniform distributions degrade all triangle-inequality methods equally (Elkan, Hamerly, and ours) because no points can be pruned when all clusters are equidistant — this is well-known in the literature. Our method's relative advantage versus Elkan should be preserved since the parallel safety certification and screening operate on the same bounds. We are happy to add a synthetic uniform experiment in the appendix if the reviewer considers it essential.