You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] align_to_table_size causes CUDA illegal memory access when num_embeddings is exactly divisible by world_size #328
PR #312 (align_to_table_size) introduces a bug: when num_embeddings is exactly divisible by world_size, num_aligned_embedding_per_rank is not set, causing max_capacity to be unaligned to bucket_capacity. This leads to CUDA illegal memory access during distributed training.
Root Cause
In _validate_configs() (planner.py), the conditional:
With align_to_table_size, when num_embeddings % world_size == 0 (e.g. 50M / 16 = 3,125,000), the aligned value equals the original, so the condition is False and num_aligned_embedding_per_rank stays None.
This causes max_capacity = local_row = 3,125,000, which is not a multiple of bucket_capacity (128). The C++ hash table rounds up to 3,125,120, breaking the invariant _capacity == max_capacity. When expand() is triggered, it allocates value tables with 3,125,000 rows but the hash table can return indices up to 3,125,119 — causing out-of-bounds access.
(The old _next_power_of_2 always produced a value larger than the original, so the condition was always True.)
Suggested Fix
Always set num_aligned_embedding_per_rank (remove the conditional), and ensure it is rounded up to a multiple of bucket_capacity.
In expand(), use self.key_index_map.capacity() instead of target_capacity when allocating value tables and updating self._capacity.
Activity
fix: align DynamicEmb capacity to bucket_capacity instead of DEMB_TAB…
fix: align DynamicEmb capacity to bucket_capacity instead of DEMB_TAB…