Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
K Nearest Neighbourhood on GPU
Search
Ciel
July 24, 2014
Research
0
40
K Nearest Neighbourhood on GPU
K Nearest Neighbourhood using inverted list on GPU
Ciel
July 24, 2014
Tweet
Share
More Decks by Ciel
See All by Ciel
LLVM IR & Optimisation Techniques
imwithye
0
160
Other Decks in Research
See All in Research
Adaptive Experimental Design for Efficient Average Treatment Effect Estimation and Treatment Choice
masakat0
0
110
AI エージェントを活用した研究再現性の自動定量評価 / scisci2025
upura
1
150
AlphaEarth Foundations: An embedding field model for accurate and efficient global mapping from sparse label data
satai
1
210
Language Models Are Implicitly Continuous
eumesy
PRO
0
230
Combinatorial Search with Generators
kei18
0
770
Google Agent Development Kit (ADK) 入門 🚀
mickey_kubo
2
1.8k
なめらかなシステムと運用維持の終わらぬ未来 / dicomo2025_coherently_fittable_system
monochromegane
0
2.8k
Vision and LanguageからのEmbodied AIとAI for Science
yushiku
PRO
1
530
Mechanistic Interpretability:解釈可能性研究の新たな潮流
koshiro_aoki
1
410
単施設でできる臨床研究の考え方
shuntaros
0
2.7k
SSII2025 [TS1] 光学・物理原理に基づく深層画像生成
ssii
PRO
4
4.2k
GPUを利用したStein Particle Filterによる点群6自由度モンテカルロSLAM
takuminakao
0
270
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
56
13k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Site-Speed That Sticks
csswizardry
10
820
Making Projects Easy
brettharned
117
6.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
Docker and Python
trallard
45
3.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Rails Girls Zürich Keynote
gr2m
95
14k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Transcript
Genie-and- Lamp-GPU Yiwei Gong K Nearest Neighbourhood using inverted list
on GPU
K Nearest Neighbourhood Fundamental Operator in Data Mining Classification 0
5 10 15 20 0 3 6 9 12 Regression Collaborative Filtering You may like * Apple * Google * Amazon
SELECT SEX M AGE 18 SALARY 2900 Sex Age Salary
… M 20 3000 … F 17 3600 … M 18 4000 … F 19 2900 … K Nearest Neighbourhood A running example
SELECT SEX M AGE 18 SALARY 2900 K Nearest Neighbourhood
Sex Age Salary … M 20 3000 … F 17 3600 … M 18 4000 … F 19 2900 … A running example
DIM + VALUE SEX+M SEX+F AGE+18 AGE+19 … 2 0
3 1 2 Invert list: row_id SELECT SEX M AGE 18 SALARY 2900 3 How do we store the inverted list table on GPU?
DIM + VALUE Inverted List … … AGE+17 1 AGE+18
2, 3 AGE+19 4 AGE+20 9, 10 AGE+21 11 … … Row ID Count AGG … … … 1 0 0 2 0 0 3 0 0 4 0 0 … … … SELECT AGE 18±1 Step 1: Matching & Aggregation
DIM + VALUE Inverted List … … AGE+17 1 AGE+18
2, 3 AGE+19 4 AGE+20 9, 10 AGE+21 11 … … Row ID Count AGG … … … 1 0 0 2 1 1*0.5 3 1 1*0.5 4 0 0 … … … SELECT AGE 18±1 Step 1: Matching & Aggregation
DIM + VALUE Inverted List … … AGE+17 1 AGE+18
2, 3 AGE+19 4 AGE+20 9, 10 AGE+21 11 … … Row ID Count AGG … … … 1 1 1*0.5 2 1 1*0.5 3 1 1*0.5 4 1 1*0.5 … … … SELECT AGE 18±1 Step 1: Matching & Aggregation
DIM + VALUE Inverted List … … SALARY+2500 NULL SALARY+3000
0, 3 SALARY+3500 1 SALARY+4000 2 SALARY+4500 4,5 … … SELECT SALARY 2900±1000 Row ID Count AGG … … … 1 1 0.5 2 1 0.5 3 1 0.5 4 1 0.5 … … … Step 1: Matching & Aggregation
DIM + VALUE Inverted List … … SALARY+2500 NULL SALARY+3000
0, 3 SALARY+3500 1 SALARY+4000 2 SALARY+4500 4,5 … … Row ID Count AGG … … … 1 1 0.5 2 1 0.5 3 2 1*0.3+0.5 4 1 0.5 … … … SELECT SALARY 2900±1000 Step 1: Matching & Aggregation
Block 1 Block 2 Block 2 SEX AGE SALARY GPU
Parallel Matching
Row ID Count AGG … … … 1 1 0.5
2 1 0.5 3 2 0.8 4 1 0.5 … … … K Selection What is the fast K Selection algorithm? Step 2: K Selection
R_id R_id R_id R_id R_id R_id R_id D+V1 D+V2 D+V3
invert_list_idx invert_list_table end_index First approach to store the inverted list table on GPU GPU
Host Device Map Main Memory ! KEY GPU Memory !
VALUE
dimension + value1 dimension + value2 Invert_list_idx Invert_list_table
None
Mapping C P U ! M E M O R
Y
Mapping C P U ! M E M O R
Y
Mapping C P U ! M E M O R
Y MAP(KEY, INDEX) device_vector
Mapping C P U ! M E M O R
Y raw_pointer get(key) map(key, value) freeze() ratio()
Bucket Top K Selection Algorithm 2 4 1 5 2
1 K = 10 First 7 results Bucket_Num = (Value - MIN) / (MAX - MIN) * Number_Of_Buckets
Bucket Top K Selection Algorithm Accept Multi Queries K =
2 K = 5 K = 6 K = 3
#define NAME “YIWEI GONG” #define UNIVERSITY “NTU” #define EMAIL “
[email protected]
”
#define BLOG “http://ciel.im” #define ME “A stupid programmer” THANK YOU
Block 1 Block 2 Block 3 Block 4 Block 5
Block 6 GPU Thread 1 Thread 2 Thread 3 Thread 4 Thread 5 Thread 6 Block