---
title: "ClikaRT::ops::mla_attention"
sidebar_label: "mla_attention"
description: "Multi-head Latent Attention over a compressed KV cache, latent-space end to end: q_nope [ΣS, H, Dl] (W_UK-absorbed) + q_pe [ΣS, H, Dr] score against the per-token compressed rows; the caches ([max_seq…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## mla\_attention() {#mla_attention}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`mla_attention`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `q_nope`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `q_pe`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `new_ckv`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `new_kpe`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `ckv_cache`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `kpe_cache`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `kvcache_start`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `cu_seqlens_q`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`double` `scale`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `slot_ids` `=` `{}`<br />
)

</div>

Multi-head Latent Attention over a compressed KV cache, latent-space end to end: q\_nope `[ΣS, H, Dl]` (W\_UK-absorbed) + q\_pe `[ΣS, H, Dr]` score against the per-token compressed rows; the caches (`[max_seqs, max_seq, Dl/Dr]`) take this step's `new_ckv`/`new_kpe` appends IN PLACE (write offsets = `kvcache_start [B]` Int32; `cu_seqlens_q [B+1]` locates each sequence's packed tokens); the returned `[ΣS, H, Dl]` output stays latent (apply the W\_UV un-absorption after). `scale` is REQUIRED; the absorbed query's magnitude lives in the model's un-absorbed head dim.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 3894

</div>
