Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Reduce KV memory for local-attention layers

オープン
#1,016 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Mikyx-1 がすでに取り組んでいます。

2026年9月6日 から。

  • #1017 @Mikyx-1 による — マージされずにクローズ
  • #1020 @Mikyx-1 による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cpp

調査の方向性

まず、runtime-aware cache constructor、デフォルトの Flash attention path、および issue で説明されている tiled attention backends を特定します。local layer と global layer が BF16 K/V buffers をどのように割り当てて読み取るかを追跡し、その後、resizing、snapshots、cache reuse、shared-KV layers、および backend selection が履歴と既存の attention 動作を維持することを確認します。

索引モデルが issue の本文から書いたものです。

説明

Problem

On dev (1658f88), the default flash attention path reserves full-context BF16 KV/K/V storage for local and global layers alike. Local layers only attend to their sliding window, so retaining capacity for the entire context wastes memory as the configured context grows.

The runtime-aware cache constructor also allocates compact tiled buffers that the default Flash path does not use. The tiled attention backends already have compact local rings; the default Flash path still reads the legacy transposed K/V buffers.

Fix direction

  • Allocate separate BF16 buffers per owning layer for the default Flash path.
  • Size local rings for the attention window plus the full prefill batch and trailing SIMD padding, capped by the configured context. The extra rows prevent batch writes and padding from overwriting history needed by early queries.
  • Keep global layers at the configured context capacity, with the logical context limit separate from physical alignment padding.
  • Reuse the source layer's buffers for shared-KV layers and retain the largest window required by their consumers.
  • Preserve live history when runtime batches require larger rings, keep snapshots independent, and clear buffers safely when reusing a cache.
  • Allocate only the buffers used by the selected attention backend and preserve the existing BF16 attention arithmetic and model-specific cache layouts.
主要言語
C++
スター
7k
フォーク
660
平均マージ
1日 15時間
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/gemma.cpp のほかの issue

google/gemma.cpp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。