Skip to content

Conversation

windreamer
Copy link
Collaborator

@windreamer windreamer commented Jul 10, 2025

Motivation

Currently, the tubomind backend in lmdeploy requires a separate cmake build process and packaging before being included in the lmdeploy wheel package. Furthermore, a direct installation of the lmdeploy source package does not install the tubomind backend. This PR aims to simplify this process by leveraging cmake-build-extension to directly build and package the tubomind backend within the setup.py script, streamlining the build and installation process for users.

Modification

This PR integrates cmake-build-extension into the setup.py file. This allows us to directly call cmake during the setup.py execution to compile and package the tubomind backend. This eliminates the need for a separate build and packaging step, and ensures that the tubomind backend is installed when lmdeploy is installed, either from source or from a wheel.

Use cases

  • Simplified Installation: Users can now install lmdeploy and its tubomind backend with a single command: pip install lmdeploy.
  • Easier Development: Developers can build and test changes to both lmdeploy and tubomind more easily without having to manage separate build processes.
  • Consistent Installation: Ensures the tubomind backend is always installed when lmdeploy is installed, preventing potential runtime errors due to missing dependencies.

Checklist

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • The modification is covered by complete unit tests.
  • If the modification has a dependency on downstream projects of a newer version, this PR should be tested with all supported versions of downstream projects.
  • The documentation has been modified accordingly, like docstring or example tutorials. (Documentation updates will be added in a follow-up PR as this change is primarily focused on the build process.)

@windreamer windreamer requested review from lvhan028 and lzhangzz July 10, 2025 07:26
@windreamer windreamer force-pushed the setup_py_cmake branch 2 times, most recently from 25304ea to 4f0004d Compare July 10, 2025 09:36
@windreamer windreamer marked this pull request as draft July 10, 2025 09:39
@windreamer windreamer force-pushed the setup_py_cmake branch 2 times, most recently from 2dc538b to 5bbcbf6 Compare July 10, 2025 13:38
@windreamer windreamer marked this pull request as ready for review July 10, 2025 13:40
@windreamer windreamer force-pushed the setup_py_cmake branch 14 times, most recently from be6c1a6 to 1d27ee7 Compare July 11, 2025 07:30
@lvhan028 lvhan028 requested review from grimoire and irexyc July 14, 2025 03:58
@windreamer windreamer force-pushed the setup_py_cmake branch 6 times, most recently from efe4393 to b4f23bb Compare July 14, 2025 10:21
@irexyc
Copy link
Collaborator

irexyc commented Jul 15, 2025

The end of line sequence of cmake/yaml-cpp_cmake_policy.patch is CRLF, which may cause failures when applying a git patch on Windows

When I compile, I encounter this error, but it probably isn't caused by this pull request since the windows ci run success. It should be an issue with my environment. However, adding this compilation flag for MSVC can fix the error.

set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=/Zc:__cplusplus")

image

@windreamer
Copy link
Collaborator Author

The end of line sequence of cmake/yaml-cpp_cmake_policy.patch is CRLF, which may cause failures when applying a git patch on Windows

When I compile, I encounter this error, but it probably isn't caused by this pull request since the windows ci run success. It should be an issue with my environment. However, adding this compilation flag for MSVC can fix the error.

set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=/Zc:__cplusplus")

image

I ran into this issue as well. Here's what happened:

  • Turbomind relies on a library called yaml-cpp, but the version of yaml-cpp it uses requires an older version of CMake. This causes problems with modern CMake builds.
  • I tried updating yaml-cpp to the latest version, but that introduced another dependency called dragonbox which caused compilation errors on Windows with the Visual Studio toolchain.
  • My solution was to apply a patch that would force yaml-cpp to require a more recent CMake version. However, the patch failed because of differences in how Windows and Linux handle line endings (CRLF vs LF). I created the patch on Linux, and Windows couldn't apply it.
  • Ultimately, I fixed the issue by modifying the Windows CI build process to disable automatic line ending conversion in Git. This allowed the patch to be applied correctly on Windows. You can refer to
    - name: Set git for windows
    run: |
    git config --global core.autocrlf false
    git config --global core.eol lf
    git config --global core.longpaths true

I’m not sure if this is the best solution, and I’m open to suggestions.

@windreamer windreamer force-pushed the setup_py_cmake branch 3 times, most recently from a4de152 to e818a9e Compare July 15, 2025 11:03
@irexyc
Copy link
Collaborator

irexyc commented Jul 15, 2025

Tested on windows and found a git related issue. Setting git config --global core.longpaths true will fix it.

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(544,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\cx\AppData\Local\Temp\tmp4jrf2mvx.build-temp\Release__turbomind\_deps\repo-cutlass-subbuild\ZERO_CHECK.vcxproj]
  1>Checking Build System
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(544,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\cx\AppData\Local\Temp\tmp4jrf2mvx.build-temp\Release__turbomind\_deps\repo-cutlass-subbuild\repo-cutlass-populate.vcxproj]
  1>Creating directories for 'repo-cutlass-populate'
  Performing download step (git clone) for 'repo-cutlass-populate'
  Cloning into 'repo-cutlass-src'...
CUSTOMBUILD : error : unable to create file examples/68_hopper_fp8_warp_specialized_grouped_gemm_with_blockwise_scaling/68_hopper_fp8_warp_specialized_grouped_gemm_with_blockwise_scaling_with_sparse_groups.cu: Filename too long [C:\Users\cx\AppData\Local\Temp\tmp4jrf2mvx.build-temp\Release__turbomind\_deps\repo-cutlass-subbuild\repo-cutlass-populate.vcxproj]

@windreamer
Copy link
Collaborator Author

Tested on windows and found a git related issue. Setting git config --global core.longpaths true will fix it.


C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(544,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\cx\AppData\Local\Temp\tmp4jrf2mvx.build-temp\Release__turbomind\_deps\repo-cutlass-subbuild\ZERO_CHECK.vcxproj]

  1>Checking Build System

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(544,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\cx\AppData\Local\Temp\tmp4jrf2mvx.build-temp\Release__turbomind\_deps\repo-cutlass-subbuild\repo-cutlass-populate.vcxproj]

  1>Creating directories for 'repo-cutlass-populate'

  Performing download step (git clone) for 'repo-cutlass-populate'

  Cloning into 'repo-cutlass-src'...

CUSTOMBUILD : error : unable to create file examples/68_hopper_fp8_warp_specialized_grouped_gemm_with_blockwise_scaling/68_hopper_fp8_warp_specialized_grouped_gemm_with_blockwise_scaling_with_sparse_groups.cu: Filename too long [C:\Users\cx\AppData\Local\Temp\tmp4jrf2mvx.build-temp\Release__turbomind\_deps\repo-cutlass-subbuild\repo-cutlass-populate.vcxproj]

Yes, already fixed in ci.

@windreamer windreamer force-pushed the setup_py_cmake branch 7 times, most recently from e5bc5f5 to 29e953e Compare July 16, 2025 05:51
@lvhan028 lvhan028 merged commit 200d876 into InternLM:main Jul 16, 2025
9 checks passed
@windreamer windreamer deleted the setup_py_cmake branch July 17, 2025 06:48
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.

3 participants