Skip to content

[FIX](DynamicEmb): Plan per EmbeddingCollection; Identify a table by its collection and its name - #504

Merged
shijieliu merged 9 commits into
NVIDIA:mainfrom
jiashuy:feat/dynamicemb-table-key
Oct 21, 2026
Merged

shijieliu merged 9 commits into
NVIDIA:mainfrom
jiashuy:feat/dynamicemb-table-key

Conversation

@jiashuy

@jiashuy jiashuy commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fix the issue:

Collections share imaginary memory

per_rank_storage pools budgets across separate embedding collections because fusion_key has no collection identity. Those collections build separate runtimes and cannot share spare HBM.

For example, two collections with per-rank value sizes of 4 GiB and 16 GiB, and budgets of 20 GiB and 2 GiB, are counted as needing no host memory. The second runtime actually needs about 14 GiB of host memory, so the planner can approve a model that does not fit.

This issue will become tricky as the number of collections increases.

Details

fusion_key decides which tables are costed as one TBE, and it carried nothing that said which collection a table came out of. TorchRec shards each shardable module on its own -- one ShardedEmbedding*Collection apiece, each with its own EmbeddingShardings -- so tables from two collections never reach the same group_tables call, and the runtimes they build cannot lend each other HBM. The planner pooled their budgets anyway.

That is the unsafe half of a coarse key. Merging tables the runtime keeps apart moves min(sum total, sum budget) up, which over-states HBM and so only refuses layouts that would have fit -- but the host tier is total - hbm and total does not move, so it is under-stated by exactly as much, and that direction approves a model the machine will not hold. Two collections with per-rank sizes of 4 GiB and 16 GiB and budgets of 20 GB and 2 GB were costed as one 22 GB budget over 20 GiB of rows: no host memory at all, where the truth is 6 GiB of HBM and 14 GiB of host.

The information existed and was being thrown away. _table_configs walks the model to find the tables, so it is the one place that knows which module each came out of, and it flattened that into a bare list of configs. It now pairs each config with the path to its collection. The path rather than id(): every rank runs that walk alone and has to reach the same grouping, and object addresses do not agree across processes.

Having that path, the planner stops keying tables by name. A table is now a TableKey(collection, name), which is how TorchRec identifies one -- it names a sharding option path + "." + name and keys a ShardingPlan by plan[path][name] -- and every per-table record follows: _dyn_emb_plan, _dyn_emb_options, _table_poolings, optimizer_types, per_rank_storage, TableToPlace, and the set module_without_tables prunes by. Two collections declaring one name are two entries throughout: charged separately, placed separately, grouped apart, filed under their own paths, and handed their own options.

That is what lets them hold their own options, which is what the planner could not do before and why it refused the model instead. DynamicEmbTableOptions is both the caller's policy and the runtime's per-table config, and _prepare_dynemb_table_options writes the geometry into it -- dim from embedding_dim, max_capacity from num_embeddings through the bucket layout, embedding_dtype from data_type -- so one object cannot describe two tables, and the function is not idempotent besides: it reads back bucket_capacity, max_capacity and init_capacity after writing them. Reached by name, both occurrences got the same object. TorchRec does not have the problem because ParameterConstraints is policy-only and each occurrence's geometry comes from its own tensor=param.

So constraints gains a second key form, and get_constraint_key is how a caller writes one:

constraints = {
    get_constraint_key(shared_a, model): ...,   # sparse.ebc_a.shared
    get_constraint_key(shared_b, model): ...,   # sparse.ebc_b.shared
}

It takes the config object rather than a name, because by name there is nothing to tell the two apart -- and a collection returns the config objects it was built from, so identity matches what the caller is holding. module is the root the path is relative to, so passing a collection itself returns the bare name and a caller with one collection needs no special case. The answer is a function of the arguments alone, never of whether some unrelated collection happens to share a name; a key that moved for that reason would be a key written down elsewhere and now silently wrong.

