Skip to main content
QUICK REVIEW

[논문 리뷰] Flash-KMeans: Fast and Memory-Efficient Exact K-Means

Shuo Yang, Haocheng Xi|arXiv (Cornell University)|2026. 03. 10.
Graph Theory and AlgorithmsComputer Science인용 수 0
한 줄 요약

Flash-KMeans는 거리 행렬의 물질화를 제거하고 원자적 쓰기 경쟁을 줄임으로써 현대 GPU에 대한 IO-의식적이고 정확한 K-Means 구현을 제공하며, 베이스라인에 비해 대규모 엔드-투-엔드 속도 향상을 달성하고 정확도 손실 없이 아웃-오브-코어 확장성을 가능하게 한다.

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 imes 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 heuristics, to ensure practical deployability. Extensive evaluations on NVIDIA H200 GPUs demonstrate that flash-kmeans achieves up to 17.9$ imes$ end-to-end speedup over best baselines, while outperforming industry-standard libraries like cuML and FAISS by 33$ imes$ and over 200$ imes$, respectively.

연구 동기 및 목표

  • K-Means를 오프라인 분석에서 AI 시스템의 온라인 프리미티브로 전환하려는 동기를 제시합니다.
  • 표준 GPU K-Means 구현에서의 커널 수준 병목 현상(IO-바운드 할당 및 원자 업데이트 경합)을 식별합니다.
  • 현대 GPU에서 엔드-투-엔드 성능을 개선하기 위한 IO-의식적이며 정확한 형식 보존 재설계를 제안합니다.
  • 아웃-오브-코어 실행 및 다이나믹 쇼페 최적화를 통해 배포 가능성을 입증합니다.
  • AI 파이프라인에서 클러스터링 프리미티브의 하드웨어 인식 가속을 위한 설계 원칙을 제공합니다.

제안 방법

  • 거리 계산을 온라인 argmin과 연결해 N×K 거리 행렬 물질화를 피하는 FlashAssign를 도입합니다.
  • 할당 정렬을 역전시키는 Sort-Inverse 업데이트를 도입해 할당을 정렬하고 역 매핑을 사용해 원자적 스캐터를 세그먼트 수준의 지역 축소로 전환합니다.
  • PCIe 전송을 가리기 위한 청크드 스트림 중첩과 최초 실행 시간(t to first-run)을 줄이는 캐시 인식 컴파일 휴리스트를 적용합니다.
  • 데이터 흐름을 하드웨어 병목 현상 주위로 재구성하면서 표준 Lloyd의 K-Means와 수학적 등가성을 유지합니다.
  • NVIDIA H200 GPU에서 cuML, FAISS, 및 fast_pytorch_kmeans와의 비교를 통해 엔드-투-엔드 및 커널 수준 메트릭 평가합니다.

실험 결과

연구 질문

  • RQ1K-Means를 수학적 형식을 바꾸지 않고도 GPU에서 온라인으로 효율적으로 실행할 수 있는가?
  • RQ2표준 GPU K-Means 구현에서의 주된 하드웨어 병목은 무엇이며 이를 어떻게 완화할 수 있는가?
  • RQ3IO-의식적 커널 설계 및 알고리즘-시스템 공동 설계가 온라인 AI 파이프라인에서 실질적인 엔드-투-엔드 속도 향상 및 배포 가능성을 제공하는가?
  • RQ4제안된 방법이 극단적인 데이터 크기와 동적 워크로드(out-of-core, dynamic shapes)에 얼마나 잘 확장되는가?

주요 결과

  • FlashAssign는 N×K 거리 물질화를 제거하여 할당 커널에서 최대 21.2× 속도 향상을 달성합니다.
  • Sort-Inverse Update는 원자적 경합을 줄이고centroid 업데이트 커널에서 최대 6.3× 속도 향상을 달성합니다.
  • 엔드-투-엔드 속도 향상은 최고의 베이스라인 대비 최대 17.9×에 도달하며 FAISS 대비 200× 이상, cuML 대비 33×의 속도 향상을 제공합니다.
  • 일 Billion 포인트까지의 아웃-오브-코어 시나리오에서 Flash-KMeans는 엔드-투-엔드 속도 향상을 최대 10.5× 제공합니다.
  • 캐시 인식 컴파일 휴리스튜는 최적 성능과 일치하되 튜닝 오버헤드를 최대 175×까지 감소시킵니다.
  • 본 방법은 거의 0의 정확도 영향으로 원활한 아웃-오브-코어 실행 및 다이나믹-쉐이프 배치를 지원합니다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.