Fix backward_adagrad unit test#5397
Closed
spcyppt wants to merge 1 commit into
Closed
Conversation
Contributor
Summary: Three fixes to the backward_adagrad test: 1. **Fix bs_features construction**: The previous logic for building `bs_features` from `feature_table_map` was incorrect when tables were replicated across multiple features. It used manual insertion logic that was fragile and produced wrong mappings. Replaced with a direct list comprehension `[bs[t] for t in feature_table_map]` which correctly maps each feature to its corresponding table's embedding module. 2. **Fix OOM in gradcheck**: When `tbe_op` is provided, the test was proceeding into torch gradcheck which allocates significant additional GPU memory, causing OOM. Added an early return when `tbe_op` is set, and explicitly freed large tensors (`bs`, `bs_features`, `fs`, `gos`, `cc`, etc.) before gradcheck to reduce GPU memory pressure. 3. **Add TBE_CONFIG_INDEX env var**: Added support for a `TBE_CONFIG_INDEX` environment variable to select a single TBE config to test, allowing targeted debugging of individual configurations without running all configs. 4. **Fix T_ calculation**: Changed `T_ = len(xws)` to `T_ = num_features` for the `feature_requires_grad` tensor size, since its length should match the number of features, not the number of input tensors. Reviewed By: q10 Differential Revision: D92668399
26e72a5 to
05ce783
Compare
Contributor
|
This pull request has been merged in d49fc97. |
zpao
pushed a commit
that referenced
this pull request
Feb 28, 2026
Summary: X-link: https://github.com/facebookresearch/FBGEMM/pull/2372 Pull Request resolved: #5397 Three fixes to the backward_adagrad test: 1. **Fix bs_features construction**: The previous logic for building `bs_features` from `feature_table_map` was incorrect when tables were replicated across multiple features. It used manual insertion logic that was fragile and produced wrong mappings. Replaced with a direct list comprehension `[bs[t] for t in feature_table_map]` which correctly maps each feature to its corresponding table's embedding module. 2. **Fix OOM in gradcheck**: When `tbe_op` is provided, the test was proceeding into torch gradcheck which allocates significant additional GPU memory, causing OOM. Added an early return when `tbe_op` is set, and explicitly freed large tensors (`bs`, `bs_features`, `fs`, `gos`, `cc`, etc.) before gradcheck to reduce GPU memory pressure. 3. **Add TBE_CONFIG_INDEX env var**: Added support for a `TBE_CONFIG_INDEX` environment variable to select a single TBE config to test, allowing targeted debugging of individual configurations without running all configs. 4. **Fix T_ calculation**: Changed `T_ = len(xws)` to `T_ = num_features` for the `feature_requires_grad` tensor size, since its length should match the number of features, not the number of input tensors. Reviewed By: q10 Differential Revision: D92668399 fbshipit-source-id: 0956adf01c2291fcba7b05fe39b70f669a408156
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.
Summary:
X-link: https://github.com/facebookresearch/FBGEMM/pull/2372
Three fixes to the backward_adagrad test:
Fix bs_features construction: The previous logic for building
bs_featuresfromfeature_table_mapwas incorrect when tables were replicated across multiple features. It used manual insertion logic that was fragile and produced wrong mappings. Replaced with a direct list comprehension[bs[t] for t in feature_table_map]which correctly maps each feature to its corresponding table's embedding module.Fix OOM in gradcheck: When
tbe_opis provided, the test was proceeding into torch gradcheck which allocates significant additional GPU memory, causing OOM. Added an early return whentbe_opis set, and explicitly freed large tensors (bs,bs_features,fs,gos,cc, etc.) before gradcheck to reduce GPU memory pressure.Add TBE_CONFIG_INDEX env var: Added support for a
TBE_CONFIG_INDEXenvironment variable to select a single TBE config to test, allowing targeted debugging of individual configurations without running all configs.Fix T_ calculation: Changed
T_ = len(xws)toT_ = num_featuresfor thefeature_requires_gradtensor size, since its length should match the number of features, not the number of input tensors.Differential Revision: D92668399