Skip to content

fix(quantization): round INT8 activations to nearest - #1474

Merged
gushiqiao merged 1 commit into
ModelTC:mainfrom
zjn20030811:fix/int8-quantization-rounding
Sep 4, 2026
Merged

fix(quantization): round INT8 activations to nearest#1474
gushiqiao merged 1 commit into
ModelTC:mainfrom
zjn20030811:fix/int8-quantization-rounding

Conversation

@zjn20030811

Copy link
Copy Markdown
Contributor

Summary

  • apply the sign-aware half-step while the scaled activation is still floating point
  • convert the complete rounded value to INT8 only afterward
  • cover positive, negative, and zero activation bins with a Triton interpreter regression

Problem

The current expression converts the +0.5 or -0.5 correction to INT8 before adding it. Both corrections become zero, so the later store truncates every fractional quantization bin toward zero. For a row whose absolute maximum is 1, values +0.5 and -0.5 consequently map to +63 and -63 instead of the nearest bins +64 and -64.

Keeping the correction in floating point until the final conversion restores symmetric round-to-nearest behavior and reduces activation quantization error without changing the scale calculation or kernel interface.

Verification

  • python test_cases/test_triton_int8_quantization.py -v (1 test passed)
  • ruff check --config pyproject.toml lightx2v/common/ops/mm/triton_kernels.py test_cases/test_triton_int8_quantization.py
  • ruff format --check --config pyproject.toml lightx2v/common/ops/mm/triton_kernels.py test_cases/test_triton_int8_quantization.py
  • python -m py_compile lightx2v/common/ops/mm/triton_kernels.py test_cases/test_triton_int8_quantization.py

@gushiqiao
gushiqiao merged commit 8984b7b into ModelTC:main Sep 4, 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.

2 participants