Skip to content

Gemma 4 Benchmark Reproduction & Olive Eval Integration Plan #285

Description

@justinchuby

Gemma 4 Benchmark Reproduction & Olive Eval Integration Plan

1. Gemma 4 Benchmark Suite

Google evaluates Gemma 4 across 14 benchmarks spanning text, vision, audio,
and long context. All scores below are from the
Gemma 4 model card on HuggingFace
for instruction-tuned variants with thinking enabled.

1.1 Text — Language Understanding & Reasoning

Benchmark What it measures Metric 31B 26B MoE (4B active) E4B E2B Gemma 3 27B
MMLU Pro Multi-domain knowledge (harder than MMLU) Accuracy % 85.2 82.6 69.4 60.0 67.6
GPQA Diamond Graduate-level science QA Accuracy % 84.3 82.3 58.6 43.4 42.4
BigBench Extra Hard Diverse hard reasoning tasks Accuracy % 74.4 64.8 33.1 21.9 19.3
MMMLU Multilingual MMLU Accuracy % 88.4 86.3 76.6 67.4 70.7
HLE no tools Humanity's Last Exam (no tools) Accuracy % 19.5 8.7
HLE with search Humanity's Last Exam (with search) Accuracy % 26.5 17.2

1.2 Text — Math & Reasoning

Benchmark What it measures Metric 31B 26B MoE (4B active) E4B E2B Gemma 3 27B
AIME 2026 no tools Competition math (AMC/AIME) Accuracy % 89.2 88.3 42.5 37.5 20.8
Tau2 (avg over 3) Mathematical reasoning Accuracy % 76.9 68.2 42.2 24.5 16.2

1.3 Text — Coding

Benchmark What it measures Metric 31B 26B MoE (4B active) E4B E2B Gemma 3 27B
LiveCodeBench v6 Live coding challenges Pass rate % 80.0 77.1 52.0 44.0 29.1
Codeforces ELO Competitive programming ELO rating 2150 1718 940 633 110

1.4 Vision (Multimodal)

Benchmark What it measures Metric 31B 26B MoE (4B active) E4B E2B Gemma 3 27B
MMMU Pro Multimodal understanding (images) Accuracy % 76.9 73.8 52.6 44.2 49.7
OmniDocBench 1.5 Document understanding Avg edit dist (↓) 0.131 0.149 0.181 0.290 0.365
MATH-Vision Math with visual diagrams Accuracy % 85.6 82.4 59.5 52.4 46.0
MedXPertQA MM Medical multimodal QA Accuracy % 61.3 58.1 28.7 23.5

1.5 Audio (E2B/E4B only)

Benchmark What it measures Metric E4B E2B
CoVoST Speech translation BLEU 35.54 33.47
FLEURS ASR across languages WER (↓) 0.08 0.09

1.6 Long Context

Benchmark What it measures Metric 31B 26B MoE (4B active) E4B E2B
MRCR v2 8-needle 128k Multi-needle retrieval in 128k ctx Accuracy % 66.4 44.1 25.4 19.1

2. Reproduction Plan

2.1 Available via lm-evaluation-harness

Gemma Benchmark lm-eval-harness task Status Notes
MMLU Pro mmlu_pro ✅ Available Standard task
GPQA Diamond gpqa_diamond ✅ Available Requires agree to ToS
BigBench Extra Hard bbh ✅ Available BIG-Bench Hard subset
MMMLU mmmlu (or mmlu with translation) ⚠️ Partial May need multilingual config
MATH-Vision ❌ Not available Multimodal (image+text)
MMMU Pro ❌ Not available Multimodal

2.2 Require custom evaluation scripts

