Skip to content

Add dequant operator (int32 → bfloat16) - #96

Closed
albiol2004 wants to merge 2 commits into
amd:develfrom
albiol2004:dequant-i32-bf16
Closed

albiol2004 wants to merge 2 commits into
amd:develfrom
albiol2004:dequant-i32-bf16

Conversation

@albiol2004

Copy link
Copy Markdown
Contributor

Added

  • aie_kernels/generic/dequant_i32_bf16.cc : C++ AIE kernel that converts int32 values to bfloat16 with per-group scale factor multiplication. Scales in float32 before final bf16 conversion for precision.
  • iron/operators/dequant_i32/ : Python operator (op.py, design.py, reference.py, test.py) following the existing dequant/ pattern.

Changed

Nothing. This is a new operator with no modifications to existing code.

Removed

Nothing.

Motivation

The INT8 GEMM operator (#93) produces int32 accumulators, but the rest of the inference pipeline (RMSNorm, SiLU, RoPE, residual adds) operates in bfloat16. This operator converts INT8 GEMM output back to
bfloat16, enabling end-to-end W8A8 quantized inference on the NPU.

Test results

  • 32/32 parametrized tests pass (input lengths 1K–8K, 1–8 columns, 1–2 channels)
  • Integration tested with Llama 3.2 1B dimensions (M=1 decode, M=32 prefill, K=2048, N=2048)
  • Max relative error vs CPU reference: 0.39% (hardware rounding differences in float32→bf16 conversion)
  • No regressions in existing dequant (int4→bf16) operator

Checklist

  • Tests pass locally
  • Code formatted (black + clang-format)
  • License headers on all files
  • No changes to existing code

Closes #95

  Add a dequantize operator that converts int32 GEMM accumulator outputs
  to bfloat16 with per-group scale factor multiplication. This is needed
  to use INT8 GEMM (amd#93) output in the rest of the inference pipeline.

  - C++ kernel: int32 → float32 (scale in float32) → bfloat16
  - Python operator following existing dequant/ pattern
  - 32 parametrized tests (1-8 columns, 1-2 channels, 1K-8K elements)
Align operator directory name with the kernel file convention
(dequant_i32_bf16.cc). The existing dequant (int4→bf16) and quantize
operators use incomplete type suffixes; this rename establishes the
full input_output naming pattern.
@albiol2004

Copy link
Copy Markdown
Contributor Author

Very sub optimal too

@albiol2004 albiol2004 closed this Apr 10, 2026
Soket1 pushed a commit to Soket1/IRON-windows that referenced this pull request Jul 20, 2026
- depth=4 weight buffers (A0..A3) exceed 16-lock cap (all locks used)
- L1 memory at 31.7KB > AIE2P tile capacity → compile fails silently
- Real expanded ping-pong needs MemTile-level prefetch (512KB SRAM)
- Reverted to proven depth=2 (A0/A1) baseline at 29.2 t/s
- Cache key restored to _mc_preq_vexp (no _dp4 suffix)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Add dequantize operator (int32 → bfloat16)

1 participant