Skip to content

NVFP4 Random Hadamard Transform (butterfly permutation-based)#509

Open
matthiasdiener wants to merge 35 commits intodevfrom
mdiener/fp4_hadamard
Open

NVFP4 Random Hadamard Transform (butterfly permutation-based)#509
matthiasdiener wants to merge 35 commits intodevfrom
mdiener/fp4_hadamard

Conversation

@matthiasdiener
Copy link
Copy Markdown
Contributor

@matthiasdiener matthiasdiener commented Mar 27, 2026

Description

Implements RHT via a butterfly permutation-based algorithm for NVFP4.

Has similar restrictions as upstream:

  • BF16 only
  • Transpose path only (no identity path)

Fixes https://github.com/ROCm/frameworks-internal/issues/15732

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@matthiasdiener matthiasdiener self-assigned this Mar 27, 2026
@matthiasdiener matthiasdiener added the ci-level 1 CI test level 1 label Mar 30, 2026
@matthiasdiener matthiasdiener changed the title [WIP] NVFP4 Hadamard NVFP4 Random Hadamard Transform (butterfly permutation-based) Mar 31, 2026
@matthiasdiener matthiasdiener marked this pull request as ready for review March 31, 2026 21:41
matthiasdiener and others added 6 commits March 31, 2026 18:51
* Update Dockerfile to use ROCm TheRock
* Update wheels building script to work with ROCm TheRock and the latest Manylinux image
* Support default ROCm location /opt/rocm/core
* Fix UB code build on TheRock
* Support comma separated list of target GPU architectures
* Guess ROCm build from HIP_PLATFORM
Co-authored-by: Ye Wang <yewang12@amd.com>

// Bit-cast __hip_bfloat16->uint16_t without address-of-temporary.
__device__ __forceinline__ uint16_t bf16_to_bits(__hip_bfloat16 v) {
uint16_t bits; __builtin_memcpy(&bits, &v, sizeof(uint16_t)); return bits;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__builtin_bit_cast ?

#ifndef TRANSFORMER_ENGINE_HADAMARD_TRANSFORM_H_
#define TRANSFORMER_ENGINE_HADAMARD_TRANSFORM_H_

#ifndef __HIP_PLATFORM_AMD__
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it now identical to upstream variant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-level 1 CI test level 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants