Repository navigation
Conversation
A table stores an int32 key widened to int64 with its sign, and a
checkpoint or a delta holds that int64 key. key_ownership places each
key by it when a checkpoint is loaded or a delta is replayed. The
bucketize places the int32 key of the KJT. The two agree only if the
bucketize gives an int32 key the rank of the int64 key with the same
value. These tests check that.
- test_hash_roundrobin_kuairand.py
- test_bucketize_kernel_matches_cpu_reference also runs with int32
keys, and also at 3 and 7 ranks.
- test_bucketize_kernel_matches_key_ownership (new) gives the
bucketize the keys next to 0, 2**31, 2**32 and 2**63 and 4096
random keys of the dtype, one key per sample, at 1, 2, 3, 5, 6, 7,
8, 12, 16, 100 and 255 ranks, for int64 and int32 keys and both
rules. Each key's rank has to equal key_ownership.owning_shard's for
the key widened to int64, and the rank from this file's own
reference. Kernel2 has to write each key, unchanged and in its own
dtype, where kernel1 counted it.
- test_bucketize_kernel_continuous_keeps_key_width (new): continuous
reads a key in its own width, and its rewrite of an int32 key stays
an int32.
- The reference reads a key as an unsigned 64-bit number under both
rules, as the rules do. numpy's % on a negative key gives the
remainder of the signed value, which is another number.
- test_embedding_dump_load.py: --key-dtype int32 draws int32 keys,
negative ones included but not -4 to -1, which are the hash table's
reserved keys as int64. --batch-size lets 7 ranks feed equal shares,
and a batch size that is not a multiple of the world size raises.
- test_embedding_dump_load.sh: int32 keys dumped and loaded under
hash_roundrobin at 8 and at 7 ranks, and under roundrobin at 7 ranks.
The loaded model has to hold every key its rank owns and return the
rows the dumped model had.
On this commit, with the bucketize of d0dbc08 (Eos, H100):
- test_hash_roundrobin_kuairand.py: 16 failed, 78 passed. All 16 are
int32 cases: matches_cpu_reference at 3 and 7 ranks, for both
features, and matches_key_ownership under hash_roundrobin at 2, 3, 5,
6, 7, 8, 12, 16, 100 and 255 ranks and under roundrobin at 7 and 100
ranks. Under hash_roundrobin at 8 ranks, for example, 1786 of 4110
int32 keys get another rank from the bucketize than from
key_ownership. Every int64 case and every continuous case passes.
- The int32 dump/load cases: the three dumps pass, and the three loads
fail on every rank with "Key <k> must exist in table of rank <r>".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
What goes wrong: with int32 KJTs, a key that a checkpoint load or a delta replay puts on one rank is looked up on another rank, and nothing raises. After a load the model misses those keys and returns fresh rows for them. Why: a table stores an int32 key widened to int64 with its sign, and a checkpoint or a delta holds that int64 key. key_ownership places each key by it, and that is all a loader has: nothing records that the input is int32. The bucketize reads an int32 key in 32 bits: - roundrobin: rank (uint32)key % W, where key_ownership gives (uint64)key % W. The two differ for a negative key when 2**32 and 2**64 leave different remainders modulo W, as at W = 7 or 100. - hash_roundrobin: the hash of the zero-extended 32-bit key, cut to its low 32 bits, modulo W, where key_ownership hashes the sign-extended key and takes the whole hash modulo W. The two differ for about (W - 1)/W of the negative keys at any W above 1, and for most keys when W is not a power of two. The fix: both bucketize kernels take the rank of a roundrobin or hash_roundrobin key from one helper, cyclic_bucket. It widens the key to 64 bits with its sign and works in 64-bit arithmetic, which is exactly key_ownership's rule. Kernel1 counts the lengths per rank and kernel2 writes the keys, both with this rank. The key written stays the input key, in its own dtype. int64 keys keep their ranks bit for bit. continuous keeps its rule: key_ownership has none for it, and its rewrite of an int32 key stays an int32. The other places that compute a rank from a key agree already: key_ownership.owning_shard and murmur3_fmix64 widen a key with its sign, and the checkpoint load, the admission counter load, replay and the twin module all go through owned_key_mask. The comments and docs that state the rules say how an int32 key is read: DistType in utils.h, key_ownership.py, DynamicEmb_APIs.md and replay_increment_design.md. Evidence, on Eos H100, this commit against the one before it: - test_hash_roundrobin_kuairand.py: 94 passed (before: 16 failed, all int32, and 78 passed). - The int32 dump/load cases of test_embedding_dump_load.sh: 6 of 6 runs pass (before: the 3 loads fail on every rank). - The same before and after: test_twin_module.sh 513 passed; test_sequence_embedding.sh 18 runs and test_pooled_embedding.sh 11 runs, all passing; test_table_row_wise.sh 26 runs, all passing; test_incremental_dump.sh 189 passed. - test_embedding_dump_load.sh, run with the one-GPU invocations eight at a time: all 228 invocations pass (before: 225, the 3 int32 loads fail). The other 222, all with int64 keys, pass on both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryFixes int32 routing under
No actionable issues were found. CUDA tests were not run during this review. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["int32 or int64 input key"] --> B["cyclic_bucket: signed int64, then uint64"]
B --> C["Optional murmur3_fmix64"]
C --> D["Remainder by shard count"]
E["Checkpoint or delta int64 key"] --> F["owning_shard"]
F --> D
D --> G["Same destination rank"]
Reviews (1) · Last reviewed commit: "fix(dynamicemb): bucketize int32 keys by..." · Reviewed by Greptile |
3 tasks done
Collaborator
|
closed as merged in #544 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With int32 KJTs under
roundrobinorhash_roundrobin, a key that a checkpoint load or a delta replay puts on one rank is looked up on another rank. Nothing raises. After a load, the model misses those keys and returns fresh rows for them.A table stores an int32 key widened to int64 with its sign, and a checkpoint or a delta holds that int64 key. Load and replay place each key by it, through
key_ownership. The bucketize reads an int32 key in 32 bits instead. Underhash_roundrobinat W ranks, about (W - 1)/W of the negative keys then go to another rank, and so do about (W - 1)/W of all keys when W is not a power of two. Underroundrobinnegative keys go to another rank at world sizes such as 7 or 100.Fix: both bucketize kernels get the rank of a
roundrobinorhash_roundrobinkey from one helper,cyclic_bucket. It widens the key to 64 bits with its sign and works in 64 bits, which is the rule ofkey_ownership. Keys keep their dtype, int64 keys keep their ranks, andcontinuousdoes not change. The docs and comments that state the rules say how an int32 key is read.Tests (H100, CI image 26.07):
test_hash_roundrobin_kuairand.py: every int32 and int64 key has to get the rank thatkey_ownershipgives (edge and random keys, 1 to 255 ranks, both rules).test_embedding_dump_load.sh: int32 keys, negative ones included, are dumped and loaded underhash_roundrobinat 8 and 7 ranks and underroundrobinat 7 ranks.hash_roundrobinat 8 ranks, 1786 of 4110 int32 keys get another rank. The 3 int32 dumps pass, and the 3 loads fail on every rank withKey <k> must exist in table of rank <r>.test_embedding_dump_load.shpass (225 on main).test_twin_module.sh(513 passed),test_sequence_embedding.sh(18 runs),test_pooled_embedding.sh(11 runs),test_table_row_wise.sh(26 runs) andtest_incremental_dump.sh(189 passed) pass, as on main.Checklist
🤖 Generated with Claude Code