@@ -181,8 +181,9 @@ data transfer. Common culprits:
181181- ` ConstantOfShape ` with unusual dtypes
182182
183183** Fix:** See the ` debugging-memcpy ` skill for root-cause analysis and
184- fix patterns. The most impactful fix is usually lowering opset version
185- or replacing unsupported ops with CUDA-friendly alternatives.
184+ fix patterns. The correct fix is to update ORT kernel registration for
185+ the missing opset versions (e.g. Equal opset 19 CUDA gap). As a
186+ secondary option, replace unsupported ops with CUDA-friendly alternatives.
186187
187188### 2. cuBLAS warmup spike
188189
@@ -279,6 +280,83 @@ print(f"Throughput: {num_tokens/decode_time:.1f} tok/s")
279280| cuBLAS warmup | ~ 40 ms (first step only) |
280281| Steady-state decode | ~ 66 µs per MatMul |
281282
283+ ## Benchmark methodology
284+
285+ ### Benchmark dimensions
286+
287+ A thorough benchmark varies these dimensions independently:
288+
289+ #### 1. Pipeline (inference framework)
290+
291+ | Pipeline | Description |
292+ | ----------| -------------|
293+ | ORT standalone CUDA | Raw ORT ` InferenceSession ` with CUDA EP |
294+ | GenAI CUDA | Full ` onnxruntime-genai ` pipeline with CUDA |
295+ | GenAI CPU | Full ` onnxruntime-genai ` pipeline, CPU only |
296+ | HF PyTorch CUDA | HuggingFace ` transformers ` baseline (GPU) |
297+ | HF PyTorch CPU | HuggingFace ` transformers ` baseline (CPU) |
298+
299+ #### 2. Model dtype
300+
301+ | Dtype | Notes |
302+ | -------| -------|
303+ | F16 | Default for GPU inference |
304+ | BF16 | Better numerical range, Ampere+ GPUs |
305+ | F32 | CPU inference, reference baseline |
306+ | Q4_K_M | INT4 k-quant (Olive) |
307+ | NF4 | INT4 NormalFloat (Olive) |
308+
309+ #### 3. Execution provider variant
310+
311+ | EP | Attention kernel | Notes |
312+ | ----| -----------------| -------|
313+ | ` default ` | ONNX Attention → MEA | Portable, no vendor fusions |
314+ | ` cuda ` | GQA rewrite → hybrid GQA/Attention | Best CUDA perf for simple models |
315+ | ` onnx-standard ` | Inlined functions → standard ops | Strict ONNX-only |
316+
317+ #### 4. Input modality
318+
319+ | Modality | Example |
320+ | ----------| ---------|
321+ | Text only | Standard LLM prompt |
322+ | Image + text | VLM with image input |
323+ | Audio + text | ALM with speech input |
324+ | Image + audio + text | Multimodal (e.g. Gemma4) |
325+
326+ #### 5. Metrics
327+
328+ | Metric | Description |
329+ | --------| -------------|
330+ | ** Decode tok/s** | Tokens per second AFTER first token |
331+ | ** TTFT** | Time to first token — includes encoder + prefill |
332+ | ** VRAM** | GPU memory usage (` nvidia-smi ` ) |
333+ | ** Model size** | On-disk size of ONNX + weights |
334+
335+ #### 6. Additional dimensions (for thorough studies)
336+
337+ | Dimension | Values |
338+ | -----------| --------|
339+ | Cache type | Static cache vs dynamic cache |
340+ | Prompt length | Short (20), medium (500), long (2000+ tokens) |
341+ | Batch size | 1, 4, 8 |
342+ | Padding strategy | ` nonpad_kv_seqlens ` vs ` attention_mask ` |
343+ | KV buffer | ` past_present_share_buffer ` : true vs false |
344+
345+ ### Best practices
346+
347+ - ** One session, one build:** Run ALL benchmarks in a single session
348+ with the SAME ORT/GenAI build to ensure comparability.
349+ - ** Warm up:** Run 2-3 inference calls before timing to amortize
350+ cuBLAS JIT compilation and CUDA context setup.
351+ - ** Record the build:** Report which ORT/GenAI commit or version was
352+ used — results are not reproducible across builds.
353+ - ** Separate TTFT from decode:** TTFT includes encoder + prefill
354+ overhead. Decode throughput measures steady-state generation.
355+ - ** Sufficient output length:** Generate 50+ tokens to amortize TTFT
356+ and get stable decode throughput numbers.
357+ - ** Control for GPU state:** Avoid running other GPU workloads during
358+ benchmarks. Check ` nvidia-smi ` for baseline memory usage.
359+
282360## Debugging workflow
283361
2843621 . ** Profile the model** with ORT session profiling
0 commit comments