Skip to content

OSS MPZCH CUDA kernel in FBGEMM #4214

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lizhouyu
Copy link

Summary:
Opensource FBGEMM CUDA Kernel for MPZCH feature

Major changes

  • Create a folder named faster_hash under the fbgemm/fbgemmgpu/src folder.
  • Copy the following files to the created folder from fbsource/fbcode/caffe2/torch/fb/retrieval
    • faster_hash.cpp
    • faster_hash.cu
    • common_utils.cuh
  • Revise the faster_hash.cpp
    • Change namespace fb to namespace fbgemm_gpu.
    • Comment out using namespace torch::fb::turborec;
    • Change TORCH_LIBRARY_IMPL(fb, ...) to TORCH_LIBRARY_IMPL(fbgemm, ...)
    • Fix namespace calling issue due to the namespace change.
  • Revise the faster_hash.cu
    • Change namespace fb to namespace fbgemm_gpu.
    • Change TORCH_LIBRARY_IMPL(fb, ...) to TORCH_LIBRARY_IMPL(fbgemm, ...)
    • Fix namespace calling issue due to the namespace change.
  • Revise the common_utils.cuh file
    • Change namespace fb to namespace fbgemm_gpu.
  • Add a BUCK file to compile the cpp and cuda library.
  • Copy the faster_hash_test.py file to the fbgemm/fbgemm_gpu/test folder.
  • Add a section in the BUCK file under the test folder for python_unittest of faster_hash_test.
  • In the faster_hash_test.py file
    • Load the faster_hash related libraries with torch.ops.load API.
    • Replace all the torch.ops.fb to torch.ops.fbgemm.
    • Following other test files to add opensource and gpu availability check.

Questions

  • After refactorying, the API calls torch.ops.create_zch_buffer, torch.ops.zero_collision_hash, torch.ops.fbgemm.zero_collision_hash, and torch.ops.fbgemm.create_zch_buffer are all valid, while torch.ops.create_zch_buffer and torch.ops.zero_collision_hash may incur certain parameter mismatches. How to resolve this issue and disable the API calls without fbgemm?
  • How to integrate the refactoryed library into fbgemm so the test can call something like from fbgemm_gpu import create_zch_buffer, zero_collision_hash?

Differential Revision: D75505020

Copy link

netlify bot commented May 29, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit 0bbf4d2
🔍 Latest deploy log https://app.netlify.com/projects/pytorch-fbgemm-docs/deploys/6842654f4bd1d30008bcfb13
😎 Deploy Preview https://deploy-preview-4214--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 684b319 to a29cd2a Compare May 29, 2025 20:46
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 29, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 29, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from a29cd2a to 2c3846e Compare May 29, 2025 20:56
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 2c3846e to 2b54f80 Compare May 29, 2025 21:07
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 29, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 29, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 2b54f80 to d94acaa Compare May 29, 2025 21:15
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@lizhouyu lizhouyu force-pushed the export-D75505020 branch from d94acaa to 3d36968 Compare May 30, 2025 17:56
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 30, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 30, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 3d36968 to a273543 Compare May 30, 2025 18:02
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 30, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from a273543 to d203230 Compare May 30, 2025 18:07
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@lizhouyu lizhouyu force-pushed the export-D75505020 branch from d203230 to 4490476 Compare May 30, 2025 18:45
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request May 30, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 4490476 to e35f85d Compare May 30, 2025 18:48
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from ff9ea8e to 62db371 Compare June 4, 2025 16:56
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 62db371 to 3bba1db Compare June 4, 2025 17:00
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 3bba1db to e39d109 Compare June 4, 2025 17:05
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from e39d109 to b4cab55 Compare June 5, 2025 15:43
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from b4cab55 to 67658fd Compare June 5, 2025 16:45
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 67658fd to fcdcf8d Compare June 5, 2025 16:51
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@lizhouyu lizhouyu force-pushed the export-D75505020 branch from fcdcf8d to 7c070ee Compare June 5, 2025 17:04
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
lizhouyu added a commit to lizhouyu/FBGEMM-1 that referenced this pull request Jun 5, 2025
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.

### Questions
- After refactorying, the API calls `torch.ops.create_zch_buffer`, `torch.ops.zero_collision_hash`, `torch.ops.fbgemm.zero_collision_hash`, and `torch.ops.fbgemm.create_zch_buffer` are all valid, while `torch.ops.create_zch_buffer` and `torch.ops.zero_collision_hash` may incur certain parameter mismatches. How to resolve this issue and disable the API calls without `fbgemm`?
- How to integrate the refactoryed library into fbgemm so the test can call something like `from fbgemm_gpu import create_zch_buffer, zero_collision_hash`?

Differential Revision: D75505020

Reviewed By: ionuthristodorescu
Summary:
Pull Request resolved: pytorch#4214

X-link: facebookresearch/FBGEMM#1290

Opensource FBGEMM CUDA Kernel for MPZCH feature

### Major changes
- Create a folder named `faster_hash` under the `fbgemm/fbgemmgpu/src` folder.
- Copy the following files to the created folder from `fbsource/fbcode/caffe2/torch/fb/retrieval`
  - faster_hash.cpp
  - faster_hash.cu
  - common_utils.cuh
- Revise the `faster_hash.cpp`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Comment out `using namespace torch::fb::turborec;`
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `faster_hash.cu`
  - Change `namespace fb` to `namespace fbgemm_gpu`.
  - Change `TORCH_LIBRARY_IMPL(fb, ...)` to `TORCH_LIBRARY_IMPL(fbgemm, ...)`
  - Fix namespace calling issue due to the namespace change.
- Revise the `common_utils.cuh` file
  - Change `namespace fb` to `namespace fbgemm_gpu`.
- Add a BUCK file to compile the cpp and cuda library.
- Copy the `faster_hash_test.py` file to the `fbgemm/fbgemm_gpu/test` folder.
- Add a section in the BUCK file under the `test` folder for `python_unittest` of `faster_hash_test`.
- In the `faster_hash_test.py` file
  - Load the `faster_hash` related libraries with `torch.ops.load` API.
  - Replace all the `torch.ops.fb` to `torch.ops.fbgemm`.
  - Following other test files to add `opensource` and `gpu availability` check.
- OSS the `murmur_hash3` function
  - Write wrappers for the `murmur_hash3` function in `faster_hash.cu` and `faster_hash.cpp` files, register wrapper functions and expose to external calls.
  - Add a test for the `murmur_hash3` function to validate on `CPU` and `GPU` the hashed values are identical for the same input value.

Reviewed By: ionuthristodorescu

Differential Revision: D75505020
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75505020

@lizhouyu lizhouyu force-pushed the export-D75505020 branch from 7c070ee to 0bbf4d2 Compare June 6, 2025 03:49
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.

2 participants