resolve_constraints is the other half. Each occurrence asks for its keys in turn -- qualified, then bare -- and takes the first constraints has. That order is the whole of the addressing rule: a bare name still reaches a table nothing more specific names, so a model whose table names are unique needs no change at all, and a qualified key overrides it for one collection. It refuses three things, all of them constraints that would otherwise be silently unused: a key no occurrence answers to; a qualified key on a table TorchRec plans, since its planner looks constraints up by name alone and would never find it; and one DynamicEmbTableOptions object reached by two occurrences, which is what a bare name does when two collections declare it, and whose message names get_constraint_key.

That last check also closes an older hole. Two differently-named tables sharing one constraint object -- {"a": c, "b": c} -- hit the same non-idempotent write and were silently mis-sized; they are now refused for the same stated reason.

Having two places that needed the path made it worth having one that finds it. The descent a sharder-claimed module ends -- the enumerator's own rule -- was written out three times: in _table_configs, in _insert_dynamicemb_plan, and in optimizer_types, which wants the sharder and threw the path away. The first two have to agree about the paths they produce and nothing made them, each building its own f"{path}.{name}" if path else name; a plan filed under a path DistributedModelParallel does not look for is not an error there, since it shards the modules its plan names and leaves the rest alone, so a drift would have surfaced as a collection that silently stayed unsharded. They now share sharded_modules, which yields each claimed module with its path and its sharder. module_without_tables keeps its own recursion: it rebuilds the tree from the bottom up rather than reading it.

Keying its prune set by TableKey fixes a bug of its own. It pruned by name, so a name DynamicEmb planned in one collection was taken out of every collection -- leaving TorchRec a table it was told to plan and could no longer see.

per_rank_storage's docstring claimed coarseness was safe in both directions. fusion_key's already said otherwise; this makes them agree.

get_planner is unchanged and still keys by name: its eb_configs is a flat list with no module to take a path from, so it cannot express a qualified key. A model that needs one builds its constraints and the planner directly; a comment there says so.

BREAKING CHANGE: TableToPlace.name is now key, a TableKey, and NodePlacer.place returns Dict[TableKey, int]. A custom NodePlacer must follow. per_rank_storage, optimizer_types and module_without_tables are likewise keyed by TableKey rather than by table name. fusion_key takes the owning collection as a trailing argument; new parameters go after it, since the existing ones are passed positionally. Two tables sharing one DynamicEmbTableOptions object is now an error rather than a silent mis-sizing.

Tested on EOS (8xH100, torch 2.13.0a0+nv26.07 / torchrec 1.8.0): test_planner_placement.py and test_planner_plan_cost.py 91 passed, up from 60 -- the collection as a parametrization of
test_tables_that_do_not_fuse_do_not_pool_their_budgets, the walk's module paths, the reservation no longer pooling across a collection boundary, get_constraint_key in each of its forms and both its refusals, resolve_constraints's precedence and its three, two occurrences of a name holding their own options and differing in shape, each being filed under its own collection, only the planned one being taken away from TorchRec, and the shared descent -- including that the path a table's collection is recorded as is the path its ParameterSharding is filed under.

The end-to-end scripts pass on the same node against this tree: test_table_row_wise, test_twin_module, test_pooled_embedding and test_sequence_embedding.

Description

Until now the dynamicemb planner addressed every table by its bare name. That works only as long as no two tables in a model share one. When they do — two EmbeddingBagCollections each holding a table called shared, say — both occurrences resolve to the same ParameterConstraints, and therefore to the same DynamicEmbTableOptions object. That object is not policy-only: _prepare_dynemb_table_options writes per-table geometry into it, and does so non-idempotently, so the second occurrence silently overwrites the first's dimensions and the model is planned against numbers belonging to a different table. The same bare key also pooled the two tables into one fused TBE and one HBM budget, and broke placement ties between tables the planner could not tell apart.

