Commit 86cbee1
fix(dynamicemb): traverse nn.Module children in check_emb_collection_modules (#355)
* fix(dynamicemb): traverse nn.Module children in check_emb_collection_modules
The function only checked direct attributes, missing EmbeddingCollection
wrapped inside DistributedModelParallel or other nn.Module containers.
Now recursively walks module.children() to find the embedding submodule.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test(dynamicemb): verify get_dynamic_emb_module traverses DMP wrappers
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(examples): drop dynamicemb_utils, use get_dynamic_emb_module
check_emb_collection_modules now traverses nn.Module.children() and
guards against cycles, so the examples-side duplicate
find_dynamicemb_modules is redundant. Route both call sites (cache stats
hook + FILL_DYNAMICEMB_TABLES fill path) through dynamicemb's public
get_dynamic_emb_module and delete commons/utils/dynamicemb_utils.py.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(dynamicemb/test): rewrite check_counter_table_checkpoint for fused MultiTableKVCounter
After the admission-counter fusion refactor (#343), `_admission_counter`
became a single MultiTableKVCounter (or None) instead of a list of
per-table KVCounters. The verification helper still iterated it as a
list, so the dump/load counter check was silently no-op on any branch
whose `get_dynamic_emb_module` could traverse into DMP wrappers and
raised `TypeError: 'MultiTableKVCounter' object is not iterable` on any
branch that could. PR #355's `children()` traversal surfaced the latter.
Rewrite the check against the current API:
- Iterate logical tables via `range(len(table._table_names))`.
- Export one table_id's (keys, frequency) with
`cnt.table_._batched_export_keys_scores([freq_name], device, table_id)`.
- Look those keys up in the peer counter via
`cnt_y.table_.lookup(keys, table_ids, score_arg)` and assert both
`founds.all()` and that the returned score_out matches the exported
frequency.
- Handle the None (no-admission) case symmetrically.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 3db734f commit 86cbee1
5 files changed
Lines changed: 113 additions & 97 deletions
File tree
- corelib/dynamicemb
- dynamicemb
- test/unit_tests
- examples
- commons/utils
- hstu/training
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
54 | 66 | | |
55 | 67 | | |
56 | | - | |
| 68 | + | |
57 | 69 | | |
58 | 70 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
78 | 89 | | |
79 | 90 | | |
80 | 91 | | |
| |||
Lines changed: 77 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
125 | 174 | | |
126 | 175 | | |
127 | 176 | | |
| |||
354 | 403 | | |
355 | 404 | | |
356 | 405 | | |
357 | | - | |
| 406 | + | |
358 | 407 | | |
359 | 408 | | |
| 409 | + | |
360 | 410 | | |
361 | 411 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
369 | 423 | | |
370 | 424 | | |
371 | 425 | | |
372 | | - | |
373 | 426 | | |
374 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
375 | 431 | | |
376 | 432 | | |
377 | 433 | | |
378 | 434 | | |
379 | 435 | | |
380 | | - | |
381 | | - | |
382 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
383 | 446 | | |
384 | 447 | | |
385 | 448 | | |
| |||
441 | 504 | | |
442 | 505 | | |
443 | 506 | | |
| 507 | + | |
| 508 | + | |
444 | 509 | | |
445 | 510 | | |
446 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
0 commit comments