Skip to content

SOFIE_quantization Full Library v0 - #53

Open
shaunlee8 wants to merge 31 commits into
gpu/alpakafrom
quantize-v2
Open

SOFIE_quantization Full Library v0#53
shaunlee8 wants to merge 31 commits into
gpu/alpakafrom
quantize-v2

Conversation

@shaunlee8

Copy link
Copy Markdown
Collaborator

An end-to-end quantized inference pipeline for SOFIE code generation. Support for ONNX quantized graphs, to self-contained generated headers, to low-precision execution. Structured as an installable codegen pass (SOFIE_quantization) over the existing core.

Frontend:

  • ONNX QDQ: QuantizeLinear / DequantizeLinear boundary pairs
  • QONNX: Quant custom ops

Data Types:

  • INT8/UINT8 affine: symmetric and asymmetric, per-tensor and per-channel weights, INT32 accumulation
  • FP8 E4M3/E5M2 with scale, FP16 carriers for movement

Operators:

  • GEMM/MatMul: fused inter-layer requantization and activations
  • Convolution: im2col, depthwise, per-channel weights
  • Gather, Elementwise, movement ops (Transpose/Reshape/...)

Execution:

  • cuBLASLt INT8 and FP8 paths with fused epilogues
  • Region detection: boundary recognition, expanded region formation through value-preserving ops, node elimination rule ladder

Pipeline:

  • Per-family passes (RQuantization_*Pass.cxx), RQuantization_*.cxx find regions where everything between a dequantize and a quantize can run directly on the codes (raw stored numbers, int or fp bit patterns). Regions grow through value-preserving ops, absorb activations, and detect boundaries between neighboring regions so chained layers requantize in place. Node elimination rules target leftover quantized ops.
  • Each region becomes a lowering plan (RQuantization_Lowering.hxx) where operand quantization metadata lives in QuantizedOperandContract (INT8, FP8, etc.) and QuantizationGrid which maps codes to values.

shaunlee8 added 30 commits June 30, 2026 08:45

@sanjibansg sanjibansg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ran a first review pass, couple of comments.

#ifndef SOFIE_RQUANTIZATION_ALPAKA_DENSE_LINEAR_COMMON
#define SOFIE_RQUANTIZATION_ALPAKA_DENSE_LINEAR_COMMON

// cuBLASLt scaffolding both dense-linear precisions sit on: owned handles, layouts, heuristic

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we instead interface this to sofieBLAS with guards to prevent anything else other than cuda? this way later when we support other architectures we just remove the guard and keeps the quantized SOFIE portable as well. This would need corresponding changes in sofieBLAS to support the CUDA primitives we have here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would keep the quantized models in a dedicated sub-dir.

Comment thread test/CoreStandsAlone.cxx

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is this test needed?

Comment thread core/src/RWeightFile.cxx

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this include any I/O operations different from what we already have?

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.

2 participants