Skip to content

Commit

Permalink
return right away if keys is empty (#3658)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3658

X-link: facebookresearch/FBGEMM#734

when reading embedding rows from rocks db, skip reading from a db shard if this db shard doesn't contain any requested rows.

Reviewed By: pradeepfn

Differential Revision: D68913784

fbshipit-source-id: b5949f64ef4b5f60b9ba0df7f3f326a4aee33bd0
  • Loading branch information
Yulu Jia authored and facebook-github-bot committed Feb 5, 2025
1 parent fbcb73e commit 9c9adb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,12 @@ class EmbeddingRocksDB : public kv_db::EmbeddingKVDB {
}
key_indices.push_back(i);
}

// bail if nothing to do
if (key_indices.empty()) {
return;
}

std::sort(
key_indices.begin(),
key_indices.end(),
Expand Down
3 changes: 3 additions & 0 deletions fbgemm_gpu/test/tbe/ssd/kv_tensor_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def test_read_tensor_using_wrapper_from_db(
)
self.assertEqual(tensor_wrapper.shape, [E, D])

# read one row as an extreme case
narrowed = tensor_wrapper.narrow(0, 0, 1)

# table has a total of E rows
# load 1000 rows at a time
step = 1000
Expand Down

0 comments on commit 9c9adb9

Please sign in to comment.