Benchmark Reason Effort
AIME 2026 New dataset, possibly private test set Medium — need dataset access
LiveCodeBench v6 Code execution sandbox required High — needs sandboxed exec
Codeforces ELO Competitive programming, execution required High
HLE Requires tool/search integration High
Tau2 Newer benchmark, limited public eval infra Medium
OmniDocBench 1.5 Document images + edit distance metric Medium
MedXPertQA MM Medical multimodal, requires images Medium
MRCR v2 128k Long context, custom prompt construction Medium
CoVoST / FLEURS Audio input + speech eval metrics Medium

2.3 Multimodal benchmarks (require image/audio input)

These CANNOT be run with text-only lm-eval-harness:

  • MMMU Pro, MATH-Vision, OmniDocBench 1.5, MedXPertQA MM (vision)
  • CoVoST, FLEURS (audio)

They require either:

2.4 Hardware requirements

Benchmark type GPU memory Runtime estimate
Text (31B, fp16) 64GB+ (H100/A100) 2-8h per benchmark
Text (E2B, fp16) 8GB (RTX 4090) 30min-2h per benchmark
Vision (31B) 80GB (H100) 4-12h per benchmark
Long context 128k 80GB (H100) 8-24h
Audio 16GB 1-4h

3. Olive Eval Integration Design

3.1 Current Olive eval architecture

Olive integrates lm-evaluation-harness via two model backends:

  1. LMEvalORTEvaluator (registered as "ort") — Wraps an ONNX model
    with ORT InferenceSession. Implements _loglikelihood_tokens() by
    running the decoder model directly. Handles KV cache, tokenization,
    and batching internally. generate_until is not implemented.

  2. LMEvalORTGenAIEvaluator (registered as "ortgenai") — Wraps an
    ORT-GenAI model directory. Uses onnxruntime_genai for inference.
    Has access to og.Generator but generate_until is not implemented
    (inherits NotImplementedError from base class).

Both extend LMEvalOnnxBaseTemplateLM from lm-eval-harness.
Text loglikelihood tasks (MMLU, GPQA, BBH) work out of the box.
Generation tasks (GSM8K, HumanEval) do NOT work until generate_until
is implemented.

Olive config format:

{
  "evaluators": {
    "gemma4_eval": {
      "type": "LMEvaluator",
      "tasks": ["mmlu_pro", "gpqa_diamond", "bbh"],
      "model_class": "ortgenai",
      "batch_size": 1,
      "limit": 100
    }
  }
}

3.2 Mapping Gemma 4 benchmarks to Olive evaluators

Benchmark Olive evaluator Model class Ready?
MMLU Pro LMEvaluator(tasks=["mmlu_pro"]) ortgenai ✅ Yes
GPQA Diamond LMEvaluator(tasks=["gpqa_diamond"]) ortgenai ✅ Yes
BBH LMEvaluator(tasks=["bbh"]) ortgenai ✅ Yes
MMMLU LMEvaluator(tasks=["mmmlu"]) ortgenai ⚠️ Check task name
AIME 2026 Custom evaluator needed ❌ No
LiveCodeBench Custom evaluator + sandbox ❌ No
Codeforces Not feasible (external system) ❌ No
HLE Custom evaluator + tools ❌ No
MMMU Pro New multimodal evaluator needed ❌ No
MATH-Vision New multimodal evaluator needed ❌ No
OmniDocBench New multimodal evaluator needed ❌ No
CoVoST/FLEURS New audio evaluator needed ❌ No
MRCR 128k Custom evaluator (long ctx) ❌ No

3.3 Gaps: What Olive needs

Gap 1: No multimodal evaluator. Olive's LMEvalORTEvaluator and
LMEvalORTGenAIEvaluator only handle text input. Vision benchmarks
(MMMU, MATH-Vision) need image inputs piped through the vision encoder
pipeline before reaching the decoder.

Proposed design:

class LMEvalVLMEvaluator(LMEvalOnnxBase):
    """Evaluator for vision-language models via ORT GenAI."""
    
    def model_call(self, input_ids, images=None):
        # Use og.MultiModalProcessor for image preprocessing
        # Run vision encoder → embedding → decoder pipeline
        pass

