Release SparseGUI Indexer (EvoCUA-8B-20260105 checkpoint)
Browse filesFiles changed (5)
- README.mdAdded+63
- evocua-8b-20260105/README.mdAdded+36
- evocua-8b-20260105/config.jsonAdded+37
- evocua-8b-20260105/model.safetensorsAdded+3
- indexer.pyAdded+123
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263---license: apache-2.0base_model:- meituan/EvoCUA-8B-20260105tags:- gui-agent- computer-use- sparse-attention- long-contextdatasets:- nvidia/ProCUA-SFT---
# SparseGUI Indexer
Learned token indexers for **decode-time sparse attention** in long-horizon GUI agents. For eachdecode query, the Indexer selects which prompt tokens attention keeps: the top-B tokens by its score,plus a few fixed always-on positions and the tokens generated in the current turn. Prefill staysdense.
Paper: [SparseGUI: Accelerating Long-Horizon GUI Agents with Learned Sparse Attention](https://arxiv.org/pdf/2612.02762).Code: [github.com/MichelleMa8/SparseGUI](https://github.com/MichelleMa8/SparseGUI).See the paper for the method, training and results.
## Checkpoints
There is one folder per backbone. You also need the backbone model.
| Folder | Backbone | Budget B ||---|---|---:|| [`evocua-8b-20260105/`](evocua-8b-20260105) | [meituan/EvoCUA-8B-20260105](https://huggingface.co/meituan/EvoCUA-8B-20260105) | 2048 |
Each folder contains `model.safetensors`, `config.json` (dimensions, budget, always-onpositions) and a short `README.md`. `indexer.py` at the top level works for every folder.
## Usage
```pythonfrom indexer import Indexer # needs torch, safetensors, huggingface_hubidx = Indexer.from_pretrained("M-Ma/SparseGUI-Indexer", subfolder="evocua-8b-20260105")kt = idx.keys(k_post) # post-RoPE keys [L, n_kv_heads, head_dim]; cache per layerkept = idx.select(q_post, kt, prompt_len) # post-RoPE query [n_q_heads, head_dim] -> kept positions```
`from_pretrained` downloads only the requested folder. The fast inference runtime (prefix cache +CUDA graph) is in the code repository.
## License
Apache-2.0. The weights were trained on attention statistics of the backbone over ProCUA-SFTtrajectories (CC BY 4.0, NVIDIA) and contain no ProCUA-SFT data.
## Citation
```bibtex@misc{sparsegui2026, title = {SparseGUI: Accelerating Long-Horizon GUI Agents with Learned Sparse Attention}, year = {2026}, eprint = {2612.02762}, archivePrefix = {arXiv}, url = {https://arxiv.org/abs/2612.02762}}```123456789101112131415161718192021222324252627282930313233343536# SparseGUI Indexer: EvoCUA-8B-20260105
Indexer for [meituan/EvoCUA-8B-20260105](https://huggingface.co/meituan/EvoCUA-8B-20260105)(Apache-2.0). Usage and license are in the [top-level README](../README.md). Details are in the[paper](https://arxiv.org/pdf/2612.02762).
| | ||---|---|| Weights | `w_q.weight` [128, 4096], `w_k.weight` [128, 1024], float32, 655,360 parameters, shared by all 36 layers || Budget | B = 2048 routed tokens per layer and decode query || Always-on | positions 0, 2, 5, 16, 19 and the last 8 prompt positions || Training data | ProCUA-SFT trajectories, no overlap with GUI-LongDep or OSWorld evaluation tasks |
```pythonidx = Indexer.from_pretrained("M-Ma/SparseGUI-Indexer", subfolder="evocua-8b-20260105")```
If you use this checkpoint, please also cite EvoCUA and ProCUA-SFT:
```bibtex@article{xue2026evocua, title = {EvoCUA: Evolving Computer Use Agents via Learning from Scalable Synthetic Experience}, author = {Xue, Taofeng and Peng, Chong and Huang, Mianqiu and Guo, Linsen and Han, Tiancheng and Wang, Haozhe and Wang, Jianing and Zhang, Xiaocheng and Yang, Xin and Zhao, Dengchang and others}, journal = {arXiv preprint arXiv:2601.15876}, year = {2026}}
@misc{jung2026procuasfttechnicalreport, title = {ProCUA-SFT Technical Report}, author = {Jaehun Jung and Ximing Lu and Brandon Cui and Muhammad Khalifa and Shaokun Zhang and Hao Zhang and Jin Xu and Amala Sanjay Deshmukh and Karan Sapra and Andrew Tao and Yejin Choi and Jan Kautz and Mingjie Liu and Yi Dong}, year = {2026}, eprint = {2606.17321}, archivePrefix = {arXiv}, url = {https://arxiv.org/abs/2606.17321}}```12345678910111213141516171819202122232425262728293031323334353637{ "architecture": "SparseGUIIndexer", "name": "evocua-8b-20260105", "description": "token indexer for decode-time sparse attention in EvoCUA-8B", "backbone": "meituan/EvoCUA-8B-20260105", "n_layers": 36, "n_q_heads": 32, "n_kv_heads": 8, "head_dim": 128, "index_dim": 128, "shared_across_layers": true, "input": "post-RoPE query / key, heads flattened head-major", "source_embed": false, "budget": 2048, "sparsify": "decode queries only (last prompt position and generated tokens); prefill dense", "score_dtype_deployment": "bfloat16", "always_on": { "head_positions": [ 0, 2, 5, 16, 19 ], "tail_window": 8 }, "training": { "objective": "KL(head-mean dense attention over routed prompt tokens || softmax(r))", "data": "ProCUA-SFT train split, 3,614 trajectories / 5,000 sampled steps, 10k-160k tokens", "optimizer_steps": 452, "lr": 0.001, "weight_decay": 0.01, "warmup_steps": 20, "max_new_tokens": 256, "seed": 20261023 }}123version https://git-lfs.github.com/spec/v1oid sha256:fa5375f558bd4e24d8ba409bec5c40249951cad2c17a0aa9e82488717475d376size 2621640123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123"""Reference implementation of the SparseGUI Indexer (DSA-style, no source embedding).
The Indexer picks, for every decoder layer and every decode query, which prompt tokens thequery attends to. One pair of projections is shared by all layers:
q~ = W_q q q: post-RoPE query of the decode token, all query heads, flattened k~ = W_k k k: post-RoPE key of a prompt token, all KV heads, flattened r = q~ . k~ / sqrt(index_dim)
Per layer, the kept set of a decode query is
top-B routed prompt tokens by r U always-on tokens U tokens generated in this turn
where the always-on tokens are ``always_on.head_positions`` plus the last``always_on.tail_window`` prompt positions, and every other prompt position is routed.All heads of a layer use the same kept set (GQA). Prefill stays dense; only the last promptposition and the generated tokens are sparsified. If the number of routed tokens is at most B,nothing is dropped.
Every backbone has its own checkpoint folder (config.json + model.safetensors); this file readsall dimensions from config.json and works for each of them.
This file needs only torch and safetensors (plus huggingface_hub to download). It reproducesthe scores and selections of the training / inference code (``sparsegui.sparse.gather``);the fused prefix-cache and CUDA-graph runtime used for the paper's timings lives in theSparseGUI code repository:https://github.com/MichelleMa8/SparseGUI
from indexer import Indexer idx = Indexer.from_pretrained("M-Ma/SparseGUI-Indexer", subfolder="evocua-8b-20260105") kt = idx.keys(k_post) # k_post [L, n_kv_heads, head_dim] -> [L, d] (cache this) kept = idx.select(q_post, kt, prompt_len) # q_post [n_q_heads, head_dim] -> sorted kept positions
``from_pretrained`` also takes a local copy of the repository (with ``subfolder``) or a localcheckpoint folder (without it)."""from __future__ import annotations
import jsonimport mathfrom pathlib import Path
import torchfrom safetensors.torch import load_file
class Indexer(torch.nn.Module): def __init__(self, config: dict): super().__init__() self.config = config q_dim = config["n_q_heads"] * config["head_dim"] k_dim = config["n_kv_heads"] * config["head_dim"] d = config["index_dim"] self.w_q = torch.nn.Linear(q_dim, d, bias=False) self.w_k = torch.nn.Linear(k_dim, d, bias=False) self.scale = 1.0 / math.sqrt(d)
@classmethod def from_pretrained(cls, path_or_repo: str | Path, subfolder: str | None = None, revision: str | None = None, device="cpu") -> "Indexer": """Load one checkpoint folder from a local path or a Hub repository.
``subfolder`` names the backbone checkpoint inside the repository (for example ``"evocua-8b-20260105"``). From the Hub only that folder is downloaded. """ path = Path(path_or_repo) if not path.exists(): from huggingface_hub import snapshot_download patterns = [f"{subfolder.strip('/')}/*"] if subfolder else None path = Path(snapshot_download(str(path_or_repo), revision=revision, allow_patterns=patterns)) if subfolder: path = path / subfolder if not (path / "config.json").is_file(): found = sorted(p.parent.name for p in path.glob("*/config.json")) raise FileNotFoundError( f"no config.json in {path}; pass subfolder=" + (" or ".join(map(repr, found)) if found else "<checkpoint folder>")) config = json.loads((path / "config.json").read_text()) model = cls(config) model.load_state_dict(load_file(str(path / "model.safetensors")), strict=True) return model.to(device).eval()
@torch.no_grad() def keys(self, k_post: torch.Tensor) -> torch.Tensor: """Indexer keys k~ [L, index_dim] for post-RoPE keys [L, n_kv_heads, head_dim].""" return self.w_k(k_post.reshape(k_post.shape[0], -1).float())
@torch.no_grad() def scores(self, q_post: torch.Tensor, keys: torch.Tensor) -> torch.Tensor: """Scores r [L] of one decode query (post-RoPE, [n_q_heads, head_dim]) over k~ [L, d].""" q = self.w_q(q_post.reshape(1, -1).float()) return (q @ keys.T)[0] * self.scale
def always_on_mask(self, prompt_len: int) -> torch.Tensor: ao = self.config["always_on"] m = torch.zeros(prompt_len, dtype=torch.bool) for p in ao["head_positions"]: if 0 <= p < prompt_len: m[p] = True if ao["tail_window"] > 0: m[max(0, prompt_len - ao["tail_window"]):] = True return m
@torch.no_grad() def select(self, q_post: torch.Tensor, keys: torch.Tensor, prompt_len: int, total_len: int | None = None, budget: int | None = None) -> torch.Tensor: """Sorted positions one layer keeps for one decode query.
``keys`` holds k~ of the prompt positions [0, prompt_len); positions in [prompt_len, total_len) are this turn's generated tokens and are always kept. """ budget = self.config["budget"] if budget is None else budget total_len = prompt_len if total_len is None else total_len ao = self.always_on_mask(prompt_len).to(keys.device) routed = (~ao).nonzero().squeeze(1) if budget >= routed.numel(): chosen = routed else: r = self.scores(q_post, keys[:prompt_len])[routed] chosen = routed[torch.topk(r, budget).indices] turn = torch.arange(prompt_len, total_len, device=keys.device) return torch.sort(torch.cat([ao.nonzero().squeeze(1), chosen, turn])).valuesREADME.mdAdded+63
evocua-8b-20260105/README.mdAdded+36
evocua-8b-20260105/config.jsonAdded+37
evocua-8b-20260105/model.safetensorsAdded+3
indexer.pyAdded+123