-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow changing the reserved keys #191
Conversation
aafcbd2
to
1789f38
Compare
Documentation previewhttps://nvidia-merlin.github.io/HierarchicalKV/review/pr-191 |
include/merlin/types.cuh
Outdated
__constant__ uint64_t LOCKED_KEY = UINT64_C(0xFFFFFFFFFFFFFFFD); | ||
template <class K> | ||
__forceinline__ __device__ bool IS_RESERVED_KEY(K key) { | ||
return key == EMPTY_KEY || key == RECLAIM_KEY || key == LOCKED_KEY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the performance(IS_RESERVED_KEY will be called anytime on each threads), it would be better to use &
operator, so we can use one reserved mask to indicate the reserved keys space like RESERVED_KEY_MASK = UINT64_C(0xFFFFFFFFFFFFFFFC);
, by default, it should be 0x3, if we wanna reserve 0xFFFFFFFFFFFFFFxF(x = E, C, D), we can let the user give a mask valued 0x30.
a1b3116
to
1fc4abb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
63f502e
to
c950300
Compare
27f39f7
to
767c84f
Compare
include/merlin/types.cuh
Outdated
uint64_t lockedKey = emptyKey & ~(UINT64_C(2) << index); | ||
EMPTY_KEY_CPU = emptyKey; | ||
|
||
printf("reserved keys are emptyKey, reclaimKey, lockedKey and reservedKeyMask2\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include/merlin/types.cuh
Outdated
printf("lockedKey: %lx, reservedKeyMask1: %lx\n", lockedKey, reservedKeyMask1); | ||
printf("reservedKeyMask2: %lx, vacantKeyMask1: %lx\n", reservedKeyMask2, vacantKeyMask1); | ||
|
||
cudaMemcpyToSymbol(EMPTY_KEY, &emptyKey, sizeof(uint64_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CUDA_CHECK
include/merlin_hashtable.cuh
Outdated
@@ -98,6 +98,7 @@ struct HashTableOptions { | |||
int device_id = -1; ///< The ID of device. | |||
bool io_by_cpu = false; ///< The flag indicating if the CPU handles IO. | |||
bool use_constant_memory = false; ///< reserved | |||
int reserved_key_index = 0; ///< The binary index of reserved key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more detail comment which allows user know the configuration effect exactly. For example: index=0
means which keys will be reserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
tests/merlin_hashtable_test.cc.cu
Outdated
@@ -3437,6 +3440,12 @@ void test_bucket_size(bool load_scores = true) { | |||
CudaCheckError(); | |||
} | |||
|
|||
|
|||
TEST(MerlinHashTableTest, test_basic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change the position?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change back
tests/merlin_hashtable_test.cc.cu
Outdated
@@ -145,6 +145,8 @@ void test_basic(size_t max_hbm_for_vectors) { | |||
options.dim = DIM; | |||
options.max_bucket_size = BUCKET_MAX_SIZE; | |||
options.max_hbm_for_vectors = nv::merlin::GB(max_hbm_for_vectors); | |||
options.reserved_key_index = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases like this for the other API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
README.md
Outdated
- The keys of `0xFFFFFFFFFFFFFFFC`, `0xFFFFFFFFFFFFFFFD`, `0xFFFFFFFFFFFFFFFE`, and `0xFFFFFFFFFFFFFFFF` are reserved for internal using. | ||
|
||
- The keys of `0xFFFFFFFFFFFFFFFD`, `0xFFFFFFFFFFFFFFFE`, and `0xFFFFFFFFFFFFFFFF` are reserved for internal using. | ||
- Call set options.reserved_key_index to change the reserved keys if the default one conflicted with your keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 'reserved_key_start_index' would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
9367c46
to
7733b72
Compare
/blossom-ci |
@@ -865,6 +876,7 @@ class HashTable : public HashTableBase<K, V, S> { | |||
return; | |||
} | |||
options_ = options; | |||
CUDA_CHECK(init_reserved_keys(options.reserved_key_start_bit)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls use MERLIN_CHECK
to check if the value falls in [0, 61]
include/merlin_hashtable.cuh
Outdated
* reserved_key_start_bit = 0, is the default behavior, HKV reserves `0xFFFFFFFFFFFFFFFD`, | ||
* `0xFFFFFFFFFFFFFFFE`, and `0xFFFFFFFFFFFFFFFF` for internal using. | ||
* if the default one conflicted with your keys, change the reserved_key_start_bit | ||
* value to a numbers between 1 and 61, reserved_key_start_bit = 1 means using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the 62 not valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
62 meaning using 62 and 63, then it is no longer neg number, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
62 should be valid.
d9b9047
to
7e7d0af
Compare
/blossom-ci |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Allow changing the reserved keys in the confliction, call
init_reserved_keys
to change it