Gap 2: generate_until not implemented. Some Gemma 4 benchmarks
(AIME, LiveCodeBench) require free-form generation + answer extraction,
not just loglikelihood scoring. Both LMEvalORTEvaluator and
LMEvalORTGenAIEvaluator inherit generate_until from LMEvalOnnxBase
which raises NotImplementedError (verified in
lmeval_ort.py:192).
The ortgenai class has og.Generator available but doesn't wire it
to generate_until yet. This blocks any lm-eval-harness task that uses
the generate_until request type (e.g. gsm8k, humaneval).

Gap 3: No long-context support. The 128k MRCR benchmark requires handling
256k-token context windows. KV cache memory management becomes critical.

3.4 Proposed workflow: ONNX vs PyTorch comparison

# Step 1: Build ONNX model with mobius
python -m mobius build google/gemma-4-e2b-it --dtype f16 --output gemma4-e2b-f16

# Step 2: Run PyTorch baseline with lm-eval-harness
lm_eval --model hf \
  --model_args pretrained=google/gemma-4-e2b-it \
  --tasks mmlu_pro,gpqa_diamond,bbh \
  --batch_size 1 \
  --output_path results/pytorch/

# Step 3: Run ONNX model with Olive LMEvaluator
olive eval \
  --model gemma4-e2b-f16/ \
  --evaluator LMEvaluator \
  --tasks mmlu_pro,gpqa_diamond,bbh \
  --model_class ortgenai \
  --output results/onnx/

# Step 4: Compare
python compare_results.py results/pytorch/ results/onnx/

Acceptance criteria: ONNX results within ±1% of PyTorch baseline on
all text benchmarks. Larger deviations indicate quantization error or
graph construction bugs.


4. Priority Ranking

Tier 1: Run immediately (text-only, lm-eval-harness)

These give the best signal for ONNX model quality with zero custom code:

Priority Benchmark Why Runtime (E2B)
P0 MMLU Pro Broad knowledge, standard benchmark ~1h
P0 GPQA Diamond Graduate-level reasoning ~30min
P1 BBH Diverse hard reasoning ~2h
P1 MMMLU Multilingual coverage ~3h

Rationale: These 4 benchmarks cover the widest range of capabilities
with the least setup effort. Any ONNX graph error (wrong attention mask,
incorrect KV cache, numerical drift) will show up as a score drop vs
the PyTorch baseline.

Tier 2: Important but needs effort

Priority Benchmark Blocker
P2 MMMU Pro Needs multimodal evaluator (vision)
P2 MATH-Vision Same as MMMU Pro
P2 AIME 2026 Needs generation-based eval + dataset

Rationale: Vision benchmarks are critical for validating the
3-model VLM pipeline (vision encoder → embedding → decoder). AIME
validates reasoning capability.

Tier 3: Nice to have

Priority Benchmark Blocker
P3 LiveCodeBench Sandbox execution environment
P3 CoVoST/FLEURS Audio pipeline eval
P3 MRCR 128k Long context memory management
P3 OmniDocBench Document image processing
P4 Codeforces External platform, not reproducible
P4 HLE Requires tool integration

5. Recommended Next Steps

  1. Immediate: Run MMLU Pro + GPQA Diamond on Gemma4 E2B ONNX
    (via Olive LMEvaluator with ortgenai) and compare to PyTorch HF
    baseline. This validates the ONNX decoder graph end-to-end.

  2. Short-term: Investigate lmms-eval for vision benchmark support.
    It already has MMMU and MATH-Vision tasks with multimodal input
    handling.

  3. Medium-term: Build LMEvalVLMEvaluator in Olive that wraps
    ORT GenAI multimodal pipeline for vision evaluations.

  4. Track: Google's Gemma 4 technical report (not yet published as
    of this research) will likely include additional benchmark details
    and evaluation methodology.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions