{
  "meta": {
    "title": "Locai Link vs Ollama: Gemma 4 CUDA benchmark",
    "date": "2026-06",
    "version": "1.0.0",
    "repository": "locai-link/bench/",
    "methodology_doc": "link-vs-ollama-benchmark-proposal.md",
    "notes": "Single-stream measurements only. One request in flight at a time per backend. Concurrent load was not measured. Results are specific to Arch Linux and the ollama-cuda Arch package; build steps and library paths differ on Ubuntu and RHEL."
  },
  "environment": {
    "os": "Arch Linux",
    "gpu": "NVIDIA RTX 4070",
    "vram_total_mib": 12288,
    "gpu_driver": "610.43.02",
    "cuda_version": "13.3",
    "compiler": "nvcc / g++-15"
  },
  "model": {
    "name": "Gemma 4",
    "variant": "E2B-it",
    "quantisation": "Q4_K_M",
    "parameters_billions": 4.6,
    "file_format": "GGUF",
    "file_size_gb": 2.9,
    "architecture_notes": "Sliding-window attention, shared KV layers"
  },
  "backends": {
    "locai_link": {
      "backend": "llama.cpp",
      "build": "b9222",
      "compute": "CUDA",
      "compiler_flags": "CUDAHOSTCXX=/usr/bin/g++-15, NVCC_PREPEND_FLAGS=-ccbin /usr/bin/g++-15",
      "api_endpoint": "/v1/chat/completions",
      "stream_protocol": "OpenAI-compatible SSE",
      "reasoning_off_via": "LLAMA_ARG_REASONING=off"
    },
    "ollama": {
      "package": "ollama-cuda",
      "source": "Arch package",
      "compute": "CUDA",
      "env_flags": "OLLAMA_LLM_LIBRARY=cuda_v13",
      "gpu_layers": 999,
      "api_endpoint": "/api/chat",
      "stream_protocol": "NDJSON",
      "reasoning_off_via": "think: false",
      "note": "OpenAI-compat endpoint (/v1/chat/completions) ignores think: false; native API used for this reason"
    }
  },
  "sampling": {
    "temperature": 0,
    "seed": 42,
    "top_p": 1,
    "streaming": true
  },
  "output_equivalence": {
    "verified": true,
    "method": "Token-identical replies at temperature=0 confirmed for all prompts across both backends"
  },
  "scenarios": {
    "conversation": {
      "description": "Short conversational prompt, mid-length reply",
      "prompt_tokens_approx": 30,
      "reply_tokens_approx": 300,
      "runs": 20,
      "warmup_requests": 3,
      "errors": 0,
      "results": {
        "locai_link": {
          "ttft_median_ms": 31,
          "ttft_p95_ms": 132,
          "prefill_toks_per_sec": 936,
          "decode_median_toks_per_sec": 196,
          "decode_p95_toks_per_sec": 198,
          "e2e_latency_median_s": 1.6,
          "peak_vram_mib": 4244,
          "peak_rss_mb": 5799
        },
        "ollama": {
          "ttft_median_ms": 326,
          "ttft_p95_ms": 338,
          "prefill_toks_per_sec": 92,
          "decode_median_toks_per_sec": 166,
          "decode_p95_toks_per_sec": 169,
          "e2e_latency_median_s": 2.1,
          "peak_vram_mib": 1990,
          "peak_rss_mb": 3022
        },
        "ratios": {
          "ttft_median": "Link 10.5x faster",
          "ttft_p95": "Link 2.6x faster",
          "prefill": "Link 10.2x faster",
          "decode_median": "Link 1.18x faster",
          "decode_p95": "Link 1.17x faster",
          "e2e_latency_median": "Link 1.3x faster",
          "peak_vram": "Ollama uses 2.2 GiB less",
          "peak_rss": "Ollama uses 2.8 GB less"
        }
      }
    },
    "document_analysis": {
      "description": "Long-context document prompt from 'From the Earth to the Moon', mid-length reply",
      "prompt_tokens_approx": 9500,
      "reply_tokens_max": 500,
      "runs": 10,
      "warmup_requests": 3,
      "errors": 0,
      "results": {
        "locai_link": {
          "ttft_median_ms": 56,
          "prefill_toks_per_sec": 169466,
          "decode_median_toks_per_sec": 174,
          "decode_p95_toks_per_sec": 178,
          "e2e_latency_median_s": 1.2,
          "peak_vram_mib": 4266,
          "peak_rss_mb": 6003
        },
        "ollama": {
          "ttft_median_ms": 385,
          "prefill_toks_per_sec": 24728,
          "decode_median_toks_per_sec": 158,
          "decode_p95_toks_per_sec": 160,
          "e2e_latency_median_s": 1.6,
          "peak_vram_mib": 2006,
          "peak_rss_mb": 3091
        },
        "ratios": {
          "ttft_median": "Link 6.9x faster",
          "prefill": "Link 6.9x faster",
          "decode_median": "Link 1.10x faster",
          "decode_p95": "Link 1.11x faster",
          "e2e_latency_median": "Link 1.3x faster",
          "peak_vram": "Ollama uses 2.2 GiB less",
          "peak_rss": "Ollama uses 2.9 GB less"
        }
      }
    }
  }
}
