Repository navigation
fix(dynamicemb): keep each table's local_hbm_for_values budget in fused groups - #534
Conversation
The fused-module HBM split used one ratio, sum(local_hbm_for_values) / sum(value bytes), applied to every table of the group, so a planner allocation of 10%/90% became 50%/50% after fusion. When a fused group does not fit its summed budget, each table now keeps min(1, its own budget / its own bytes) of its rows in HBM, in both the caching and the hybrid layout. The layout decision itself is unchanged and still taken for the group on the sums: a group whose rows fit the summed budget is HBM-only, so table fusion is preserved. create_table_state placed the whole group's value buffers on the host whenever options[0] had no budget; it now takes the host only when every table's budget is zero, so a table with a budget is not moved to host memory by an unrelated groupmate. get_group_value_bytes_by_tier, the planner's mirror of that runtime, now reports sum(min(bytes_i, budget_i)) as HBM when the group does not fit. Charging the summed budget under-stated the host tier by whatever one table could not spend on its own rows -- the unsafe direction for plan approval. A table whose budget exceeds its size no longer lends the spare to groupmates in a splitting group; a table left at the default budget of 0 keeps the one-bucket floor. Co-Authored-By: Claude Code <[email protected]>
[Medium impact] The changes affect DynamicEmb memory allocation and planning for workloads that use fused tables. Fix the per-table cache overflow path and the outstanding minimum-bucket estimate before merging. FindingsSummaryKeeps each fused table's own HBM share when the group does not fit entirely in HBM.
Reviews (3) · Last reviewed commit: "Merge branch 'main' into fix/per-table-h..." · Reviewed by Greptile |
… (PR NVIDIA#534) b9ca916 unintentionally carried the runtime half of the per-table HBM budget change: those edits were sitting uncommitted in this tree while the hash_bucket review findings were being addressed, and a commit takes whole files. The change is unrelated to hash_bucket and is under review as NVIDIA#534, which also carries the planner-side mirror it needs to stay consistent. This restores _create_cache_storage's shared cap_scale split, create_table_state's options[0] host placement, and the DynamicEmb_APIs.md row, exactly as they were before b9ca916. Co-Authored-By: Claude Code <[email protected]>
jiashuy
left a comment
There was a problem hiding this comment.
If the configuration is set inappropriately—specifically, where caching=True but global_hbm_for_values=0—the resulting cache will contain only a single bucket. Even with an overflow buffer, such a cache is highly susceptible to overflow, which causes errors in the current implementation. Given this, should we add a check to automatically set caching to false whenever the HBM budget is 0 (the default value)?
A zero-budget table fused with a positive-budget one got a one-bucket cache: 1024 resident rows and a finite overflow of 3072, which a batch with more unique keys than that cannot enter -- while _prefetch_cache_path assumes every admitted key can. Take caching off such a table when its resolved HBM value budget is zero, with a warning, before anything reads the field: the planner does it in _prepare_dynemb_table_options, so grouping and the cost model see the layout the table will really get, and direct construction does it before the grouped-key check. A positive local_hbm_for_values keeps caching however global_hbm_for_values is set, which direct construction never reads. A group of zero-budget tables now takes the existing non-caching host/PS paths instead of being refused as "Can't use caching mode", and a group left mixed by the normalization is refused by name, since one fused module cannot hold both layouts. test_alignment drops its "caching with zero global HBM is invalid" skip: those 240 combinations now run and pass as host-only modules. Co-Authored-By: Claude Code <[email protected]>
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Merge main up to d03198c (NVIDIA#536, NVIDIA#534, NVIDIA#529, NVIDIA#527, NVIDIA#526). - NVIDIA#527 sends empty weights for an empty input under index dedup, the change this branch made in shard/embedding.py: the merge keeps main's docstring and comments and this branch's needs_counters, the same condition. - NVIDIA#529 adds PrefetchState.key_map_generation and _slots_after_rehash, and looks a prefetched batch's slots up again in its backward when a later prefetch rehashed the table. Git put _slots_after_rehash between PrefetchState's fields and this branch's record_stream, which then fell out of the class without a conflict; the merge puts it back. The lookup's row map (out_rows, grad_rows) only says where rows go, and the forward's load_from_flat_by reads value rows, which a storage keeps through a rehash. - NVIDIA#534 (each table's HBM budget in fused groups), NVIDIA#536 (erase_by_score for lru_lfu tables, per named table) and NVIDIA#526 (VMMTensor frees after the queued work) merge without conflicts. Every file of test/unit_test.sh passes on one node, each group's .sh files with its DYNAMICEMB_TEST_GROUP, and so does the HSTU end-to-end test on one node and on 2. On 2 nodes test_hier_dist.py (122), test_hier_overflow.py (79) and test_hier_pipeline.py (45) pass, and on 4 nodes test_hier_dist.py (122). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The fused-module HBM split used one ratio —
sum(local_hbm_for_values) / sum(value bytes)— applied to every table of the group, so a planner allocation of 10% / 90% became 50% / 50% after fusion._create_cache_storage: when a fused group does not fit its summed budget, each table now keepsmin(1, its own budget / its own bytes)of its rows in HBM, in both the caching and the hybrid layout. The layout decision itself is unchanged and still taken for the group on the sums — a group whose rows fit the summed budget is still HBM-only — so table fusion is preserved.create_table_stateplaced the whole group's value buffers on the host wheneveroptions[0].local_hbm_for_values == 0; it now does so only when every table's budget is zero, so a table with a budget is not moved to host memory by an unrelated groupmate.get_group_value_bytes_by_tier(the planner's mirror of that runtime) now reportssum(min(bytes_i, budget_i))as HBM when the group does not fit, instead of the summed budget. Charging the summed budget understated the host tier by whatever budget one table could not spend on its own rows — the unsafe direction for plan approval.Behavior change
A table whose budget exceeds its size no longer lends the spare to groupmates once the group does not fit; a table left at the default budget of 0 keeps the one-bucket floor. A group that does fit its summed budget is unaffected (still HBM-only), which is the case where covering a groupmate still happens.
Tests
test/unit_tests/test_per_table_hbm_budget.py(registered intest/unit_test.sh): per-table shares in CACHING and HYBRID, the zero-budget groupmate, and the group-level HBM-only fit. Every case fails on the previous code (both tables get the same 26624-row share instead of 4096 / 49152, and HBM rows land in host buffers).test_planner_plan_cost.py: the lending tests moved to the fits-its-budget case; new tests pin the 10% / 90% split and the no-lending-when-it-does-not-fit case.test_per_table_hbm_budget.py+test_planner_plan_cost.py+test_planner_placement.py: 89 passedtest_no_eviction_row_indexing.py+test_expansion_value_capacity.py: 35 passedtest_batched_dynamic_embedding_tables_v2.py: 390 passed, 4 skippedtest_hybrid_storage_export.sh: 17 passedtest_alignment.pyat world sizes 1 and 4: 1200 passed, 240 skipped eachtest_table_row_wise.sh: all 11 configurations (2- and 4-GPU)Note: the runtime hunks here are identical to ones that also landed on
feat/global-bucket-layout(b9ca916) while this change was being prepared; whichever merges first, the other reconciles without conflict.🤖 Generated with Claude Code