Add support for MLU kernelize

Open
#701 7 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, pytorch, rust

Research direction

Compare the runtime patterns in PR #155 and PR #285, then inspect the Python package under kernels/ and the Rust bindings in kernels-data/. Run the proposed mlu_only tests, including test_hub_forward_mlu(), and review the benchmark CLI and nix-builder/README.md hardware table. Done means MLU detection, validation, backend bindings across config versions, tests, CLI support, and documentation are covered.

Written by the indexing model from the issue text.

Description

Summary

I'd like to propose adding runtime device support for Cambricon MLU accelerators to the kernels Python package. This would follow the same pattern as PR #155 (NPU) and PR #285 (Neuron), enabling the kernels library to recognize, route, and load kernels targeting MLU hardware.

Motivation

Cambricon MLU is a custom AI accelerator used in several production environments. Currently, attempting to use kernelize() with an MLU device raises: ValueError: Unknown device type: mlu. This prevents MLU users from participating in the kernel hub ecosystem, even when using MLU-compatible kernels registered via register_kernel_mapping().

Proposed scope

Runtime support only — this PR would not touch kernel-builder or nix-builder. Specifically:

  • kernels/ Python package: _MLURepos class, MLU backend detection via torch.mlu.device_count(), device validation, benchmark CLI support
  • kernels-data/ Rust library: Backend::Mlu variant across all config versions (v1–v5) and Python bindings (Backend.MLU)
  • Tests: mlu_only pytest marker, test_hub_forward_mlu() (with fallback allowance since no MLU kernels exist in kernels-community yet)
  • Documentation: update nix-builder/README.md hardware support table (Tier 3, same as NPU/Neuron)

References

Looking forward to your feedback!

Dominant language
Python
Stars
781
Forks
141
Avg merge
1d 10h
Merged PRs (30d)
57

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from huggingface/kernels

All issues in huggingface/kernels

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.