Skip to content

Fix pin for pytorch, build CPU, GPU kernels - #132

Merged
weiji14 merged 5 commits into
conda-forge:mainfrom
isuruf:ops
Nov 6, 2026
Merged

weiji14 merged 5 commits into
conda-forge:mainfrom
isuruf:ops

Conversation

@isuruf

@isuruf isuruf commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

Previously CPU packages didn't have any compiled kernels and the GPU packages had only CPU kernels compiled in and no GPU kernels compiled.

… 2026.11.02.15.51.50

Other tools:
- conda-build 26.3.0
- rattler-build 0.74.0
- rattler-build-conda-compat 1.4.19
@conda-forge-admin

Copy link
Copy Markdown
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe/recipe.yaml) and found it was in an excellent condition.

- Force DS_ACCELERATOR=cuda in CUDA builds. Without a GPU on CI, DeepSpeed
  fell back to the CPU accelerator, so the CUDA packages shipped no CUDA
  kernels. Skip cutlass_ops/ragged_device_ops (need deepspeed-kernels) and
  evoformer_attn (needs CUTLASS); add libcufile-dev for gds; use ninja.
- Skip deepspeed_ccl_comm in all variants and drop oneccl-devel.
- Patch fp_quantizer so nvcc doesn't reject redeclaring a template
  parameter, keeping the semantics nvcc 12 compiled.
- Generalise the ops test to cpu/cuda and set DS_ACCELERATOR explicitly
  (osx-arm64 would otherwise pick mps).
@isuruf isuruf changed the title Fix pin for pytorch, build CPU kernels Fix pin for pytorch, build CPU, GPU kernels Nov 4, 2026
@isuruf

isuruf commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@conda-forge/deepspeed, this is ready

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @isuruf, I haven't been using deepspeed for a long while, so good to have someone make sure things are built correctly (instead of me just pushing buttons when CI is green). Just a couple of questions for now, would appreciate it if @loadams (actual DeepSpeed dev) gives this a proper review, and maybe consider getting some of the patches here upstreamed.

Comment thread recipe/build.sh
Comment on lines +52 to +65
# The op builders default to -march=native and pick SIMD intrinsics from the
# build machine's CPU flags. Use portable settings instead (see patch 0001).
# Leave -march to the compiler flags from conda-forge's activation scripts.
export DS_CPU_ARCH=""
case ${target_platform} in
linux-64)
# conda-forge's x86_64 baseline has no AVX, so use the scalar code path
export DS_SIMD_WIDTH="-D__SCALAR__"
;;
linux-aarch64|osx-arm64)
# NEON is part of the AArch64 baseline
export DS_SIMD_WIDTH="-D__NEON__"
;;
*)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should microarch levels be declared then on this feedstock? Also, are you forcing scalar instructions always on x86_64, instead of letting Deespeed's simd_width() function pick which SIMD instructions to build for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'll leave it to another PR

Comment on lines +9 to +13
+ # Allow packagers to override the detected CPU architecture flag so that
+ # pre-compiled ops are not tied to the build machine (-march=native).
+ # An empty value means no -march/-mcpu flag is added.
+ if os.environ.get("DS_CPU_ARCH") is not None:
+ return os.environ["DS_CPU_ARCH"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on why this override is needed? We're not doing cross-compilation to linux-aarch64 (yet), and as far as I'm aware, the osx-arm64 CI builds should be on native hardware?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-march=native makes the build depend on the build machine. If the build machine had avx512, we would get one. This removes -march=native because of that.

@weiji14

weiji14 commented Nov 5, 2026

Copy link
Copy Markdown
Member

One more comment. ds_report on the CPU builds look ok, mostly YESes (compared to all NOs in last week's build), e.g. at https://github.com/conda-forge/deepspeed-feedstock/actions/runs/41900411813/job/126820978756?pr=132#step:5:8789:

 │ [2026-11-04 19:58:57,056] [WARNING] [real_accelerator.py:213:get_accelerator] Setting accelerator to CPU. If you have GPU or other accelerator, we were unable to detect it.
 │ --------------------------------------------------
 │ DeepSpeed C++/CUDA extension op report
 │ --------------------------------------------------
 │ NOTE: Ops not installed will be just-in-time (JIT) compiled at
 │       runtime if needed. Op compatibility means that your system
 │       meet the required dependencies to JIT install the op.
 │ --------------------------------------------------
 │ JIT compiled ops requires ninja
 │ ninja .................. [OKAY]
 │ --------------------------------------------------
 │ op name ................ installed .. compatible
 │ --------------------------------------------------
 │ deepspeed_not_implemented  [YES] ...... [OKAY]
 │  [WARNING]  async_io requires the dev libaio .so object and headers but these were not found.
 │  [WARNING]  async_io: please install the libaio-devel package with yum
 │  [WARNING]  If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
 │ async_io ............... [YES] ...... [NO]
 │ deepspeed_ccl_comm ..... [NO] ....... [OKAY]
 │ deepspeed_shm_comm ..... [YES] ...... [OKAY]
 │ cpu_adagrad ............ [YES] ...... [OKAY]
 │ cpu_adam ............... [YES] ...... [OKAY]
 │ cpu_lion ............... [YES] ...... [OKAY]
 │ fused_adam ............. [YES] ...... [OKAY]
 │ pin_memory ............. [YES] ...... [OKAY]
 │ --------------------------------------------------
 │ DeepSpeed general environment info:
 │ torch install path ............... ['$SRC_DIR_run_env/lib/python3.14/site-packages/torch']
 │ torch version .................... 2.14.1
 │ deepspeed install path ........... ['$SRC_DIR_run_env/lib/python3.14/site-packages/deepspeed']
 │ deepspeed info ................... 0.19.9, 755995d, HEAD
 │ deepspeed wheel compiled w. ...... torch 2.14 
 │ shared memory (/dev/shm) size .... 64.00 MB

but on the GPU CI, they show up as NO (unsure if it's because there's no GPU on CI), https://github.com/conda-forge/deepspeed-feedstock/actions/runs/41900411813/job/126820978864?pr=132#step:5:13056:

 │ + ds_report
 │ [2026-11-04 20:24:16,729] [WARNING] [real_accelerator.py:213:get_accelerator] Setting accelerator to CPU. If you have GPU or other accelerator, we were unable to detect it.
 │ W1104 20:24:17.450000 3326 site-packages/torch/utils/cpp_extension.py:183] No CUDA runtime is found, using CUDA_HOME='$SRC_DIR_run_env'
 │ --------------------------------------------------
 │ DeepSpeed C++/CUDA extension op report
 │ --------------------------------------------------
 │ NOTE: Ops not installed will be just-in-time (JIT) compiled at
 │       runtime if needed. Op compatibility means that your system
 │       meet the required dependencies to JIT install the op.
 │ --------------------------------------------------
 │ JIT compiled ops requires ninja
 │ ninja .................. [OKAY]
 │ --------------------------------------------------
 │ op name ................ installed .. compatible
 │ --------------------------------------------------
 │ deepspeed_not_implemented  [NO] ....... [OKAY]
 │  [WARNING]  async_io requires the dev libaio .so object and headers but these were not found.
 │  [WARNING]  async_io: please install the libaio-devel package with yum
 │  [WARNING]  If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
 │ async_io ............... [NO] ....... [NO]
 │ deepspeed_ccl_comm ..... [NO] ....... [OKAY]
 │ deepspeed_shm_comm ..... [NO] ....... [OKAY]
 │ cpu_adagrad ............ [NO] ....... [OKAY]
 │ cpu_adam ............... [NO] ....... [OKAY]
 │ cpu_lion ............... [NO] ....... [OKAY]
 │ fused_adam ............. [NO] ....... [OKAY]
 │ pin_memory ............. [NO] ....... [OKAY]
 │ --------------------------------------------------
 │ DeepSpeed general environment info:
 │ torch install path ............... ['$SRC_DIR_run_env/lib/python3.14/site-packages/torch']
 │ torch version .................... 2.14.1
 │ deepspeed install path ........... ['$SRC_DIR_run_env/lib/python3.14/site-packages/deepspeed']
 │ deepspeed info ................... 0.19.9, 755995d, HEAD
 │ deepspeed wheel compiled w. ...... torch 2.14 
 │ shared memory (/dev/shm) size .... 64.00 MB

I should probably test this locally on my GPU, but just want to point this out in case it's helpful.

@isuruf

isuruf commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

@weiji14, this is what I get from a machine with a CUDA GPU

 │ --------------------------------------------------
 │ DeepSpeed C++/CUDA extension op report
 │ --------------------------------------------------
 │ NOTE: Ops not installed will be just-in-time (JIT) compiled at
 │       runtime if needed. Op compatibility means that your system
 │       meet the required dependencies to JIT install the op.
 │ --------------------------------------------------
 │ JIT compiled ops requires ninja
 │ ninja .................. [OKAY]
 │ --------------------------------------------------
 │ op name ................ installed .. compatible
 │ --------------------------------------------------
 │ async_io ............... [YES] ...... [OKAY]
 │ fused_adam ............. [YES] ...... [OKAY]
 │ cpu_adam ............... [YES] ...... [OKAY]
 │ cpu_adagrad ............ [YES] ...... [OKAY]
 │ cpu_lion ............... [YES] ...... [OKAY]
 │ pin_memory ............. [YES] ...... [OKAY]
 │ dc ..................... [YES] ...... [OKAY]
 │  [WARNING]  Unable to locate CUTLASS. Install nvidia-cutlass, clone CUTLASS next to DeepSpeed, or set CUTLASS_P
 │ ATH to the CUTLASS checkout.
 │ evoformer_attn ......... [NO] ....... [NO]
 │ fp_quantizer ........... [YES] ...... [OKAY]
 │ fused_lamb ............. [YES] ...... [OKAY]
 │ fused_lion ............. [YES] ...... [OKAY]
 │ gds .................... [YES] ...... [NO]
 │ transformer_inference .. [YES] ...... [OKAY]
 │ inference_core_ops ..... [YES] ...... [OKAY]
 │ cutlass_ops ............ [NO] ....... [OKAY]
 │ utils .................. [YES] ...... [OKAY]
 │ transformer ............ [YES] ...... [OKAY]
 │ quantizer .............. [YES] ...... [OKAY]
 │ spatial_inference ...... [YES] ...... [OKAY]
 │ ragged_device_ops ...... [NO] ....... [OKAY]
 │ ragged_ops ............. [YES] ...... [OKAY]
 │ random_ltd ............. [YES] ...... [OKAY]
 │ stochastic_transformer . [YES] ...... [OKAY]
 │ --------------------------------------------------
 │ DeepSpeed general environment info:
 │ torch install path ............... ['$SRC_DIR_run_env/lib/python3.14/site-packages/torch']
 │ torch version .................... 2.14.1
 │ deepspeed install path ........... ['$SRC_DIR_run_env/lib/python3.14/site-packages/deepspeed']
 │ deepspeed info ................... 0.19.9, 465abda, main
 │ torch cuda version ............... 12.9
 │ torch hip version ................ None
 │ nvcc version ..................... 12.9
 │ deepspeed wheel compiled w. ...... torch 2.14, cuda 12.9
 │ shared memory (/dev/shm) size .... 125.78 GB

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weiji14, this is what I get from a machine with a CUDA GPU

Cool, I can verify this locally on my end too (building on CUDA 13)

Details
$ ds_report
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
      runtime if needed. Op compatibility means that your system
      meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [FAIL]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
 [WARNING]  async_io requires the dev libaio .so object and headers but these were not found.
 [WARNING]  async_io: please install the libaio-dev package with apt
 [WARNING]  If libaio is already installed (perhaps from source), try setting the CFLAGS and LDFLAGS environment variables to where it can be found.
async_io ............... [YES] ...... [NO]
fused_adam ............. [YES] ...... [OKAY]
cpu_adam ............... [YES] ...... [OKAY]
cpu_adagrad ............ [YES] ...... [OKAY]
cpu_lion ............... [YES] ...... [OKAY]
pin_memory ............. [YES] ...... [OKAY]
dc ..................... [YES] ...... [OKAY]
 [WARNING]  Unable to locate CUTLASS. Install nvidia-cutlass, clone CUTLASS next to DeepSpeed, or set CUTLASS_PATH to the CUTLASS checkout.
evoformer_attn ......... [NO] ....... [NO]
fp_quantizer ........... [YES] ...... [OKAY]
fused_lamb ............. [YES] ...... [OKAY]
fused_lion ............. [YES] ...... [OKAY]
/home/weiji/mambaforge/envs/temp/bin/x86_64-conda-linux-gnu-ld: cannot find -lcufile: No such file or directory
collect2: error: ld returned 1 exit status
gds .................... [YES] ...... [NO]
transformer_inference .. [YES] ...... [OKAY]
inference_core_ops ..... [YES] ...... [OKAY]
cutlass_ops ............ [NO] ....... [OKAY]
utils .................. [YES] ...... [OKAY]
transformer ............ [YES] ...... [OKAY]
quantizer .............. [YES] ...... [OKAY]
spatial_inference ...... [YES] ...... [OKAY]
ragged_device_ops ...... [NO] ....... [OKAY]
ragged_ops ............. [YES] ...... [OKAY]
random_ltd ............. [YES] ...... [OKAY]
stochastic_transformer . [YES] ...... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/home/user/mambaforge/envs/temp/lib/python3.14/site-packages/torch']
torch version .................... 2.14.1
deepspeed install path ........... ['/home/user/mambaforge/envs/temp/lib/python3.14/site-packages/deepspeed']
deepspeed info ................... 0.19.9, 465abda, ops
torch cuda version ............... 13.4
torch hip version ................ None
nvcc version ..................... 13.5
deepspeed wheel compiled w. ...... torch 2.14, cuda 13.4
shared memory (/dev/shm) size .... 15.52 GB

and have also tested the output of $ python recipe/test_ops.py cuda:

installed_ops: {'async_io': 1, 'fused_adam': 1, 'cpu_adam': 1, 'cpu_adagrad': 1, 'cpu_lion': 1, 'pin_memory': 1, 'dc': 1, 'evoformer_attn': False, 'fp_quantizer': 1, 'fused_lamb': 1, 'fused_lion': 1, 'gds': 1, 'transformer_inference': 1, 'inference_core_ops': 1, 'cutlass_ops': False, 'utils': 1, 'transformer': 1, 'quantizer': 1, 'spatial_inference': 1, 'ragged_device_ops': False, 'ragged_ops': 1, 'random_ltd': 1, 'stochastic_transformer': 1}
torch_info: {'version': '2.14', 'bf16_support': False, 'cuda_version': '13.4', 'nccl_version': '2.32', 'hip_version': '0.0'}
loaded async_io
loaded cpu_adagrad
loaded cpu_adam
loaded cpu_lion
loaded dc
loaded fp_quantizer
loaded fused_adam
loaded fused_lamb
loaded fused_lion
loaded gds
loaded inference_core_ops
loaded pin_memory
loaded quantizer
loaded ragged_ops
loaded random_ltd
loaded spatial_inference
loaded stochastic_transformer
loaded transformer
loaded transformer_inference
loaded utils

Thanks again for applying the fixes and adding tests too! I'll merge this in now 🚀

@weiji14
weiji14 merged commit 2aec137 into conda-forge:main Nov 6, 2026
19 checks passed
@sdvillal sdvillal mentioned this pull request Nov 19, 2026
8 of 10 tasks
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.

3 participants