This PR makes a table's identity TableKey(collection, name) — the module path plus the name, the same pair TorchRec itself uses to address a plan (plan[path][name], ShardingOption.fqn). Constraints are looked up per occurrence: collection.name first, then bare name, so a qualified key wins where one is given and a model whose table names are already unique needs no change whatsoever. get_constraint_key(config, model) builds the qualified key for callers who need one. Fusion grouping and tie-breaking now carry the collection too, so two tables that merely share a name are no longer costed, budgeted, or ordered as if they were one.

TorchRec cannot express this itself — its enumerator looks constraints up by bare name and never consults the path — which is harmless upstream, where constraints are pure policy, and is exactly what makes it unsafe here.

Two defects found while doing the above are fixed in the same PR, since both make the planner disagree with the runtime it is planning for:

  • get_planner now refuses a table name it cannot honour. Its three name arguments are keyed by the bare name, because it takes a flat eb_configs with no module to derive a path from. A qualified key matched none of them and the table quietly fell back to ROW_WISE instead of the TABLE_ROW_WISE that was asked for. It now raises and says why.
  • A group that fits in HBM is costed as HBM-only. The planner read caching before checking whether the rows fit; the runtime checks the fit first and only then looks at caching/external_storage. A 4 GiB group with a 20 GiB budget was charged 20 GiB of HBM plus 4 GiB of host memory rather than 4 GiB and nothing — enough to reject models that place perfectly well.

Alongside, the planner tests were cut from 61 to 51 by dropping assertions on internal return shapes and on claims a neighbouring test already made, and the remaining ones were rewritten to drive the real planner and to state their setup at the call site. The API doc gained a section on naming a table in constraints and lost a stale claim that names are unique; the README no longer lists table-row-wise as future work; six claims in the design note were corrected against the code.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@jiashuy jiashuy changed the title fix(dynamicemb): identify a table by its collection and its name [FIX](DynamicEmb): Plan per EmbeddingCollection; Identify a table by its collection and its name Oct 20, 2026
@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

The PR identifies each table by its collection and name, keeping separate collections from sharing memory budgets in the planner.

  • Tables with the same name can now be planned separately in each collection.
  • Memory estimates keep collection budgets apart and check HBM fit before caching costs.

