Skip to content

Fix FP8 round-trip example on non-native GPUs - #498

Open
skyguan92 wants to merge 1 commit into
ROCm:amd-stagingfrom
skyguan92:fix/portable-fp8-roundtrip
Open

Fix FP8 round-trip example on non-native GPUs#498
skyguan92 wants to merge 1 commit into
ROCm:amd-stagingfrom
skyguan92:fix/portable-fp8-roundtrip

Conversation

@skyguan92

Copy link
Copy Markdown

Motivation

The FP8 example currently exits before launching its kernel unless the device is
gfx94x. Current HIP headers also provide host/device software conversion paths
when native FP8 conversion instructions are unavailable, so this excludes GPUs
that can execute the example correctly.

The round-trip validation also assigns raw __hip_fp8_storage_t bytes directly
to float. That compares the numeric value of the encoded byte instead of the
decoded FP8 value.

Technical Details

  • Decode FP8 storage through __hip_cvt_fp8_to_halfraw in a shared host/device
    helper.
  • Remove the obsolete gfx94x early exit while retaining the existing FNUZ
    selection for gfx94x and OCP E4M3 elsewhere.
  • Use size_t for the kernel index to remove the signed/unsigned warning.
  • Document the decode helper and the portable fallback behavior.

This change enables correctness coverage; it does not claim native FP8 hardware
acceleration on architectures such as gfx1100.

Test Plan

Test the exact commit on physical gfx1100, compare the unmodified baseline,
exercise both Make and CMake builds, validate the complete E4M3 raw-code space
plus a broad float corpus, trace the kernel dispatch, and compile the CI
architecture set.

Test Result

Tested on two independently selected AMD Radeon Pro W7900D devices (GPU 0 and
GPU 7) with ROCm 7.14.0 / HIP 7.14.60850 in
rocm/dev-ubuntu-24.04:7.14.0-full-amd64-digest-439edaa8.

  • Baseline: builds with a signed/unsigned warning, then prints Need a gfx94x
    and exits without launching the conversion kernel on both devices.
  • Patched Make build: warning-free and reports CPU and GPU round trip convert matches on both devices.
  • Patched CMake build: builds and reports the same passing result on both
    devices.
  • Independent HIP validation: all 256 E4M3 raw codes and 65,557 deterministic
    float inputs match between host and device on both devices. The known-value
    oracle also passes: 1.1 -> 0x39 -> 1.125.
  • rocprofv3 --kernel-trace records one
    float_to_fp8_to_float(..., unsigned long) dispatch with a 32-thread workgroup.
  • A -Wall -Wextra -Werror fat binary builds for the CI set: gfx908, gfx90a,
    gfx942, gfx950, gfx1030, gfx1100, gfx1101, gfx1200, and gfx1201.
  • clang-format 18, git diff --check, and markdownlint pass.

Added/Updated documentation?

  • Yes
  • No, does not apply to this PR.

Included Visual Studio files?

  • Yes
  • No, does not apply to this PR.

Submission Checklist

  • Existing CMake and Make integrations build the updated example.
  • No CI workflow change is needed; the example already participates in the
    HIP-Doc build.
  • No unsupported-ASIC guard is needed because the HIP header provides the
    portable conversion path used here.
  • Reviewed the repository and ROCm pull-request guidelines.

Decode raw FP8 storage through the HIP half conversion helper so the example validates numeric round trips instead of encoded byte values. Use the portable device conversion path on architectures without native FP8 instructions.

Signed-off-by: guanjiawei <128683929+skyguan92@users.noreply.github.com>
@skyguan92
skyguan92 requested review from a team as code owners August 13, 2026 17:39
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