Fix gather/scatter fast division bug - #3059
Conversation
tarang-jain
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the fix.
|
Actually, can we add a test for this diff? We could either add a test for FastIntDiv directly, or we can test the |
| inplace_inputs_i64); | ||
| GATHER_TEST((GatherTest<false, false, true, float, int64_t, int64_t>), | ||
| GatherInplaceTestCI64I64, | ||
| inplace_inputs_i64_i32_max); // slow test, 8GB allocation, reproduces https://github.com/rapidsai/raft/issues/3055 |
There was a problem hiding this comment.
@tfeher @tarang-jain Only float type is possible here (8GB allocation, 100ms). I would suggest to not have it. I already added a regression test for the fix in fast_int_div.cu
There was a problem hiding this comment.
I think it is fine to spend 100ms on this.
tfeher
left a comment
There was a problem hiding this comment.
Thanks Huy for the fix, LGTM!
| inplace_inputs_i64); | ||
| GATHER_TEST((GatherTest<false, false, true, float, int64_t, int64_t>), | ||
| GatherInplaceTestCI64I64, | ||
| inplace_inputs_i64_i32_max); // slow test, 8GB allocation, reproduces https://github.com/rapidsai/raft/issues/3055 |
There was a problem hiding this comment.
I think it is fine to spend 100ms on this.
|
/ok to test 9acb86f |
|
/ok to test 33ec5d7 |
|
/ok to test b18e428 |
|
/ok to test dc2ede3 |
- gather/scatter crashes at int32 boundary even when it advertises int64 type. This change fixes this issue. - int64 is still not supported for performance reason with int128.
|
/ok to test 9f3d2cb |
|
/ok to test d87dcdd |
|
/merge |
1 similar comment
|
/merge |
|
/merge |
1 similar comment
|
/merge |
|
Hello @huuanhhuyn, going forward let's remember to build cuvs and build cuml at the least to ensure that raft doesn't cause any breakages. This PR is causing some breakages currently. |
Add explicit template parameters for FastIntDiv, follow up to NVIDIA/raft#3059. Authors: - Anupam (https://github.com/aamijar) Approvers: - Jim Crist-Harif (https://github.com/jcrist) URL: #8299
…around) The shuffle_dataset path used an out-of-place gather into a temporary buffer to work around an illegal memory access in raft's in-place gather overload when n_rows * row_len exceeded 2^31 (32-bit index overflow). That bug is now fixed upstream in raft (NVIDIA/raft#3059, closes #3055), which the cuvs raft pin now includes. Revert to the in-place gather to drop the extra full-size temporary allocation and copy.
#3093) This PR allows FastIntDiv to support the full 64-bit range values. Within the 32-bit range values, the fast implementation is selected. When exceeds 32-bit, it fallbacks during runtime to the normal division. The overhead of runtime check is measured to be negligible. FastIntDiv is used by in-place gather() where number of columns (divisor) is set once and the / and % divisions are called a lot more frequent to obtain row and col numbers from the given flat index. Therefore, the benchmark compares the fast int division against the normal division at 100 divisors and 1 million numerators for 32-bit and 64-bit range. ``` ---------------------------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------------------------- fast_int_div_i32/FastIntDiv/int32/manual_time 0.138 ms 0.893 ms 5086 native_div_i32/NativeIntDiv/int32/manual_time 0.186 ms 0.941 ms 3755 fast_int_div_i64/FastIntDiv/int64/manual_time 0.762 ms 1.52 ms 921 native_div_i64/NativeIntDiv/int64/manual_time 0.742 ms 1.50 ms 948 ``` @mfoerste4 Original version without the current changes and [this PR](#3059) -> Only negligible runtime overhead (~4%) is added. ``` ---------------------------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------------------------- fast_int_div_i32/FastIntDiv/int32/manual_time 0.131 ms 0.223 ms 5371 native_div_i32/NativeIntDiv/int32/manual_time 0.180 ms 0.273 ms 3884 ``` The [gather() bench](https://github.com/huuanhhuyn/raft/blob/fc9681c1821fc4a1559b8970a8e814f17569f84a/cpp/bench/prims/matrix/gather.cu) gives a similar comparison. The added runtime check is only a negligible overhead Authors: - https://github.com/huuanhhuyn Approvers: - Malte Förster (https://github.com/mfoerste4) - Divye Gala (https://github.com/divyegala) URL: #3093
raft::matrix::gather/scatter crashes at int32 boundary even when it advertises int64 type -> issue 3055. This PR fixes this issue.
int64 is still not supported for performance reason with int128.
closes #3055