No new actionable issues were found. Verification was by code inspection; no tests were run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Model collections and table configs] --> B[TableKey: collection and name]
  B --> C[Resolve each table's constraint]
  C --> D[Place and cost tables within each collection]
  D --> E[Remove planned tables from TorchRec's input]
  E --> F[Plan remaining tables with leftover memory]
  F --> G[Combine plans under collection paths]
Loading

Reviews (4) · Last reviewed commit: "fix(dynamicemb): cost a caching group th..." · Reviewed by Greptile

@jiashuy

jiashuy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Fix the issue:

Collections share imaginary memory

per_rank_storage pools budgets across separate embedding collections because fusion_key has no collection identity. Those collections build separate runtimes and cannot share spare HBM.

For example, two collections with per-rank value sizes of 4 GiB and 16 GiB, and budgets of 20 GiB and 2 GiB, are counted as needing no host memory. The second runtime actually needs about 14 GiB of host memory, so the planner can approve a model that does not fit.

This issue will become tricky as the number of collections increases.

@jiashuy
jiashuy force-pushed the feat/dynamicemb-table-key branch 2 times, most recently from 8c5424b to d7fe796 Compare October 21, 2026 03:16
jiashuy and others added 8 commits October 21, 2026 08:48
`fusion_key` decides which tables are costed as one TBE, and it carried
nothing that said which collection a table came out of. TorchRec shards
each shardable module on its own -- one `ShardedEmbedding*Collection`
apiece, each with its own `EmbeddingSharding`s -- so tables from two
collections never reach the same `group_tables` call, and the runtimes
they build cannot lend each other HBM. The planner pooled their budgets
anyway.

That is the unsafe half of a coarse key. Merging tables the runtime keeps
apart moves `min(sum total, sum budget)` up, which over-states HBM and so
only refuses layouts that would have fit -- but the host tier is
`total - hbm` and `total` does not move, so it is under-stated by exactly
as much, and that direction approves a model the machine will not hold.
Two collections with per-rank sizes of 4 GiB and 16 GiB and budgets of
20 GB and 2 GB were costed as one 22 GB budget over 20 GiB of rows: no
host memory at all, where the truth is 6 GiB of HBM and 14 GiB of host.

The information existed and was being thrown away. `_table_configs` walks
the model to find the tables, so it is the one place that knows which
module each came out of, and it flattened that into a bare list of
configs. It now pairs each config with the path to its collection. The
path rather than `id()`: every rank runs that walk alone and has to reach
the same grouping, and object addresses do not agree across processes.

Having that path, the planner stops keying tables by name. A table is now
a `TableKey(collection, name)`, which is how TorchRec identifies one --
it names a sharding option `path + "." + name` and keys a `ShardingPlan`
by `plan[path][name]` -- and every per-table record follows:
`_dyn_emb_plan`, `_dyn_emb_options`, `_table_poolings`, `optimizer_types`,
`per_rank_storage`, `TableToPlace`, and the set `module_without_tables`
prunes by. Two collections declaring one name are two entries throughout:
charged separately, placed separately, grouped apart, filed under their
own paths, and handed their own options.

That is what lets them hold their own options, which is what the planner
could not do before and why it refused the model instead.
`DynamicEmbTableOptions` is both the caller's policy and the runtime's
per-table config, and `_prepare_dynemb_table_options` writes the geometry
into it -- `dim` from `embedding_dim`, `max_capacity` from
`num_embeddings` through the bucket layout, `embedding_dtype` from
`data_type` -- so one object cannot describe two tables, and the function
is not idempotent besides: it reads back `bucket_capacity`,
`max_capacity` and `init_capacity` after writing them. Reached by name,
both occurrences got the same object. TorchRec does not have the problem
because `ParameterConstraints` is policy-only and each occurrence's
geometry comes from its own `tensor=param`.

So `constraints` gains a second key form, and `get_constraint_key` is how
a caller writes one:

    constraints = {
        get_constraint_key(shared_a, model): ...,   # sparse.ebc_a.shared
        get_constraint_key(shared_b, model): ...,   # sparse.ebc_b.shared
    }

It takes the config object rather than a name, because by name there is
nothing to tell the two apart -- and a collection returns the config
objects it was built from, so identity matches what the caller is
holding. `module` is the root the path is relative to, so passing a
collection itself returns the bare name and a caller with one collection
needs no special case. The answer is a function of the arguments alone,
never of whether some unrelated collection happens to share a name; a key
that moved for that reason would be a key written down elsewhere and now
silently wrong.

`resolve_constraints` is the other half. Each occurrence asks for its
keys in turn -- qualified, then bare -- and takes the first `constraints`
has. That order is the whole of the addressing rule: a bare name still
reaches a table nothing more specific names, so a model whose table names
are unique needs no change at all, and a qualified key overrides it for
one collection. It refuses three things, all of them constraints that
would otherwise be silently unused: a key no occurrence answers to; a
qualified key on a table TorchRec plans, since its planner looks
constraints up by name alone and would never find it; and one
`DynamicEmbTableOptions` object reached by two occurrences, which is what
a bare name does when two collections declare it, and whose message names
`get_constraint_key`.

That last check also closes an older hole. Two differently-named tables
sharing one constraint object -- `{"a": c, "b": c}` -- hit the same
non-idempotent write and were silently mis-sized; they are now refused
for the same stated reason.

Having two places that needed the path made it worth having one that
finds it. The descent a sharder-claimed module ends -- the enumerator's
own rule -- was written out three times: in `_table_configs`, in
`_insert_dynamicemb_plan`, and in `optimizer_types`, which wants the
sharder and threw the path away. The first two have to agree about the
paths they produce and nothing made them, each building its own
`f"{path}.{name}" if path else name`; a plan filed under a path
`DistributedModelParallel` does not look for is not an error there, since
it shards the modules its plan names and leaves the rest alone, so a
drift would have surfaced as a collection that silently stayed unsharded.
They now share `sharded_modules`, which yields each claimed module with
its path and its sharder. `module_without_tables` keeps its own
recursion: it rebuilds the tree from the bottom up rather than reading
it.

Keying its prune set by `TableKey` fixes a bug of its own. It pruned by
name, so a name DynamicEmb planned in one collection was taken out of
every collection -- leaving TorchRec a table it was told to plan and
could no longer see.

`per_rank_storage`'s docstring claimed coarseness was safe in both
directions. `fusion_key`'s already said otherwise; this makes them agree.

`get_planner` is unchanged and still keys by name: its `eb_configs` is a
flat list with no module to take a path from, so it cannot express a
qualified key. A model that needs one builds its constraints and the
planner directly; a comment there says so.

BREAKING CHANGE: `TableToPlace.name` is now `key`, a `TableKey`, and
`NodePlacer.place` returns `Dict[TableKey, int]`. A custom `NodePlacer`
must follow. `per_rank_storage`, `optimizer_types` and
`module_without_tables` are likewise keyed by `TableKey` rather than by
table name. `fusion_key` takes the owning collection as a trailing
argument; new parameters go after it, since the existing ones are passed
positionally. Two tables sharing one `DynamicEmbTableOptions` object is
now an error rather than a silent mis-sizing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…dy does

`test_a_name_that_is_unique_is_qualified_just_the_same` asserted
`get_constraint_key(l, module) == "left.l"`, which the test above it
already asserts as the second element of its list -- `l` is in that
module precisely so a name nothing collides with is seen to be qualified
too. `test_an_overridden_bare_key_is_not_reported_as_a_typo` built the
same module and the same constraints as the precedence test and asserted
only that nothing was raised, which the precedence test reaches first:
were the overridden bare key reported as naming no table, it would raise
there and that test would fail. `test_the_path_is_stable_across_calls`
compared two walks over two instances of one class, where the paths come
from `named_modules` and cannot differ. None could fail on its own.

What the first two said is kept: both docstrings move onto the test that
survives, since the reason a case is interesting outlives the duplicate
assertion. The third's -- that the identity is the path rather than
`id()` because every rank walks alone -- is already on `TableKey` and in
§7.2, where it is a statement about the design rather than about this
model.

The helpers they left behind are folded together. `_dynamicemb_planner`
spelled out the same row-wise DynamicEmb constraint that
`_dynamicemb_constraints` builds, so it now calls it; and `_planned` --
step 1 run over a module, three lines open-coded in two places -- becomes
one module-level helper.

No behaviour is under test here that was not before: 61 tests in this
file become 58.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Six tests asserted the shape of an internal return value. `_table_configs`
pairs each config with a path -- which every test downstream of it relies
on, and which `get_constraint_key` already states from the side a caller
sees, since the bare name a root collection yields is the promise that
one collection needs no special key. Four more restated what
`sharded_modules` does: the paths it yields, the empty path at the root,
the sharder it carries, that an unclaimed module is recursed into. All of
that is the walk's implementation written twice, and it had to be
rewritten once already when the walk started carrying a `TableKey`.

What survives of that class is the one thing no caller can see: that the
path `_table_configs` records a table's collection as is the path
`_insert_dynamicemb_plan` files its ParameterSharding under. Two walks
that disagreed would not raise -- `DistributedModelParallel` shards the
modules its plan names and leaves the rest alone -- so a collection would
silently stay unsharded.

`TestResolveConstraints` now drives the planner instead of calling
`resolve_constraints`. What a caller writes is a `constraints` dict and
what they get back is a planned table or an error; which function inside
reaches that answer is ours to move, and the tests should not have to
move with it. The precedence case gains something in the trade: it asks
which options object the table was *planned* with, by identity, where
before it only asked which constraint was selected.

Not moved up to `plan()` itself, which needs a process group: these stay
in the unit tests, one level below the public entry, rather than becoming
four more end-to-end runs where a mis-keyed constraint shows up as an OOM.

52 tests, from 58.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`test_a_bare_name_still_reaches_its_table` asserted the compatibility
every other test in the file is already written in: they all key their
constraints by a bare name, so bare lookup breaking turns the file red
without its help. The note it carried -- that a `constraints` dict
written before any of this keeps working -- moves to the class, where it
reads as the premise it is.

`TestShardedModules` no longer calls `sharded_modules`; what is left of
it is the invariant between two callers, so it is named for that:
`TestCollectionPathsAgree`, matching `TestCollectionsDoNotPoolBudgets`
rather than the classes named after the function under test.

51 tests, from 52.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Each of these wrapped something shorter than the name that hid it, or
named half of what it returned.

`_sharders()` was `[EmbeddingBagCollectionSharder()]`, and its name --
plural, unqualified -- said less than the expression. Inlined.

`_at_ebc(name)` was `TableKey("sparse.ebc", name)`, in tests whose whole
subject is which path a table is filed under. Inlined, so the path is on
the line that asserts about it.

`_planned` returned a planner and said neither that nor which step had
run. It is now `_plan_dynamicemb`, after the method it calls, and takes
`sharders` so that "only the pooled collection's" is on the signature
rather than buried in the body.

`_sharding` returned the `(ParameterSharding, DynamicEmbTableOptions)`
pair and named the first half; it is `_planned_table`, after the
`_Planned` it builds. The class-local `_sharding` in
`TestCollectionsDoNotPoolBudgets` does return a bare sharding and keeps a
name of its own, `_row_wise_sharding`.

`_ebc`, `_ec` and `_TwoCollections` took bare lists, so a call read
`_TwoCollections(["shared"], ["shared"])` with nothing to say which side
was which. They now take `table_names`, `left_names` and `right_names`,
passed by keyword.

Two things found while reading. `_key` had an `isinstance(name,
TableKey)` passthrough that no caller reaches -- left from when these
tests were keyed by name -- so it does one thing now. And its default
collection was `"ebc"`, a module that does not exist in this file; it is
`"sparse.ebc"`, where `_Model` actually holds its collection, so the
string means one thing throughout.

No test is added, removed or re-aimed. `test_planner_placement.py` keeps
its own `_table(collection="ebc")`: that file builds `TableToPlace`
directly and has no module tree, so there is no path for the value to
agree with.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`get_constraint_key`'s docstring said its return value was also the key
for `get_planner`'s `table_row_wise_embedding_table_names`. It is not:
that set is compared against `config.name` (`get_planner.py`), a bare
name, while a qualified key is `collection.name`. A caller following the
docstring got neither an error nor table-row-wise sharding -- the `else`
branch planned the table row-wise and nothing said so.

That is the mistake `resolve_constraints` refuses for `constraints`, in
those words, because a constraint that reaches no table reads as "plan
this with the defaults" and is found in a profile rather than in an
error. `get_planner` had no such check: it has no `raise` of its own at
all, and a name matching nothing was dropped silently.

So the docstring now says where the key does and does not work, and
`get_planner` refuses a name that `eb_configs` does not declare. Three
arguments, not one: `data_parallel_embedding_table_names` fails the same
way -- a typo there plans the table model parallel -- and an extra key in
`dynamicemb_options_dict` is likewise ignored, though a missing one
already raises `KeyError` where it is indexed. The message names the
qualified-key case, since that is the one the docstring sent people to.

The check runs before `torch.cuda.get_device_properties` and
`dist.get_world_size`, so it needs neither a GPU nor a process group, and
every caller reaches it.

`get_planner` still cannot take a qualified key: `eb_configs` is a flat
list with no module to take a path from. A model that needs one builds
its constraints and the planner directly, which the docstring now says.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two claims in `DynamicEmb_APIs.md` described behaviour that is gone.

The planner no longer "validates that every table name appears exactly
once": that uniqueness check was what refused a model two collections
could declare one name in, and it is what the `TableKey` work removed.
In its place the doc now has a section on how `constraints` is keyed --
qualified before bare, which is why a model whose names are unique needs
no change -- what `get_constraint_key` is for and why it takes the config
object, and the three cases that are refused. None of this was in the
document a caller reads; it was only in the design note.

The `NodePlacer` example returned `Dict[str, int]` keyed by table name.
`place` returns `Dict[TableKey, int]`, so a placer written from that
example would hand back keys the planner cannot look up. The example
imports `TableKey`, returns `table.key`, and says what the pair is.

The new section also says where the key does *not* work: `get_planner`'s
three name arguments are keyed by the bare name, and as of the commit
before this one it refuses a name `eb_configs` does not declare instead
of planning the table some other way.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ls TRW future

The design note described the planner it was written against rather than
the one that exists.

- `per_rank_storage` "needed no change" was true of M2 and false since:
  it is keyed by `TableKey` and buckets by `fusion_key`. The same row
  listed two of `plan.py`'s helpers where it now holds seven.
- `local_hbm_for_values` was said to come from the world size. It is
  divided by the table's own fanout -- one node's worth under
  table-row-wise -- which is what §4.2 is about. The same sentence was
  wrong in `_prepare_dynemb_table_options`'s docstring, which is where a
  reader is most likely to trust it.
- The step 2-4 sketch passed `table_names` to `module_without_tables`,
  which takes a set of `TableKey`.
- Ties in the placer break on the key, not the name.
- A pin that does not fit is refused naming `collection.name`.
- `test_tables_that_do_not_fuse_do_not_pool_their_budgets` was said to
  have a case per component of `fusion_key`. It has five of six: the
  sharding type is fixed at table-row-wise by `TableToPlace.fusion_key`,
  so what guards that component is `per_rank_storage`, which reads each
  table's own. Saying "a case per attribute" invites the next reader to
  assume a guard that is not there.

The note also now says that `get_planner` cannot express a qualified key
and refuses a name `eb_configs` does not declare.

`README.md` was two releases behind in both directions: its usage notes
said a dynamic embedding table "is always row-wise sharding", and its
future plans still listed `table-row-wise` among the shard types to add.
It shipped in NVIDIA#493.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@jiashuy
jiashuy force-pushed the feat/dynamicemb-table-key branch from d7fe796 to 25244ea Compare October 21, 2026 03:18
`get_group_value_bytes_by_tier` asked about `caching` before asking
whether the group fits. The runtime asks in the other order:
`_create_cache_storage` tests `total_memory > local_hbm` first, and the
`else` branch is HBM_ONLY -- it never reads `caching`, and warns that
`external_storage` is ignored there as well. There is no cache and no
backing tier for a group whose rows fit their budget.

So a group that fits was charged its whole HBM budget plus its whole
size again on the host: 4 GiB of rows with a 20 GB budget cost 20 GB of
HBM and 4 GiB of host, where the runtime spends 4 GiB of HBM and nothing.
Both figures over-state, which is the direction that refuses a layout
that would have run rather than accepting one that will not -- the
planner and `BalancedNodePlacer` both price through this function, so a
model with a generous cache budget could fail to place on a machine with
room for it.

The fit check now comes first and the caching branch sits inside it,
which leaves every other case as it was: CACHING and CACHING_PS when the
rows do not fit, HOST_ONLY and HOST_PS when there is no budget to hold
them, HYBRID when the budget covers part, HBM_ONLY when it covers all.

One case remains deliberately unlike the runtime: `caching=True` with no
HBM budget at all raises in `_create_cache_storage` ("Can't use caching
mode as the reserved HBM size is too small") and is costed here as a
host-only group. The planner accepts a configuration that will not
build. That is a refusal to add, not an arithmetic change, and it is left
for its own commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@jiashuy

jiashuy commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

CI(dynamicemb fw_bw & dump_load) passed on EOS, ready to be merged

@jiashuy
jiashuy requested a review from shijieliu October 21, 2026 05:42
@shijieliu
shijieliu merged commit bbf9db4 into NVIDIA:main Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants