<!--
Copyright 2025 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<!--
This file is used to generate a comprehensive list of on_device_model
histograms along with a detailed description for each histogram.
-->

<histogram-configuration>

<histograms>

<variants name="InputSource">
  <variant name="" summary="Input provided directly by the user."/>
  <variant name=".ModelFeedback"
      summary="Input that is the model's own output from a previous turn."/>
</variants>

<variants name="OnDeviceModelExecutionFeature">
  <variant name="" summary="all features"/>
  <variant name=".ScamDetection" summary="Scam Detection"/>
</variants>

<histogram name="OnDeviceModel.Android.GenerateResult{ModelExecutionFeature}"
    enum="OnDeviceModelAndroidGenerateResult" expires_after="2026-09-13">
  <owner>ssid@chromium.org</owner>
  <owner>xinghuilu@chromium.org</owner>
  <summary>
    Records the result of generate on Android for {ModelExecutionFeature}.
    Logged exactly once when a generate request has completed.
  </summary>
  <token key="ModelExecutionFeature" variants="OnDeviceModelExecutionFeature"/>
</histogram>

<histogram
    name="OnDeviceModel.Android.IsModelDownloadSuccessful{ModelExecutionFeature}"
    enum="BooleanSuccess" expires_after="2026-10-25">
  <owner>ssid@chromium.org</owner>
  <owner>xinghuilu@chromium.org</owner>
  <summary>
    Records whether the on-device model download was successful on Android for
    {ModelExecutionFeature}. Logged exactly once when a download request has
    completed.
  </summary>
  <token key="ModelExecutionFeature" variants="OnDeviceModelExecutionFeature"/>
</histogram>

<histogram
    name="OnDeviceModel.Android.ModelDownloadFailureReason{ModelExecutionFeature}"
    enum="OnDeviceModelAndroidModelDownloadFailureReason"
    expires_after="2026-10-25">
  <owner>ssid@chromium.org</owner>
  <owner>xinghuilu@chromium.org</owner>
  <summary>
    Records the failure reason of on-device model download on Android for
    {ModelExecutionFeature}. Logged exactly once when a download request has
    failed.
  </summary>
  <token key="ModelExecutionFeature" variants="OnDeviceModelExecutionFeature"/>
</histogram>

<histogram name="OnDeviceModel.BenchmarkDuration" units="ms"
    expires_after="2027-01-17">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records the time it takes to run the benchmark in
    OnDeviceModelService.GetEstimatedPerformanceClass(). Logged whenever
    GetEstimatedPerformanceClass() is called.
  </summary>
</histogram>

<histogram name="OnDeviceModel.BenchmarkEstimatedTokensPerSecond.{Stage}"
    units="tk/s" expires_after="2027-02-07">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The estimated tokens per second this device can achieve during {Stage}.
    Logged whenever OnDeviceModelService.GetEstimatedPerformanceClass() is
    called.
  </summary>
  <token key="Stage">
    <variant name="Input" summary="input"/>
    <variant name="Output" summary="output"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.BenchmarkSuccess" enum="Boolean"
    expires_after="2027-01-03">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records whether there was an error running the tokens per second benchmark.
    Logged whenever OnDeviceModelService.GetEstimatedPerformanceClass() is
    called.
  </summary>
</histogram>

<histogram name="OnDeviceModel.BenchmarkVeryLowReason"
    enum="VeryLowPerformanceReason" expires_after="2027-01-17">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records the reason the benchmark returned kVeryLow performance class. Logged
    whenever kVeryLow performance class is returned from running the benchmark.
  </summary>
</histogram>

<histogram name="OnDeviceModel.DeviceHeapSize.{GpuType}" units="MB"
    expires_after="2027-02-07">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The maxiumum GPU heap size for a device with {GpuType} GPU. Logged whenever
    OnDeviceModelService.GetEstimatedPerformanceClass() is called.
  </summary>
  <token key="GpuType">
    <variant name="Discrete" summary="discrete"/>
    <variant name="Integrated" summary="integrated"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.Embedding.LoadDlcStatus"
    enum="EmbeddingModelLoadDlcStatus" expires_after="2026-09-27">
  <owner>jmpollock@chromium.org</owner>
  <owner>yich@google.com</owner>
  <owner>zuan@chromium.org</owner>
  <summary>
    Records any failure reason (or success) when attempting to load the
    embedding model DLC, this is the first part of the process during
    LoadEmbeddingModel().
  </summary>
</histogram>

<histogram name="OnDeviceModel.Embedding.LoadEmbeddingStatus"
    enum="EmbeddingModelLoadEmbeddingStatus" expires_after="2026-09-06">
  <owner>jmpollock@chromium.org</owner>
  <owner>yich@google.com</owner>
  <owner>zuan@chromium.org</owner>
  <summary>
    Records any failure reason (or success) that results from the mojo call
    LoadEmbeddingModel().
  </summary>
</histogram>

<histogram name="OnDeviceModel.Embedding.TfliteRunnerLoadStatus"
    enum="EmbeddingModelTfliteRunnerLoadStatus" expires_after="2025-12-14">
  <owner>jmpollock@chromium.org</owner>
  <owner>yich@google.com</owner>
  <owner>zuan@chromium.org</owner>
  <summary>
    Records any failure reason (or success) when attempting to load the
    embedding model into memory so that it can run, this is the second part of
    the process during LoadEmbeddingModel().
  </summary>
</histogram>

<histogram name="OnDeviceModel.Embedding.TfliteRunnerRunStatus"
    enum="EmbeddingModelTfliteRunnerRunStatus" expires_after="2025-12-14">
  <owner>jmpollock@chromium.org</owner>
  <owner>yich@google.com</owner>
  <owner>zuan@chromium.org</owner>
  <summary>
    Records any failure reason (or success) when attempting to run the embedding
    model.
  </summary>
</histogram>

<histogram name="OnDeviceModel.GpuBlockedReason" enum="GpuBlockedReason"
    expires_after="2027-01-17">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records the reason the GPU was blocked in OnDeviceModelService. Logged
    whenever ChromeML::IsGpuBlocked() is called.
  </summary>
</histogram>

<histogram name="OnDeviceModel.GpuErrorReason" enum="GpuErrorReason"
    expires_after="2027-02-14">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records a fatal error received by the OnDeviceModelService. Logged whenever
    the service crashes due to a GPU error.
  </summary>
</histogram>

<histogram name="OnDeviceModel.LoadModelDuration" units="ms"
    expires_after="2027-01-17">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records the time it takes to load a model in the OnDeviceModelService.
    Logged every time a model is successfully loaded.
  </summary>
</histogram>

<histogram name="OnDeviceModel.LoadPlatformModelStatus"
    enum="LoadPlatformModelStatus" expires_after="2027-01-17">
  <owner>jmpollock@chromium.org</owner>
  <owner>yich@google.com</owner>
  <summary>
    The result of loading a platform model in the OnDeviceModelService. Logged
    every time when loading a platform model.
  </summary>
</histogram>

<histogram name="OnDeviceModel.MaxBufferSize.{GpuType}" units="MB"
    expires_after="2025-10-26">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The maxiumum buffer size for a device with {GpuType} GPU. Logged whenever
    OnDeviceModelService.GetEstimatedPerformanceClass() is called.
  </summary>
  <token key="GpuType">
    <variant name="Discrete" summary="discrete"/>
    <variant name="Integrated" summary="integrated"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.QueueTime.{Priority}" units="ms"
    expires_after="2027-01-03">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    Records the time a task for a session with {Priority} priority spent in the
    queue in the OnDeviceModelService. Logged each time a task is run for a
    session.
  </summary>
  <token key="Priority">
    <variant name="Background" summary="background"/>
    <variant name="Foreground" summary="foreground"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.SystemRAM.{GpuType}" units="MB"
    expires_after="2027-02-07">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The total system memory for a device with {GpuType} GPU. Logged whenever
    OnDeviceModelService.GetEstimatedPerformanceClass() is called.
  </summary>
  <token key="GpuType">
    <variant name="Discrete" summary="discrete"/>
    <variant name="Integrated" summary="integrated"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.TokenCount.Input{InputSource}{Type}"
    units="tokens" expires_after="2027-02-14">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The number of {Type} tokens processed by the OnDeviceModel as a chunk of
    input. This is for {InputSource}. Note that for some types of input (e.g.
    images and audio) there is considerably more work done than just processing
    the tokens. Logged each time a {Type} chunk is processed.
  </summary>
  <token key="InputSource" variants="InputSource"/>
  <token key="Type">
    <variant name="" summary="total"/>
    <variant name=".Audio" summary="audio"/>
    <variant name=".Image" summary="image"/>
    <variant name=".Text" summary="text"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.TokenCount.{Stage}" units="tokens"
    expires_after="2027-02-07">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The number of {Stage} tokens processed by the OnDeviceModel. Logged each
    time the OnDeviceModel processes {Stage}.
  </summary>
  <token key="Stage">
    <variant name="Context" summary="context"/>
    <variant name="Execute" summary="execute"/>
    <variant name="Output" summary="output"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.TokensPerSecond.Input{InputSource}{Type}"
    units="tk/s" expires_after="2027-02-14">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The tokens per second seen when processing a chunk of {Type} input. This is
    for {InputSource}. Note that for some types of input (e.g. images and audio)
    there is considerably more work done than just processing the tokens. Logged
    each time a {Type} chunk is processed.
  </summary>
  <token key="InputSource" variants="InputSource"/>
  <token key="Type">
    <variant name="" summary="total"/>
    <variant name=".Audio" summary="audio"/>
    <variant name=".Image" summary="image"/>
    <variant name=".Text" summary="text"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.TokensPerSecond.{Stage}" units="tk/s"
    expires_after="2027-02-07">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The tokens per second seen when processing {Stage}. Logged each time the
    OnDeviceModel processes {Stage}.
  </summary>
  <token key="Stage">
    <variant name="Context" summary="context"/>
    <variant name="Execute" summary="execute"/>
    <variant name="Output" summary="output"/>
  </token>
</histogram>

<histogram name="OnDeviceModel.TotalTime.Input{InputSource}{Type}" units="ms"
    expires_after="2027-02-14">
  <owner>rmcelrath@chromium.org</owner>
  <owner>sophiechang@chromium.org</owner>
  <owner>src/services/on_device_model/OWNERS</owner>
  <summary>
    The total time taken when processing a chunk of {Type} input. This is for
    {InputSource}. Note that for some types of input (e.g. images and audio)
    there is considerably more work done than just processing the tokens. Logged
    each time a {Type} chunk is processed.
  </summary>
  <token key="InputSource" variants="InputSource"/>
  <token key="Type">
    <variant name="" summary="total"/>
    <variant name=".Audio" summary="audio"/>
    <variant name=".Image" summary="image"/>
    <variant name=".Text" summary="text"/>
  </token>
</histogram>

</histograms>

</histogram-configuration>
