Skip to content

Add support for MLU kernelize - #700

Closed
atri2549 wants to merge 1 commit into
huggingface:mainfrom
atri2549:mlu-support
Closed

Add support for MLU kernelize#700
atri2549 wants to merge 1 commit into
huggingface:mainfrom
atri2549:mlu-support

Conversation

@atri2549

@atri2549 atri2549 commented Jul 8, 2026

Copy link
Copy Markdown

What does this PR do?

Adds runtime device support for Cambricon MLU accelerators to the kernels Python package and the kernels-data Rust library. This enables 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, passing device="mlu" to kernelize() raises ValueError: Unknown device type: mlu, preventing MLU users from participating in the kernel hub ecosystem. This follows the same pattern as PR #155 (NPU) and PR #285 (Neuron), adding runtime support for a third-party device.

Changes

Python (kernels/src/kernels/):

  • layer/repos.py — Added _MLURepos class and MLU branch in DeviceRepos.create_repo()
  • layer/kernelize.py — Added "mlu" to the _validate_device_type supported set
  • backends.py — Added MLU backend dataclass, parsing, and auto-detection via torch.mlu.device_count()
  • cli/benchmark.py — Added MLU backend display and device mapping

Rust (kernels-data/):

  • src/config/mod.rs — Added Backend::Mlu variant to canonical enum
  • src/config/v1.rsv5.rs — Added Mlu to all config versions' Backend enum and universal backends lists
  • bindings/python/src/lib.rs — Added Mlu to PyBackend enum (exposed as Backend.MLU in Python)

Tests (kernels/tests/):

  • conftest.py — Added has_mlu detection and mlu_only skip logic
  • pytest.ini — Registered mlu_only marker
  • test_layer.py — Added test_hub_forward_mlu() (allows fallback since no MLU kernels exist yet)
  • kernels-data/bindings/python/tests/test_kernels_data.py — Added MLU assertions for Backend.MLU

Configuration:

  • src/kernels/python_depends.json — Added empty "mlu": {} entry

Documentation:

  • nix-builder/README.md — Added MLU row to hardware support table (Tier 3)

Checklist

  • This PR is linked to an issue that was discussed and approved
  • I have tested these changes locally
  • New/changed functionality has test coverage
  • LLM disclosure:
    • I did not use an LLM to create this PR.
    • I used an LLM for assistance while creating this PR.
    • This PR was mostly or completely generated by an LLM.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Hi @atri2549, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/huggingface/kernels/blob/main/CONTRIBUTING.md for more details.

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.

1 participant