Feat/support block quant#862
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
1009dbd to
98d6c8f
Compare
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly advances the framework's quantization capabilities by introducing robust support for block quantization. It integrates specialized kernels for efficient blockwise matrix multiplication, particularly optimized for TPU execution. The changes also provide more granular control over quantization settings through extended configuration options, enabling users to specify block sizes and exclude specific layers from quantization. This enhancement is crucial for optimizing the performance and memory footprint of large language models and MoE architectures. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
c70a952 to
c3e5734
Compare
|
@Bob-Chen222 Please help review this pr. |
d1e6ff7 to
9df8bf3
Compare
9df8bf3 to
cdfba68
Compare
Squashed from PR #862 (feat/support_block_quant) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment was marked as resolved.
This comment was marked as resolved.
be236f6 to
785aafb
Compare
- Add expand_block_scale() in blockwise_utils.py with channel_to_block extensibility for future non-uniform block quant support - Update kernel.py to detect pre-expanded 3D scale (ndim==3) instead of compact 2D scale, removing runtime convert_block_scale_to_kernel_layout - Update QuantizedLinear to pre-expand scale at init time (both static and dynamic paths in from_linear, plus auto-expand in __init__) - Add _maybe_expand_linear_block_scale() in weight_utils.py to convert 2D checkpoint scale to 3D kernel-ready layout at load time - Remove redundant _normalize_scale_for_gmm() calls from EPMoE.__call__ since scales are already in correct 4D format from quantize_weights() or _maybe_convert_epmoe_scale_for_kernel() 2. Fix test to use pre-expanded 3D scale for kernel API The xla_quantized_matmul_local kernel now expects pre-expanded 3D scale [in_blocks, 1, n_out] instead of compact 2D [out_blocks, in_blocks]. Update the direct kernel test to call expand_block_scale before invoking the kernel. 3. Restore _normalize_scale_for_gmm as safety net in EPMoE.__call__ The normalize call is cheap for already-4D scales (just validation) and handles edge cases where callers bypass quantize_weights() and directly set 2D/3D scale params. The real perf win is in the linear layer where jnp.repeat was inside shard_map on every step.
785aafb to
0f532a4
Compare
This comment was marked as resolved.
This comment was marked as resolved.
c2682dd to
f926266
Compare
Squashed from PR #862 (feat/support_block_quant)
Motivation
Add block-wise quantization support from TPU inference, with coverage for both dense Linear layers and EPMoE.
Closes #879
Modifications
jnp.repeat) from runtime to init/load time for better inference performanceAccuracy Tests
This PR will not effects for existing non-quantized model or channel-wise kernel. And add test List into CI about:
python/sgl_jax/test/kernels/quantized_linear_test.pypython/sgl_jax/test/kernels/moe_block_quant_test.pypython/sgl_jax/test/test_linear_tp.pytest/srt/test_moe_block_quant_e2e.pytest/srt/quantization/test_w8_block_dynamic_quantization.pytest/srt/quantization/test_w8_moe_block_linear_channel_quantization.pyQwen3-30B-A3B (
tp=4, ep=4)Linear per-channel + MoE block)Linear per-channel + MoE block)Qwen3-8B (
tp=4)Benchmarking and Profiling
Hardware: TPU v6e-4
Benchmark tool:
bench_one_batch_server.py(single-batch offline, input_len=4096, output_len=1024)Server config: precompilation enabled
Qwen3-8B BF16 (
tp=4)Qwen3-8B INT8 block dynamic (
tp=4)Config:
int8_block_128_dynamic.yamlQwen3-30B-A3B BF16 (
tp=4, ep=4)Qwen3-30B-A3B INT8 mixed (
tp=4, ep=4)Config:
int8_moe_block_128_linear_channel_dynamic.yaml(Linear per-channel + MoE block)Key Observations
Checklist