-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
SparseLinear_v2
, fixing indexing issues (#754)
* Introduce `SparseLinear_v2` to fix indexing issues `SparseLinear` does not correctly index the gradient/weight matrix (#752). This change fixes the indexing, so that the full matrix is used. To retain compatibility with existing models that use `SparseLinear`, which works relatively well if there are not too many hash collisions, the fixed version is renamed to `SparseLinear_v2`. Thanks to @sriram7797 for reporting this issue! * SparseLinear_v2: fix issue mapping murmur hashes to array The output of MurMur hashes were mapped to array indices as follows: ``` idx = hash & (nr_weight-1) ``` This works well when `nr_weight` is a power of two. For instance, if we have 16 buckets: ``` idx = hash & 15 idx = hash & 0b1111 ``` However, when the user uses a bucket count that is not a power of two, this breaks down. For instance, if we have 15 buckets: ``` idx = hash & 14 idx = hash & 0b1110 ``` This would mask out all odd indices. We fix this by using the modulus instead. To preserve compatibility with existing models, this change is only added to `SparseLinear_v2`. * Rename `invalid_indexing` to `v1_indexing` * Add comment about v1 indexing * Fix incorrect merge fix * Add the `new` tag to the docs * Check that the corrected hash function has the expected distribution * Symbol export fixes
- Loading branch information
Showing
6 changed files
with
127 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters