Skip to content

[KernelGen][Nvidia] Add _fake_quantize_learnable_per_channel_affine_backward operator with Triton kernel - #5543

Open
chx7514 wants to merge 4 commits into
flagos-ai:masterfrom
chx7514:pr/_fake_quantize_learnable_per_channel_affine_backward
Open

[KernelGen][Nvidia] Add _fake_quantize_learnable_per_channel_affine_backward operator with Triton kernel#5543
chx7514 wants to merge 4 commits into
flagos-ai:masterfrom
chx7514:pr/_fake_quantize_learnable_per_channel_affine_backward

Conversation

@chx7514

@chx7514 chx7514 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Triton kernel for _fake_quantize_learnable_per_channel_affine_backward. Triton kernel implementation for _fake_quantize_learnable_per_channel_affine_backward,
the backward of learnable per-channel fake quantization. Computes the gradients
with respect to the input, scale and zero-point, accounting for the saturation
branch where the quantized value is clamped to [quant_min, quant_max].

Testing

  • Validated against reference on device via to_reference(inp, True)
  • Tested on: Nvidia, Tianshu, Muxi, Ascend, Hygon

Performance

Test command: pytest benchmark/test_fake_quantize_learnable_per_channel_affine_backward.py --level core (NVIDIA H20)

fake_quantize_learnable_per_channel_affine_backward

dtype Size Torch Latency (ms) Gems Latency (ms) Speedup
float32 [64, 1024] 0.074368 0.062336 1.193
float32 [1024, 64] 0.078336 0.072224 1.085
float32 [256, 512, 32] 0.144576 0.251744 0.574
float32 [128, 256, 128] 0.182240 0.246272 0.740
float32 [64, 1024] 0.071600 0.063520 1.127
float32 [4096, 4096] 0.309472 0.219392 1.411
float32 [16, 128, 64, 60] 0.254128 0.279744 0.908
float32 [1024, 1024] 0.076160 0.065024 1.171
Operator Geometric Mean Speedup
fake_quantize_learnable_per_channel_affine_backward 0.991

Multi-backend Testing

Backend Accuracy Test Speedup (mean) Notes
Nvidia (H20) PASS (8 cases) 0.991 Primary
Tianshu N/A
Muxi N/A
Ascend N/A
Hygon N/A

Files Changed

  • src/flag_gems/ops/_fake_quantize_learnable_per_channel_affine_backward.py: Triton kernel implementation
  • tests/test_fake_quantize_learnable_per_channel_affine_backward.py: Accuracy test
  • benchmark/test_fake_quantize_learnable_per_channel_affine_backward.py: Performance benchmark
  • src/flag_gems/ops/__init__.py: Register import and __all__
  • src/flag_gems/__init__.py: Register to _FULL_CONFIG
  • conf/operators.yaml: Add operator entry (kind: Math, stage: alpha 5.4)

@chx7514
chx7514 force-pushed the pr/_fake_quantize_learnable_per_channel_affine_backward branch from c27a739 to c2977a7 Compare August 17, 2026 06:58
@bin913

bin913 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

/test|_fake_quantize_learnable_per_channel_affine_backward:h20

…fine_backward

Signed-off-by: Dongxu-H <dxhan@baai.ac.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants