Skip to content

Commit c5859f0

Browse files
Siqiao Chenfacebook-github-bot
Siqiao Chen
authored andcommitted
benchmark for DramKV
Summary: X-link: facebookresearch/FBGEMM#1316 read/write benchmark test for dramKV Reviewed By: emlin Differential Revision: D75724567
1 parent 605ad59 commit c5859f0

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

fbgemm_gpu/bench/tbe/tbe_ssd_benchmark.py

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def benchmark_ssd_function(
7676
total_time_write_ns = 0
7777

7878
for i in range(iters):
79+
time.sleep(1)
7980
start = (i + warmup_iters) * indices_per_itr
8081
end = start + indices_per_itr
8182
indices_this_itr = indices[start:end]
@@ -105,32 +106,49 @@ def benchmark_read_write(
105106
num_shards: int,
106107
num_threads: int,
107108
block_cache_size_mb: int,
109+
use_dram_kv: bool,
108110
) -> None:
109111
idx_dtype = torch.int64
110112
data_dtype = torch.float32
111113
np.random.seed(42)
112114
torch.random.manual_seed(43)
113115
elem_size = 4
114116

117+
ssd_uniform_init_lower = -0.01
118+
ssd_uniform_init_upper = 0.01
119+
row_storage_bitwidth = 32
120+
115121
with tempfile.TemporaryDirectory(prefix=ssd_prefix) as ssd_directory:
116-
ssd_db = torch.classes.fbgemm.EmbeddingRocksDBWrapper(
117-
ssd_directory,
118-
num_shards,
119-
num_threads,
120-
0, # ssd_memtable_flush_period,
121-
0, # ssd_memtable_flush_offset,
122-
4, # ssd_l0_files_per_compact,
123-
embedding_dim,
124-
0, # ssd_rate_limit_mbps,
125-
1, # ssd_size_ratio,
126-
8, # ssd_compaction_trigger,
127-
536870912, # 512MB ssd_write_buffer_size,
128-
8, # ssd_max_write_buffer_num,
129-
-0.01, # ssd_uniform_init_lower
130-
0.01, # ssd_uniform_init_upper
131-
32, # row_storage_bitwidth
132-
block_cache_size_mb * (2**20), # block cache size
133-
)
122+
if use_dram_kv:
123+
logging.info("Using DRAM KV")
124+
ssd_db = torch.classes.fbgemm.DramKVEmbeddingCacheWrapper(
125+
embedding_dim,
126+
ssd_uniform_init_lower,
127+
ssd_uniform_init_upper,
128+
num_shards,
129+
num_threads,
130+
row_storage_bitwidth,
131+
)
132+
else:
133+
logging.info("Using SSD")
134+
ssd_db = torch.classes.fbgemm.EmbeddingRocksDBWrapper(
135+
ssd_directory,
136+
num_shards,
137+
num_threads,
138+
0, # ssd_memtable_flush_period,
139+
0, # ssd_memtable_flush_offset,
140+
4, # ssd_l0_files_per_compact,
141+
embedding_dim,
142+
0, # ssd_rate_limit_mbps,
143+
1, # ssd_size_ratio,
144+
8, # ssd_compaction_trigger,
145+
536870912, # 512MB ssd_write_buffer_size,
146+
8, # ssd_max_write_buffer_num,
147+
ssd_uniform_init_lower,
148+
ssd_uniform_init_upper,
149+
row_storage_bitwidth,
150+
block_cache_size_mb * (2**20), # block cache size
151+
)
134152

135153
total_indices = (warmup_iters + iters) * batch_size * bag_size
136154
indices_per_itr = batch_size * bag_size
@@ -174,6 +192,7 @@ def benchmark_read_write(
174192
@click.option("--num-shards", default=8)
175193
@click.option("--num-threads", default=8)
176194
@click.option("--block-cache-size-mb", default=0)
195+
@click.option("--use-dram-kv", default=False)
177196
def ssd_read_write(
178197
ssd_prefix: str,
179198
num_embeddings: int,
@@ -185,6 +204,7 @@ def ssd_read_write(
185204
num_shards: int,
186205
num_threads: int,
187206
block_cache_size_mb: int,
207+
use_dram_kv: bool,
188208
) -> None:
189209
benchmark_read_write(
190210
ssd_prefix,
@@ -197,6 +217,7 @@ def ssd_read_write(
197217
num_shards,
198218
num_threads,
199219
block_cache_size_mb,
220+
use_dram_kv,
200221
)
201222

202223

0 commit comments

Comments
 (0)