Views
No views yet
Input (32K tokens) → 4 segments × 8K
Stage 1: 8 local slots per segment → L_i
Stage 2: multi-view stats → K=4 global slots G
Stage 3: Q=[chunk], KV=[G, L_i, chunk] → Flash Attentionadapter_model.bin (25 MB)
└── LoRA Adapters (r=8, alpha=16): q_proj, k_proj, v_proj, o_proj
trainable_params.bin (~3.5 GB)
├── local_constructor.* — Local Construction modules (32 layers)
├── global_integrator.* — Global Integration modules (32 layers)
├── input_layernorm / post_attention_layernorm — LayerNorm weights (32 layers)
├── model.embed_tokens.weight — Token embeddings (vocab=128,258)
└── model.norm.weight — Final LayerNormk_proj / v_proj output dim is 1024 (not 4096). HiCI modules are unaffected — they
use their own bottleneck projections (dim=512) independent of the base attention head structure.llama3_attn_hici.py from this repo (transformers >= 4.40.0).1import torch
2import transformers
3from peft import PeftModel
4import llama3_attn_hici as hici_attn
5
6# 1. Replace attention with HiCI BEFORE loading model
7hici_attn.MIXED_GROUP_TRAINING = False
8hici_attn.replace_llama_attn(use_flash_attn=True, use_full=False, use_hierarchical_forward=True)
9
10# 2. Load base model
11base_model = transformers.AutoModelForCausalLM.from_pretrained(
12 "meta-llama/Meta-Llama-3-8B", torch_dtype=torch.bfloat16, device_map="auto",
13)
14
15# 3. Register HiCI modules (must match training config)
16hici_attn.register_hici_to_model(base_model, num_memory_slots=8, global_slots=4, num_heads=8, bottleneck_dim=512)
17
18# 4. Load LoRA adapter + trainable_params
19model = PeftModel.from_pretrained(base_model, "ZengXiangyu/Llama-3-8b-HiCI-32k")
20
21# 5. Tokenizer (tiktoken-based, no tokenizer.model needed)
22tokenizer = transformers.AutoTokenizer.from_pretrained("ZengXiangyu/Llama-3-8b-HiCI-32k")1@article{zeng2026hici,
2 title={HiCI: Hierarchical Construction-Integration for Long-Context Attention},
3 author={Zeng, Xiangyu and Xu, Qi and Wang, Yunke and Xu, Chang},
4 journal={arXiv preprint arXiv:2603.20843},
5 year={2026}
6}