Skip to content

finegrained-kernels: accept MX scale bytes without native UE8M0 - #1238

Open
IlyasMoutawwakil wants to merge 7 commits into
mainfrom
finegrained-ue8m0-compat
Open

IlyasMoutawwakil wants to merge 7 commits into
mainfrom
finegrained-ue8m0-compat

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Accept existing uint8 MX scale bytes when PyTorch lacks torch.float8_e8m0fnu. Guard optional dtype access in format detection and forward/backward paths, while retaining the native dtype's zero-copy byte view.

Native GitHub stack #1244: #1238 (this PR) → #1239 (quantized embeddings). Review and merge bottom to top.

Correct shared scale decoding for UE8M0 byte 0 (2^-127) and byte 255 (NaN). Use typing.List only at custom-op schema boundaries that older PyTorch requires.

Validation: the missing-dtype regression uses monkeypatch; a compact Triton regression checks eight exponent bytes, including both boundaries, with a cold cache. Both passed. Ruff and diff checks passed. The missing-dtype test simulates that condition on the installed PyTorch.

Related issue

Requested by a maintainer for huggingface/transformers#49658.

Checklist

  • Linked to a discussed issue
  • Tested locally
  • New/changed functionality has test coverage
  • Mostly or completely generated with an LLM

@github-actions

Copy link
Copy Markdown

This PR changes source code for the following kernel(s): finegrained-kernels.

If you have the kernel-bot build permissions, then trigger /kernel-bot build finegrained-kernels yourself. Otherwise, a maintainer will review the PR and will take an appropriate action. Thanks for your patience.

@github-actions github-actions Bot added the chore Version bumps, releases, misc maintenance label Oct 16, 2026


import os
from typing import List

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.

torch op registration on older torch versions didn't accept annotating with list

@IlyasMoutawwakil
IlyasMoutawwakil added this pull request to stack #1244 October 18, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Version bumps, releases, misc maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant