Skip to content

Commit 5821ea7

Browse files
authored
docs: refresh skill notes to match latest Gemma4 state
1 parent 59de1f5 commit 5821ea7

3 files changed

Lines changed: 22 additions & 24 deletions

File tree

‎.agents/skills/multimodal-models/SKILL.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,25 +285,26 @@ If the model dtype is already f32, no Cast is needed.
285285

286286
Models with KV-shared layers (e.g. Gemma4) borrow key/value from
287287
earlier source layers instead of projecting their own. With GQA
288-
(PR #279), shared layers use `GroupQueryAttention` with:
288+
(`onnxruntime/mobius#279`), shared layers use `GroupQueryAttention` with:
289289

290-
- `key=None` (empty, `kv_sequence_length=0`)
290+
- `key=None` (empty current K, i.e. `new_kv_length=0`)
291291
- `value=None` (empty)
292292
- `past_key=source_layer_present_key` (borrowed from source)
293293
- `past_value=source_layer_present_value` (borrowed from source)
294-
- `do_rotary=1` (RoPE applied to queries; source K already has RoPE)
294+
- `do_rotary=1` (RoPE applied to queries; borrowed source K is already RoPE-rotated)
295295

296296
This eliminates ~40 Transpose/Reshape ops per shared layer that
297297
were previously needed to convert the source KV from BNSH
298298
`[B, kv_heads, seq, head_dim]` to 3D `[B, seq, kv_hidden]` format.
299299

300-
**Caveat:** Requires ORT to support `kv_sequence_length=0` in the
301-
GQA op. Tracked in microsoft/onnxruntime#28318.
300+
This relies on ORT GQA support for empty current K/V (`new_kv_length=0`,
301+
represented in graph wiring as empty key/value tensors with
302+
`kv_sequence_length=0`).
302303

303304
## Vision preprocessing: float-domain bicubic resize
304305

305-
For HF parity in vision preprocessing, ort-extensions provides a
306-
float-domain bicubic resize (PR #1056) that avoids uint8 clamping
306+
For HF parity in vision preprocessing, `microsoft/onnxruntime-extensions#1056`
307+
provides a float-domain bicubic resize that avoids uint8 clamping
307308
artifacts. This eliminates 0.03-0.13 pixel differences that can
308309
cause token divergence in vision encoders. The utility operates in
309310
packed RGB with fused uint8→float rescale.

‎.agents/skills/onnx-export-quantization/SKILL.md‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,18 +389,14 @@ than requiring exact numerical matches.
389389

390390
## Inference speed: Q4_K_M vs NF4
391391

392-
Benchmark with Gemma4 E2B-IT on GenAI (text-only, 50+ token decode):
393-
394-
| Dtype | CUDA tok/s | CPU tok/s | Notes |
395-
|-------|-----------|----------|-------|
396-
| F16 | 104 | 6.8 | Baseline |
397-
| Q4_K_M | 111 (+8%) | 16.2 (+138%) | **Recommended** |
398-
| NF4 | 93 (-10%) | 4.0 (-41%) | Slower than F16 |
392+
For the benchmark table, use the canonical reference in
393+
`.agents/skills/profiling-onnx-models/SKILL.md` ("Quantization benchmark
394+
reference (Gemma4 E2B-IT)").
399395

400396
**Q4_K_M is recommended over NF4** for both speed and quality:
401-
- Faster on both CPU (+138% vs F16) and CUDA (+8% vs F16)
402-
- NF4 is paradoxically *slower* than F16 on both EPs
403-
- Quality is comparable between Q4_K_M and NF4
397+
- Faster on both CPU and CUDA than F16 in the referenced measurement
398+
- NF4 is slower than F16 in the same measurement
399+
- Quality is comparable between Q4_K_M and NF4 in spot checks
404400
- Q4_K_M uses less memory than F16 (~4x compression)
405401

406402
## Cross-references

‎.agents/skills/profiling-onnx-models/SKILL.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ larger head dimensions (e.g. Gemma4 global attention with
214214

215215
**Gemma4 Flash Attention note:** Flash Attention gives only 1-3%
216216
benefit for Gemma4. With float attention masks (KV-shared layers),
217-
only 7/35 layers are eligible for Flash. With all-GQA (PR #279),
217+
only 7/35 layers are eligible for Flash. With all-GQA (`onnxruntime/mobius#279`),
218218
25/35 layers become eligible but the `head_dim=512` global layers
219219
still cannot use Flash. The performance impact is minimal because
220220
global attention layers dominate compute.
@@ -374,19 +374,20 @@ A thorough benchmark varies these dimensions independently:
374374
6. **Measure GenAI throughput** — tok/s is the user-facing metric
375375
7. **Check GPU utilization** — `nvidia-smi` during inference
376376

377-
## Quantization benchmark reference (Gemma4 E2B)
377+
## Quantization benchmark reference (Gemma4 E2B-IT)
378378

379379
Measured with Gemma4 E2B-IT on GenAI (text-only, 50+ token decode):
380380

381381
| Dtype | CUDA tok/s | CPU tok/s | Notes |
382382
|-------|-----------|----------|-------|
383383
| F16 | 104 | 6.8 | Baseline |
384-
| Q4_K_M | 111 (+8%) | 16.2 (+138%) | **Recommended** — best speed, no quality loss |
385-
| NF4 | 93 (-10%) | 4.0 (-41%) | Slower than F16 on both EPs |
384+
| Q4_K_M | 111 (+7%) | 16.2 (+138%) | **Recommended** — best speed, no observed quality regression in spot checks |
385+
| NF4 | 93 (-11%) | 4.0 (-41%) | Slower than F16 on both EPs |
386386

387-
**Recommendation:** Q4_K_M wins on both CPU and CUDA with no measurable
388-
quality degradation. NF4 is slower than even F16 and should be avoided
389-
for inference speed. Use Q4_K_M as the default quantization format.
387+
**Recommendation:** Q4_K_M wins on both CPU and CUDA with no observed
388+
quality regression in spot checks. NF4 is slower than even F16 in this
389+
measurement and should be avoided for inference speed. Use Q4_K_M as
390+
the default quantization format.
390391

391392
## Cross-references
392393

0 commit comments

Comments
 (0)