Skip to content

Support block_bucketize_sparse_features for empty tensor #3750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JacoCheung opened this issue Feb 28, 2025 · 0 comments
Open

Support block_bucketize_sparse_features for empty tensor #3750

JacoCheung opened this issue Feb 28, 2025 · 0 comments

Comments

@JacoCheung
Copy link

JacoCheung commented Feb 28, 2025

Bug description

While evaluating with TorchRec ShardedEmbeddingCollection under a distributed env, some rank may get zero input for the last global batch. However fbgemm.block_bucketize_sparse_features will throw errors when the lengths tensor contains no elements:

Traceback (most recent call last):
    x = torch.ops.fbgemm.block_bucketize_sparse_features(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/_ops.py", line 1120, in __call__
    return self._op(*args, **(kwargs or {}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA error: invalid configuration argument
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

Can you help to support an empty input ? Thanks!

reproducer

import fbgemm_gpu
import torch
import torchrec

values = torch.tensor([]).long().cuda()
lengths = torch.tensor([]).long().cuda()

mb = torchrec.KeyedJaggedTensor(
    keys = ["product"],
    values = values, # key [] on rank0, [2] on rank 1
    lengths = lengths, # length [] on rank0, 1 on rank 1
)
x = torch.ops.fbgemm.block_bucketize_sparse_features(
  lengths,
  values,
  bucketize_pos=False,
  sequence=True,
  block_sizes=torch.tensor([2]).cuda(),
  my_size=2,
  max_B=-1
)

ENV

  • version 1.0.0
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

No branches or pull requests

1 participant