[PR #41] [MERGED] Nibble Swizzle #98

Closed
opened 2026-10-26 22:20:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/41
Author: @contentis
Created: 5/20/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @comfyanonymous

Base: main ← Head: nibble_packing


📝 Commits (3)

  • bf16787 Add hi_first parameter to control FP4 nibble packing order
  • 4572ab0 remove sage artefact
  • df2b48f Merge branch 'main' into nibble_packing

📊 Changes

10 files changed (+314 additions, -96 deletions)

View changed files

📝 .gitignore (+1 -0)
📝 comfy_kitchen/__init__.py (+33 -18)
📝 comfy_kitchen/backends/cuda/__init__.py (+4 -0)
📝 comfy_kitchen/backends/cuda/dlpack_bindings.cpp (+8 -0)
📝 comfy_kitchen/backends/cuda/float_utils.cuh (+10 -5)
📝 comfy_kitchen/backends/cuda/ops/quantize_nvfp4.cu (+60 -52)
📝 comfy_kitchen/backends/eager/quantization.py (+17 -6)
📝 comfy_kitchen/backends/triton/quantization.py (+22 -6)
📝 comfy_kitchen/float_utils.py (+29 -9)
📝 tests/test_qdq.py (+130 -0)

📄 Description

NVFP4 requires two 4-bit values to be packed into an 8-bit container. When doing this there is ambiguity on the order of packing two values A,B in physical memory as either [A|B] or [B|A].

This PR adds the functionality to control this behaviour when running the Q/DQ and adds helpers to change the layout.


🔄 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/Comfy-Org/comfy-kitchen/pull/41 **Author:** [@contentis](https://github.com/contentis) **Created:** 5/20/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@comfyanonymous](https://github.com/comfyanonymous) **Base:** `main` ← **Head:** `nibble_packing` --- ### 📝 Commits (3) - [`bf16787`](https://github.com/Comfy-Org/comfy-kitchen/commit/bf167873b01b86de794c6496650e83c4b76a2af0) Add hi_first parameter to control FP4 nibble packing order - [`4572ab0`](https://github.com/Comfy-Org/comfy-kitchen/commit/4572ab09ed411acaf05fbe48f98c0f6d4b58b361) remove sage artefact - [`df2b48f`](https://github.com/Comfy-Org/comfy-kitchen/commit/df2b48f64022973692baf83a1bc752efb4a606b1) Merge branch 'main' into nibble_packing ### 📊 Changes **10 files changed** (+314 additions, -96 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) 📝 `comfy_kitchen/__init__.py` (+33 -18) 📝 `comfy_kitchen/backends/cuda/__init__.py` (+4 -0) 📝 `comfy_kitchen/backends/cuda/dlpack_bindings.cpp` (+8 -0) 📝 `comfy_kitchen/backends/cuda/float_utils.cuh` (+10 -5) 📝 `comfy_kitchen/backends/cuda/ops/quantize_nvfp4.cu` (+60 -52) 📝 `comfy_kitchen/backends/eager/quantization.py` (+17 -6) 📝 `comfy_kitchen/backends/triton/quantization.py` (+22 -6) 📝 `comfy_kitchen/float_utils.py` (+29 -9) 📝 `tests/test_qdq.py` (+130 -0) </details> ### 📄 Description NVFP4 requires two 4-bit values to be packed into an 8-bit container. When doing this there is ambiguity on the order of packing two values A,B in physical memory as either [A|B] or [B|A]. This PR adds the functionality to control this behaviour when running the Q/DQ and adds helpers to change the layout. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:20:22 +00:00
Sign in to join this conversation.
No labels
pull-request
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
Comfy-Org/comfy-kitchen#98
No description provided.