Skip to content

feat: add packed cvt variants end-to-end example (sm_80+) - #281

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
honeyspoon:upstream-cvt-packed-example
Jun 28, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
honeyspoon:upstream-cvt-packed-example

Conversation

@honeyspoon

@honeyspoon honeyspoon commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #276 -- adds the sm_80+ end-to-end GPU example that was noted as still owed.

  • Adds crates/rustc-codegen-cuda/examples/cvt_packed/ with a single kernel that exercises all five packed cvt intrinsics (cvt_f16x2_f32, cvt_rz_f16x2_f32, cvt_rn_relu_f16x2_f32, cvt_rn_relu_bf16x2_f32, cvt_rz_bf16x2_f32) on the same (3.14, -2.5) inputs
  • Host unpacks each u32 result via manual f16/bf16 bit decoding and verifies:
    • rn (round-to-nearest): both lanes approximate the input values
    • rz (round-toward-zero): both lanes approximate inputs with |result| <= |input|
    • relu variants: positive lane preserved, negative lane clamped to 0.0
  • Includes sm_80+ guard with early-return on older GPUs
  • Follows the same structure as the existing cvt_f16x2 example

Part of #274

Test plan

  • cargo oxide run cvt_packed on an sm_80+ (Ampere or later) GPU
  • Verify all 5 variants print correct values and the example exits with SUCCESS
  • Verify the example gracefully skips on sm_7x and below

@honeyspoon
honeyspoon force-pushed the upstream-cvt-packed-example branch from ee1e57a to 20a8fc5 Compare June 24, 2026 13:34
honeyspoon and others added 2 commits June 28, 2026 08:26
Follow-up to NVIDIA#276, adds the GPU-verified example noted as owed.
Tests cvt.rz, cvt.rn.relu for both f16x2 and bf16x2, verifying
ReLU clamps negatives to zero and rz truncates toward zero.

Part of NVIDIA#274

Signed-off-by: abder <[email protected]>
@nihalpasham
nihalpasham force-pushed the upstream-cvt-packed-example branch from 20a8fc5 to a9aa9bd Compare June 28, 2026 03:12
@nihalpasham nihalpasham added enhancement New feature or request intrinsics Device intrinsics and libdevice math mappings cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) tests Adds or improves test coverage examples Example kernels and host harnesses under crates/rustc-codegen-cuda/examples labels Jun 28, 2026
@nihalpasham
nihalpasham merged commit 576f1e6 into NVIDIA:main Jun 28, 2026
26 checks passed
@nihalpasham

Copy link
Copy Markdown
Collaborator

Thank you for following through with the packed-conversion GPU example. Keeping all five variants in one kernel makes their lane behavior easy to compare.

I added a few small finishing touches on the branch:

  • made the expected packed values bit-exact so nearest and toward-zero rounding cannot pass for one another;
  • added the missing canonical-NaN check for the ReLU variants;
  • added the standalone lockfile and cleaned up the example build.

The corrected sm_80 output contains all five expected instructions and is accepted by ptxas.

@honeyspoon
honeyspoon deleted the upstream-cvt-packed-example branch June 30, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) enhancement New feature or request examples Example kernels and host harnesses under crates/rustc-codegen-cuda/examples intrinsics Device intrinsics and libdevice math mappings tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants