Skip to content

Migrate internal tbe/* and torchrec callers to canonical type packages#5780

Closed
q10 wants to merge 1 commit into
pytorch:mainfrom
q10:export-D105789345
Closed

Migrate internal tbe/* and torchrec callers to canonical type packages#5780
q10 wants to merge 1 commit into
pytorch:mainfrom
q10:export-D105789345

Conversation

@q10
Copy link
Copy Markdown
Contributor

@q10 q10 commented May 26, 2026

Summary:
...canonical packages where those types now live
(fbgemm_gpu.tbe.config, fbgemm_gpu.tbe.cache.cache_config,
fbgemm_gpu.tbe.ssd.ssd_config). Also remove the eager
KVEmbeddingInference re-export from tbe/cache/__init__.py (and
update its 1 in-tree caller bench/tbe/tbe_kv_benchmark.py) so that
loading tbe.cache no longer transitively imports the heavy
kv_embedding_ops_inference module. Fold the one stray external
caller (torchrec/distributed/batched_embedding_kernel.py) that
D103493980 missed: BackendType is consolidated into the existing
from fbgemm_gpu.tbe.ssd import (...) block.

After this diff, no fbgemm_gpu/ source file depends on the shell for
any type that has a canonical home elsewhere (only construct_cache_state
and get_new_embedding_location still come from the shell since they
have not yet been canonicalised). This is the prerequisite for D103477971:
it breaks the latent circular import (ops_common -> tbe.ssd.ssd_config ->
tbe/ssd/init.py -> tbe/ssd/inference.py -> ops_common) at its source,
allowing D103477971 to convert ops_common.py to a re-export shell without
relocating ssd_config.py outside the tbe.ssd package.

Files migrated (internal, fbgemm_gpu/):

  • fbgemm_gpu/tbe/ssd/inference.py, inference_serving.py, training.py
  • fbgemm_gpu/tbe/cache/init.py, kv_embedding_ops_inference.py
  • fbgemm_gpu/tbe/bench/benchmark_click_interface.py, embedding_ops_common_config.py
  • fbgemm_gpu/split_embedding_configs.py, split_embedding_inference_converter.py
  • fbgemm_gpu/split_table_batched_embeddings_ops.py
  • fbgemm_gpu/split_table_batched_embeddings_ops_inference.py
  • fbgemm_gpu/split_table_batched_embeddings_ops_training.py
  • fbgemm_gpu/split_table_batched_embeddings_ops_training_common.py
  • fbgemm_gpu/sparse_ops.py
  • fbgemm_gpu/bench/tbe/tbe_kv_benchmark.py

Files migrated (external):

  • torchrec/distributed/batched_embedding_kernel.py: BackendType line 37
    folded into the existing tbe.ssd package umbrella block.

Backward-compat fallback paths inside torchrec (D105254047's
try/except ImportError shims in embedding_lookup.py / sharding_config.py /
types.py) are intentionally LEFT UNTOUCHED - they protect old base-layer
fbgemm_gpu consumers and remain dead code on master.

No public-API change. The legacy shell still re-exports every type, so
external callers (and the pyper_models snapshot copies of older torchrec)
are unaffected.

Reviewed By: cthi

Differential Revision: D105789345

Summary:
...canonical packages where those types now live
(`fbgemm_gpu.tbe.config`, `fbgemm_gpu.tbe.cache.cache_config`,
`fbgemm_gpu.tbe.ssd.ssd_config`). Also remove the eager
`KVEmbeddingInference` re-export from `tbe/cache/__init__.py` (and
update its 1 in-tree caller `bench/tbe/tbe_kv_benchmark.py`) so that
loading `tbe.cache` no longer transitively imports the heavy
`kv_embedding_ops_inference` module. Fold the one stray external
caller (`torchrec/distributed/batched_embedding_kernel.py`) that
D103493980 missed: `BackendType` is consolidated into the existing
`from fbgemm_gpu.tbe.ssd import (...)` block.

After this diff, no `fbgemm_gpu/` source file depends on the shell for
any type that has a canonical home elsewhere (only `construct_cache_state`
and `get_new_embedding_location` still come from the shell since they
have not yet been canonicalised). This is the prerequisite for D103477971:
it breaks the latent circular import (ops_common -> tbe.ssd.ssd_config ->
tbe/ssd/__init__.py -> tbe/ssd/inference.py -> ops_common) at its source,
allowing D103477971 to convert ops_common.py to a re-export shell without
relocating ssd_config.py outside the tbe.ssd package.

Files migrated (internal, fbgemm_gpu/):
- fbgemm_gpu/tbe/ssd/inference.py, inference_serving.py, training.py
- fbgemm_gpu/tbe/cache/__init__.py, kv_embedding_ops_inference.py
- fbgemm_gpu/tbe/bench/benchmark_click_interface.py, embedding_ops_common_config.py
- fbgemm_gpu/split_embedding_configs.py, split_embedding_inference_converter.py
- fbgemm_gpu/split_table_batched_embeddings_ops.py
- fbgemm_gpu/split_table_batched_embeddings_ops_inference.py
- fbgemm_gpu/split_table_batched_embeddings_ops_training.py
- fbgemm_gpu/split_table_batched_embeddings_ops_training_common.py
- fbgemm_gpu/sparse_ops.py
- fbgemm_gpu/bench/tbe/tbe_kv_benchmark.py

Files migrated (external):
- torchrec/distributed/batched_embedding_kernel.py: `BackendType` line 37
  folded into the existing `tbe.ssd` package umbrella block.

Backward-compat fallback paths inside torchrec (D105254047's
try/except ImportError shims in embedding_lookup.py / sharding_config.py /
types.py) are intentionally LEFT UNTOUCHED - they protect old base-layer
fbgemm_gpu consumers and remain dead code on master.

No public-API change. The legacy shell still re-exports every type, so
external callers (and the pyper_models snapshot copies of older torchrec)
are unaffected.

Reviewed By: cthi

Differential Revision: D105789345
@meta-cla meta-cla Bot added the cla signed label May 26, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 26, 2026

@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105789345.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 26, 2026

This pull request has been merged in 8e5780d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant