Skip to content

[Engine] Inkling 2 Mini: 1M-token context on 8 GB cards through a ZHA index (opt-in) #324

Backlog

Description

@CrownedSilverFox

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Problem

Inkling 2 Mini's 8 full-attention layer runs keep 32,768 bytes a token in VRAM (fp16; about 17 KB in Q8_0). On an 8 GB card that caps the context far below 1M tokens: at 1M the full runs alone need 32 GiB (17 GiB in Q8_0).

Proposed behavior

An opt-in index over those 8 runs, after "ZHA" (Zyphra Hierarchical Attention, arXiv 2610.42112), one level:

  • keys and values of the full runs go to pinned RAM as 4-bit leaves (9,216 bytes a token for all 8 runs);
  • VRAM keeps, per 64-key chunk and KV head, summaries for 4 trained reference queries (592 bytes a token for all 8);
  • a token reads exactly chunk 0, its last 1,024 keys and the far chunks its summaries score best (16%, at most 256), and every other far chunk as one summarized key;
  • an answer keeps the chunks it has read in a VRAM pool, so a token fetches only new ones over PCIe.

Turned on with STRATA_INK_ZHA=<reference file> (131 KB, trained for Inkling 2 Mini). Without it the engine writes the same tokens as main. NVIDIA (sm_75+) only, one sequence, one card; refused with --draft-model, --layer-split, --expert-gpu, on HIP and Metal.

Tradeoffs

  • The answers move: at 32K tokens the mean KL against full attention is about 0.016.
  • Pinned RAM grows with the context (9 GiB at 1M).
  • A new CUDA file (about 2,500 lines) and a few hooks in the engine (an architecture hook when a prompt's read starts and ends, to lend the index's prompt buffers from the expert cache).

Evidence so far

RTX 4060 8 GB, Ryzen 7 5700X, 31 GB RAM, Inkling-2-Mini-IQ4_NL.gguf: a 1,024,338-token prompt read at 853 tokens/s and its needle (at 10%) answered; at 128K the prompt read 1,310 tokens/s against 963 with full attention and answers written 30.0 tokens/s against 22.2; at 272K full attention runs out of VRAM, the index reads 1,243 tokens/s. Mean KL 0.0156 at 32K.

I have a branch ready and can open it as a draft PR if the scope is welcome.

What do you do today instead?

On an 8 GB card the context stays well below 272K tokens: a 271,910-token prompt stops with no VRAM for the attention cache. For longer contexts I run the index from my own branch.

Activity

  1. added
    needs-format
    on Nov 24, 2026
  2. github-actions commented on Nov 24, 2026

    @github-actions

    Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

    • Fill in "What do you want to do?".

    Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

    Details: CONTRIBUTING.md

  3. github-actions commented on Nov 24, 2026

    @github-actions

    Thanks, this follows the format now.

  4. removed
    needs-format
    on Nov 24, 2026
  5. CrownedSilverFox commented on Nov 24, 2026

    @CrownedSilverFox
    Author

    The branch: https://github.com/CrownedSilverFox/PolyStrata/tree/inkling-zha-index, 3 commits on main 36e654b (diff against main):

    1. poly: read_groups() counts the rows a read of the prompt already holds as room: a small engine fix the long reads need. It changes how a read's calls are grouped, not what they compute.
    2. poly: Inkling 2's full layers through a ZHA index (STRATA_INK_ZHA, opt-in): the index, docs/INKLING_ZHA.md (what it does, what it takes, the measurements), the settings register.
    3. terminal/data: the ZHA reference file for Inkling 2 Mini (131 KB).

    I'll open it as a draft PR once the scope is agreed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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