Skip to content

[FIX](DynamicEmb) Fix int32 overflow in get_dst_ptr - #555

Merged
shijieliu merged 1 commit into
NVIDIA:mainfrom
lzw3232:main
Nov 13, 2026
Merged

shijieliu merged 1 commit into
NVIDIA:mainfrom
lzw3232:main

Conversation

@lzw3232

@lzw3232 lzw3232 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

The output address calculation used by gather_embedding_pooled computes b * layout.total_D in int32. When the output element count exceeds INT32_MAX, this multiplication can overflow even though the sample index and row width each fit in int32, causing a CUDA illegal memory access. For example, B=10,520,878 and total_D=256 produce 2,693,344,768 output elements.
Cast b to int64_t before multiplication so the output address offset is computed in 64 bits. This change is limited to address arithmetic and does not extend the supported range of batch indices, bag indices, or dimensions.

Signed-off-by: lizongwu <[email protected]>
Co-authored-by: TRAE CLI <[email protected]>
@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This change appears safe to merge.

Summary

Fixes pooled embedding output addresses when the output contains more than INT32_MAX elements.

  • Pooled gather keeps large output row offsets in 64 bits.

No actionable issues found.

Reviews (1) · Last reviewed commit: "Fix int32 overflow in get_dst_ptr" · Reviewed by Greptile

@shijieliu
shijieliu merged commit 428ba2f into NVIDIA:main Nov 13, 2026
1 check passed
shijieliu added a commit to shijieliu/recsys-examples that referenced this pull request Nov 16, 2026
Brings in main 4466f9d: NVIDIA#528 (hierarchical dist), NVIDIA#550, NVIDIA#553, NVIDIA#555, NVIDIA#478
(exportable embedding collections with NVE layers), NVIDIA#554 and NVIDIA#556.

Conflicts:
- corelib/dynamicemb/CMakeLists.txt: main (NVIDIA#478) adds the RPATH, NVE_ROOT
  and DYNAMICEMB_PYTHON_MODULE_DIR lines above the C++ standard; kept them,
  with this branch's C++20 (PyTorch 2.14's headers need it).
- corelib/dynamicemb/setup.py: main's file. It already has this branch's
  CUDA_HOME import and sm_103-aware default archs (from NVIDIA#528); the conflict
  was only main's new `import torch` and `Extension` imports.
- corelib/dynamicemb/README.md: main's new inference build section, after
  this branch's FBGEMM 1.9.0 / TorchRec 1.9.2 lines.

docker/Dockerfile merged cleanly: NVIDIA#478's build stage rebuilds the default
NVE from the submodule with the same pip command and settings as the devel
stage, and builds torch_binding_build through the CMakeLists above.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aleliu <[email protected]>
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