FBGEMM icon indicating copy to clipboard operation
FBGEMM copied to clipboard

cmake: introduce USE_SYSTEM_* flags

Open ConnorBaker opened this issue 2 years ago β€’ 25 comments

Similar to the work done in https://github.com/pytorch/pytorch/pull/37137, this adds the following CMake options:

  • USE_SYSTEM_LIBS
  • USE_SYSTEM_ASMJIT
  • USE_SYSTEM_CPUINFO
  • USE_SYSTEM_GOOGLETEST

This is particularly useful in the context of Nix, where we can build these libraries once and then re-use them elsewhere to avoid rebuilding vendors dependencies.

I'm unsure of how to best enable this for fbgemm_gpu.

What's the relationship between FBGEMM and libtorch? Does libtorch require fbgemm, fbgemm_gpu, or both?

ConnorBaker avatar Jul 01 '23 23:07 ConnorBaker

Deploy Preview for pytorch-fbgemm-docs canceled.

Name Link
Latest commit 8dc96b908062fb5584f1e8669f467a4e0a53c084
Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/64e43cb85fc3e90008b17749

netlify[bot] avatar Jul 01 '23 23:07 netlify[bot]

@q10 I see that you've worked with the CMake in this repo before, would you have the bandwidth to review this?

ConnorBaker avatar Jul 01 '23 23:07 ConnorBaker

@q10 I see that you've worked with the CMake in this repo before, would you have the bandwidth to review this?

Yes I can. Let me run it through the OSS CI system before reviewing this more thoroughly on Monday.

q10 avatar Jul 02 '23 00:07 q10

Much appreciated! And any insight on changes I'd need to make for the GPU variant would be awesome :)

ConnorBaker avatar Jul 02 '23 01:07 ConnorBaker

@q10 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jul 04 '23 04:07 facebook-github-bot

@q10 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jul 04 '23 23:07 facebook-github-bot

As a followup, any thoughts on offering an fbgemm-config.cmake for users who would like to be able to do find_package(fbgemm)?

I know that fbgemmLibraryConfig.cmake is produced, but that's also located in /share/cmake/fbgemm and so I need to use find_package(fbgemmLibrary) and pass "-DfbgemmLibrary_DIR:PATH=${fbgemm}/share/cmake/fbgemm" to have CMake find it.

Although, I'm not very proficient in writing or interpreting CMake, so that may be working as intended or a best practice.

ConnorBaker avatar Jul 04 '23 23:07 ConnorBaker

As a followup, any thoughts on offering an fbgemm-config.cmake for users who would like to be able to do find_package(fbgemm)?

I know that fbgemmLibraryConfig.cmake is produced, but that's also located in /share/cmake/fbgemm and so I need to use find_package(fbgemmLibrary) and pass "-DfbgemmLibrary_DIR:PATH=${fbgemm}/share/cmake/fbgemm" to have CMake find it.

Although, I'm not very proficient in writing or interpreting CMake, so that may be working as intended or a best practice.

I think it's a good idea to offer an fbgemm-config.cmake, though we are not experts on CMake either, which is why we have not gotten around to working on this.

I'm looking at the CI builds, and it appears that the CMake changes made in this PR have broken all the CMake-based builds of FBGEMM (see here)...

q10 avatar Jul 05 '23 18:07 q10

@q10 would you mind triggering CI again to see if it's fixed?

ConnorBaker avatar Jul 09 '23 17:07 ConnorBaker

@q10 would you mind triggering CI again to see if it's fixed?

Looks to be broken still :(

q10 avatar Jul 10 '23 19:07 q10

Alrighty, @q10 would you mind running the CI again?

ConnorBaker avatar Aug 22 '23 05:08 ConnorBaker

bumping this thread.

BwL1289 avatar Apr 29 '25 16:04 BwL1289

Hi @ConnorBaker, if there is still desire to land this PR, could you rebase it onto latest main?

q10 avatar Apr 29 '25 17:04 q10

Im happy to help if @ConnorBaker is no longer interested.

BwL1289 avatar Apr 29 '25 17:04 BwL1289

@ConnorBaker I have rebased and fixed merge conflicts if you can give me access to push to your repo

BwL1289 avatar Apr 29 '25 21:04 BwL1289

@BwL1289 you should have access now, thank you!

ConnorBaker avatar Apr 30 '25 05:04 ConnorBaker

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
Latest commit e6af349433d75ab81dc6cf8ee0a85360d0355654
Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/68137140d845300008db4f93
Deploy Preview https://deploy-preview-1859--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 site configuration.

netlify[bot] avatar Apr 30 '25 12:04 netlify[bot]

@ConnorBaker thanks! Just pushed and synced the last few commits. @q10 let us know if you can run CI again.

BwL1289 avatar Apr 30 '25 13:04 BwL1289

@q10 bump

BwL1289 avatar May 01 '25 13:05 BwL1289

@q10 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar May 01 '25 21:05 facebook-github-bot

Ths diff appears to break linux and macos builds - see https://github.com/pytorch/FBGEMM/actions/runs/14775835150/job/41508826517?pr=1859 for example

/__w/FBGEMM/FBGEMM/bench/SparseDenseMMInt8Benchmark.cc:9:10: fatal error: bench/BenchUtils.h: No such file or directory

q10 avatar May 01 '25 21:05 q10

@ConnorBaker hate to ask, but any idea? Possibly something in this block but not 100%

# Ensure that we can include header files from the root directory.
target_include_directories(${TESTNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)

BwL1289 avatar May 01 '25 22:05 BwL1289

I probably won’t have a chance to look at this again until next week :(

ConnorBaker avatar May 02 '25 15:05 ConnorBaker

No worries! Thanks Connor.

BwL1289 avatar May 02 '25 15:05 BwL1289

@ConnorBaker FYI I opened a PR on your branch to attempt to fix the test CI errors.

BwL1289 avatar May 13 '25 16:05 BwL1289