Skip to content

feat: bf16x2 packed arithmetic operations - #270

Closed
honeyspoon wants to merge 4 commits into
NVIDIA:mainfrom
honeyspoon:add-bf16x2-arith
Closed

honeyspoon wants to merge 4 commits into
NVIDIA:mainfrom
honeyspoon:add-bf16x2-arith

Conversation

@honeyspoon

Copy link
Copy Markdown
Contributor

Summary

  • Add 7 packed bf16x2 arithmetic operations: add, sub, mul, min, max, neg, abs
  • All ops use inline PTX assembly with =r,r,r (binary) or =r,r (unary) constraints
  • Full four-layer implementation: cuda-device stubs, dialect-nvvm ops, mir-importer translation, mir-lower PTX codegen

Closes #46
Part of #27

Details

Function PTX Mnemonic Operands SM Requirement
add_bf16x2(a, b) add.rn.bf16x2 binary sm_90+
sub_bf16x2(a, b) sub.rn.bf16x2 binary sm_90+
mul_bf16x2(a, b) mul.rn.bf16x2 binary sm_90+
min_bf16x2(a, b) min.bf16x2 binary sm_90+
max_bf16x2(a, b) max.bf16x2 binary sm_90+
neg_bf16x2(a) neg.bf16x2 unary sm_90+
abs_bf16x2(a) abs.bf16x2 unary sm_90+

Each u32 carries two packed bf16 values (low 16 bits = first lane, high 16 bits = second lane). The existing fma_bf16x2 (sm_80+) is unchanged.

Note: fma.rn.relu.bf16x2 is intentionally not included here (separate feature).

Test plan

  • cargo check -p dialect-nvvm -p mir-lower passes
  • cargo fmt --all clean
  • End-to-end GPU test on sm_90+ hardware (requires CUDA device)

Runs rustfmt, clippy, and unit tests on packages that don't need the
CUDA toolkit. Triggers on every push to PR branches.
Add quality gates beyond upstream CI to catch maintainer fixup patterns
before pushing PRs:

- rustdoc: build docs with -D warnings (catches bare bracket links)
- cargo-deny: dependency security and license checks
- style-checks job with diff-aware checks for:
  - em-dashes in doc comments (error)
  - bare brackets in doc comments (warning)
  - SPDX license headers on new files (error)
  - unnecessary &mut on pliron type getters (error)
  - float equality assertions (warning)
  - useless &vec![...] patterns (warning)

All style checks are diff-aware (only flag added lines, not pre-existing
upstream code).
ci: enhance fork CI with rustdoc, style checks, and cargo-deny
@honeyspoon

Copy link
Copy Markdown
Contributor Author

Opened against the wrong repo. Re-creating on honeyspoon/cuda-oxide.

@honeyspoon honeyspoon closed this Jun 22, 2026
@midagedev midagedev mentioned this pull request Sep 21, 2026
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