1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[PR #28] [MERGED] Fix support for MXFP4 quantized models with Triton tensors #242

Closed
opened 2026-11-01 04:19:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/p-e-w/heretic/pull/28
Author: @tymat
Created: 11/20/2025
Status: ✅ Merged
Merged: 11/20/2025
Merged by: @p-e-w

Base: master ← Head: fix-mxfp4-triton-tensor-support


📝 Commits (1)

  • ecd7ffd Fix support for MXFP4 quantized models with Triton tensors

📊 Changes

1 file changed (+5 additions, -0 deletions)

View changed files

📝 src/heretic/model.py (+5 -0)

📄 Description

Problem

When loading models with MXFP4 quantization (e.g., openai/gpt-oss-20b), heretic fails with:

KeyError: 'mlp.down_proj'

This occurs because the transformers library uses Triton tensors for MXFP4 quantized weights, and torch.is_tensor() returns False for them, causing the assertion in try_add() to fail.

Solution

Extract the underlying PyTorch tensor via the .data attribute when encountering Triton tensors. The .data attribute contains a regular PyTorch tensor that supports all required operations (.device, .sub_(), matrix multiplication).

Testing

  • Tested with openai/gpt-oss-20b
  • Model loads successfully and recognizes both attn.o_proj and mlp.down_proj components
  • Maintains compatibility with non-quantized models

Environment

  • PyTorch 2.9.1+cu130
  • transformers 4.57.1
  • triton 3.5.1
  • kernels 0.11.0

Fixes loading MXFP4 quantized models while maintaining backward compatibility.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/p-e-w/heretic/pull/28 **Author:** [@tymat](https://github.com/tymat) **Created:** 11/20/2025 **Status:** ✅ Merged **Merged:** 11/20/2025 **Merged by:** [@p-e-w](https://github.com/p-e-w) **Base:** `master` ← **Head:** `fix-mxfp4-triton-tensor-support` --- ### 📝 Commits (1) - [`ecd7ffd`](https://github.com/p-e-w/heretic/commit/ecd7ffd8bcd67727ae36f29b6b6c886aeca75232) Fix support for MXFP4 quantized models with Triton tensors ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/heretic/model.py` (+5 -0) </details> ### 📄 Description ## Problem When loading models with MXFP4 quantization (e.g., `openai/gpt-oss-20b`), heretic fails with: ``` KeyError: 'mlp.down_proj' ``` This occurs because the `transformers` library uses Triton tensors for MXFP4 quantized weights, and `torch.is_tensor()` returns `False` for them, causing the assertion in `try_add()` to fail. ## Solution Extract the underlying PyTorch tensor via the `.data` attribute when encountering Triton tensors. The `.data` attribute contains a regular PyTorch tensor that supports all required operations (`.device`, `.sub_()`, matrix multiplication). ## Testing - Tested with `openai/gpt-oss-20b` - Model loads successfully and recognizes both `attn.o_proj` and `mlp.down_proj` components - Maintains compatibility with non-quantized models ## Environment - PyTorch 2.9.1+cu130 - transformers 4.57.1 - triton 3.5.1 - kernels 0.11.0 Fixes loading MXFP4 quantized models while maintaining backward compatibility. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 04:19:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#242
No description provided.