Repository navigation
Add opt-in wide INT4 M1 GEMV with uint8 zero points - #34212
Draft
Selena Yang (selenayang888) wants to merge 1 commit into
Draft
Selena Yang (selenayang888) wants to merge 1 commit into
Selena Yang (selenayang888) wants to merge 1 commit into
Conversation
This was referenced Nov 13, 2026
Comment on lines
+223
to
+227
| #define M1_WIDE_DISPATCH_ZP(BS) \ | ||
| if (zero_points != nullptr) { \ | ||
| M1_WIDE_DISPATCH_COLS(BS, true) \ | ||
| } else { \ | ||
| M1_WIDE_DISPATCH_COLS(BS, false) \ |
Contributor
There was a problem hiding this comment.
Suggested change
| #define M1_WIDE_DISPATCH_ZP(BS) \ | |
| if (zero_points != nullptr) { \ | |
| M1_WIDE_DISPATCH_COLS(BS, true) \ | |
| } else { \ | |
| M1_WIDE_DISPATCH_COLS(BS, false) \ | |
| #define M1_WIDE_DISPATCH_ZP(BS) \ | |
| if (zero_points != nullptr) { \ | |
| M1_WIDE_DISPATCH_COLS(BS, true) \ | |
| } else { \ | |
| M1_WIDE_DISPATCH_COLS(BS, false) \ |
| const dim3 grid((warps + kWarpsPerBlock - 1) / kWarpsPerBlock); | ||
| const dim3 block(kWarpsPerBlock * 32); | ||
|
|
||
| #define M1_WIDE_LAUNCH(BS, ZP, C) \ |
Contributor
There was a problem hiding this comment.
Suggested change
| #define M1_WIDE_LAUNCH(BS, ZP, C) \ | |
| #define M1_WIDE_LAUNCH(BS, ZP, C) \ |
This was referenced Nov 15, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. This branch applies the iteration's files onto
mainf4cd337; it has not yet been built, tested or measured at this head. Numbers below come from the frozen staged runtimes described under Known Limitations.Summary
Previous PR: none; this is the first PR in the series. The B0 baseline is reported below and was not opened as a separate PR.
Series: B0 baseline → #34212 wide GEMV (this PR) → #34213 cuDNN guard → #34214 XQA idle CTAs → #34215 chunked prefill.
Companion: ORT #33728 supplies the wide INT8 kernel included in every accumulated configuration from iteration 1 on.
Performance: Qwen3.5-2B
Accumulated package/runtime results, not isolated gains from this PR. Baseline = B0: rt-base (ORT main 2bf400a), all switches off, decoder capture off. Optimized = #34212 (with #33728's INT8 kernel): rt-it1, wide INT4 + wide INT8 switches on, decoder capture off. Change = Optimized decode relative to Baseline (first table) or llama.cpp (second table). The increment over the previous PR and isolated controls follow each GPU's tables; prefill is reported separately.
A100-SXM4-80GB
Baseline:
a100-review-B0; optimized:a100-review-it1w48.Same optimized series versus llama.cpp
a100-review-llama(identical input IDs, same rounds):B0→it1w4): decode +7.03% to +7.36%, TTFT -0.54% to -0.01%; decode regressions at tokens: none.H200
Baseline:
h200-review-B0; optimized:h200-review-it1w48.Same optimized series versus llama.cpp
h200-review-llama(identical input IDs, same rounds):B0→it1w4): decode +6.22% to +7.87%, TTFT +0.01% to +1.08%; decode regressions at tokens: none.Shared-host medians are descriptive, not statistical significance; negative rows are kept. Small increments must be remeasured on an isolated rebased PR head.
Controls And Configuration
Optimized: rt-it1 with ORT_MATMUL_NBITS_4BIT_M1_WIDE=1 and ORT_MATMUL_NBITS_8BIT_M1_WIDE=1, capture off, versus rt-base B0. INT4-only control: rt-it1 with only the INT4 switch. Both switches default off. The INT8 switch exists only with #33728's kernel; remeasure after rebasing on it, or report INT4-only numbers if it is not merged.
Published Qwen3.5-2B VLM package v4: 172 INT4 and 15 INT8 MatMulNBits projections, block128/uint8 zero points. FP16 KV, FPA1, context 8192, batch 1, eight CPU threads pinned to 32-39. A100 physical GPU 2; H200 physical GPU 1. llama.cpp uses Q4_K_M, CUDA graphs, flash attention and FP16 KV. Quantization/quality are not asserted equivalent.
Fresh unique-source workload: token prefixes 128/512/2048/4096/7680 of benchmark_src/16384-cache-capacity-diagnostics.txt (text SHA256 3496ea55dead1c0ca9cd72aa6b1ff4bfcfca4433262a228d193a33885d33c49d). Actual token counts/hashes come from the model tokenizer, not the manifest's historical API counts. Both engines consume identical input IDs. Exactly 128 generated tokens; fresh generator, no prefix reuse, tokenization and generator creation excluded. Two warmups + five measurements x three rotating rounds; medians of 15 measured requests per row. TTFT is synchronized native GenAI, not HTTP. Decode uses 127 first-to-last intervals. This is a new workload; do not combine it with historical repeated-seed rows.
Known Limitations
Historical combined w48 strict checks pass only 4/50 positions. The fresh H200 INT4-only prompt-512 outputs diverge after 113 matching generated tokens in all 15 measurements. Task quality of either switch set is unmeasured. Coordinate the INT4 extension with #33728 before any competing PR; the accumulated table includes #33728's INT8 contribution and does not isolate this kernel.
The staged runtime binaries are frozen experiments, not benchmarks of a newly split/rebased PR head. B0 is source-built ORT baseline 2bf400a, not the published wheel or Foundry service. Full revision/build pinning, corresponding llama.cpp per-benchmark quality, CPU performance, padded/multimodal coverage and agreed RAM/VRAM budgets remain outstanding. Shared-host median ratios are descriptive; no statistical-significance, cross-GPU scaling or service-level win is claimed.
Review required: retain draft status and default-off numerical optimizations. Do not promote from these timings alone; resolve the iteration-specific failures and every WORK.md gate below.
Quality Results
Use the same evaluation inputs/protocol and compute 100 * max(0, 1 - candidate_score / llama_score); require strictly less than 1 for each benchmark. This report does not transfer scores from other exports or models.