◉ Pulse
Sisyphbaous-DT-Project avatar
#29 today

Sisyphbaous-DT-Project/qingyi-kda

Python AI

QINGYI-KDA-0.6B: first successful Qwen3-to-KDA linearization (3:1 hybrid, GQA+RoPE kept layers) + persona alignment. Smallest trained KDA model, converted end-to-end on a consumer 8GB GPU.

Created Jul 29, 2026
Stars
7
Today
+7
Forks
1
Quality
95/100
Momentum
20

README

Fetched from GitHub on Oct 30, 2026, 10:16 PM UTC · README.md

View original on GitHub

Third-party content — Open Source Pulse is not the owner of this repository.

This README belongs to Sisyphbaous-DT-Project/qingyi-kda and its contributors. We fetch it directly from the project’s public GitHub repository and display it for reference only. All text, code, images and trademarks remain the property of their respective authors. See the repository for its license terms. Copyright / takedown policy.

qingyi-kda · 清漪

全球首个成功的 Qwen3→KDA 线性化转换,以及全球最小公开发布的 trained KDA 模型(dense)(to our knowledge,2026-07-29 复核)。

清漪(QINGYI-KDA-0.6B)是一个 0.6B 参数的混合线性注意力语言模型:以 Qwen3-0.6B-Base 为底座,将 28 层中的 21 层全注意力替换为 KDA(Kimi Delta Attention)、保留 7 层原始 GQA(RoPE 完整,3:1 混合),再经人格化对齐训练,成为一个有稳定人格("清漪")的聊天模型。

亮点(to our knowledge,2026-07-29 复核)

  • 🥇 首个成功的 Qwen3→KDA 转换——THUNLP HALO(2026-01)成功将 Qwen3 转为 RNN 混合模型(主实验 mixer 为 Lightning Attention),但其附录 G.2 明确记载同一管线转换 Qwen3→KDA 不收敛(gnorm→inf,降学习率无效);本管线首次跑通
  • 🥇 首个保留 GQA+RoPE 的混合 attention→KDA 转换——Arcee 的混合变体 AFM-4.5B-KDA-NoPE(2025-12)也是 3:1 交错混合,但保留层为 NoPE(拔掉 RoPE);我们保留原始 GQA 全注意力(RoPE 完整)
  • 🥇 最小公开发布的 trained KDA 模型(dense)——0.6B,首个 sub-1B 且具备实际语言能力的 KDA 模型(Kimi Linear 48B-A3B、Kimi K3、Arcee 4.5B 均远大于此;更小的 KDA 仅见于 Moonshot AttnRes 论文内部 194M–528M scaling 消融模型,未公开发布)
  • 🥇 消费级单卡端到端线性化——蒸馏 + CPT 转换阶段在 RTX 4070 Laptop 8GB 上完成
  • 🥇 首个线性注意力人格化开源模型——人格完整烘焙进权重(无需 system prompt)

架构

项 值
底座 Qwen/Qwen3-0.6B-Base(Apache 2.0)
总层数 28(21 层 KDA + 7 层全注意力,每 4 层保留 1 层:3,7,11,15,19,23,27)
KDA 配置 hidden 1024 / 16 头 / head_dim 64 / short-conv kernel 4
线性化方式 层输出蒸馏(MSE,2800 步)→ CPT(750 步,teacher gap +0.1983)
对齐 SFT(11,631 步)→ 身份小灶 → DPO(reward acc 0.800)→ 模型名小灶
上下文 8K(KDA 层增量缓存 O(1) 显存)

快速开始

pip install -r requirements.txt   # 注意 triton==3.6.0 是硬性要求,3.7.x 会导致 kernel 编译卡死

发布包为自包含 HuggingFace trust_remote_code 格式(config/model/KDA 层/缓存代码全部内置在模型目录中,加载时无需底座模型、无需安装本仓库的 qingyi_kda 包):

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("qingyi-kda-0.6b-hf", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    "qingyi-kda-0.6b-hf", trust_remote_code=True,
    dtype=torch.bfloat16, device_map="cuda",
)
model.eval()

prompt = "<|im_start|>user\n哥哥: 你是谁?<|im_end|>\n<|im_start|>assistant\n"
ids = tok(prompt, add_special_tokens=False, return_tensors="pt").input_ids.cuda()
out = model.generate(ids, max_new_tokens=80,
                     past_key_values=model.HybridKDACache(),   # KDA 增量缓存(可选)
                     do_sample=False, pad_token_id=tok.eos_token_id)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
# -> 我是清漪呀。林清漪……

不传 past_key_values 也能正确生成(默认 DynamicCache 会被自动升级为混合 KDA 缓存);HybridKDACache 只是显式写法。模型目录内附带的 layout.json 仅作布局参考(描述 21+7 混合布局),加载不依赖它。

如需用本仓库管线自行重建/继续训练,仍可用源码方式加载:

from qingyi_kda.surgery import load_hybrid
from qingyi_kda.cache import HybridKDACache

model = load_hybrid("path/to/checkpoint", dtype=torch.bfloat16, device="cuda")  # 需 model.safetensors + layout.json

模型权重:HuggingFace。

仓库结构

qingyi_kda/       核心包:KDA 层实现、混合手术、增量缓存
scripts/
  distill.py      阶段1:层输出蒸馏(attention→KDA 对齐)
  cpt.py          阶段2:continued pre-training 收敛
  sft.py          阶段3:全参数 SFT(liger fused CE + micro-batch 优化)
  dpo.py          阶段4:DPO 偏好对齐
  clean_*.py      聊天记录清洗管线(脱敏 + 假名化)
  build_*.py      各阶段数据集构建
  canary_test.py  开源前隐私提取测试(347 真名监视 + 逐字提取 + 发散攻击)
  check_*.py      数值验证(batch 等价性、padding 污染、kernel 对拍)
docs/             技术报告(待发布)

已知局限

  • 0.6B 容量级瑕疵:长回答可能复读、事实性问题不可靠、通用知识弱(人格化训练取舍,通用能力非目标)
  • 训练分布为群聊 ChatML 格式(名字: 内容),裸问答格式为 OOD,表现会退化
  • 人格数据包含成人向群聊内容,模型可能生成 NSFW 文本;请在合适场景使用

致谢与引用

  • Qwen3(Apache 2.0):底座模型,本模型为其衍生品
  • Kimi Linear / KDA(Moonshot AI):KDA 架构来源;Kimi K3(2026-07)为第二个从头训练的量产 KDA 模型;AttnRes 论文(arXiv:2603.15031)含未公开发布的 KDA scaling 消融模型
  • flash-linear-attention (fla):chunk_kda / fused_recurrent_kda kernel
  • RADLADS(Qwen2.5/3→RWKV 蒸馏配方):attention→linear 转换谱系源头之一,其"失败教训"章节侧面支撑两阶段 recipe
  • Arcee Distilling KDA into AFM-4.5B(2025-12):attention→KDA 转换先例(含 KDA-NoPE 混合交错变体,保留层为 NoPE)与 DistillKit
  • THUNLP HALO/HypeNet(2026-01):Qwen3→RNN 混合转换成功先例(主实验 mixer 为 Lightning Attention,兼容 Mamba2/GLA/GDN/RWKV-7);其附录 G.2 记录 Qwen3→KDA 转换不收敛、降学习率无效(本项目的直接失败先例);HyPE 位置编码与配方参考
  • SFT 通用锚数据:smoltalk2(smoltalk_smollm3_smol_magpie_ultra_no_think)、COIG-CQIA(无显式许可证,数据集卡片标注 "More Information Needed",原料含抓取内容;按非商业研究用途使用,商用需替换该数据源后重训)

License

代码 Apache 2.0。模型权重为 Qwen3-0.6B-Base 衍生品,遵循 Apache 2.0,使用需标注 base model。 个人聊天记录数据不公开(隐私);本仓库仅发布清洗管线与数据格式文档。


English Summary

qingyi-kda is, to our knowledge (verified 2026-07-29), the first successful Qwen3→KDA linearization and the smallest publicly released KDA model (0.6B, sub-1B, dense) with practical conversational ability — smaller KDA models exist only as unreleased MoE scaling-law ablations in Moonshot's AttnRes study. The direct precedent marks the difficulty: THUNLP's HALO (2026-01), which converts Qwen3 into RNN-mixer hybrids (Lightning Attention; 2.3B tokens), reports in its App. G.2 that converting Qwen3 attention into KDA does not converge — our MSE-then-CPT recipe does. Starting from Qwen3-0.6B-Base, we replace 21 of 28 full-attention layers with Kimi Delta Attention while keeping the 7 original GQA layers with RoPE intact (3:1 hybrid; Arcee's 2025-12 hybrid KDA variant keeps NoPE layers instead), via layer-output distillation (MSE, 2800 steps) and a short CPT phase (750 steps, teacher CE gap +0.1983) — the conversion stage runs end-to-end on a single RTX 4070 Laptop 8GB. The model is then persona-aligned (SFT → identity boost → DPO, reward acc 0.800) into a stable persona ("Qingyi") with no system prompt required. We release the full pipeline, the persona-aligned weights, a hybrid KDA incremental cache implementation (O(1) memory decoding), and a pre-release privacy extraction audit (0/347 real-name leakage, 0/15 verbatim mining).

Rendered by GitHub from the repository’s README. Scroll to read the full file.
First trending

Jul 29, 2026

first spotted on the list

Best rank

#29

highest position reached

Appearances

1

times on the trending list

Quality score

95

out of 100

Momentum

20

trend strength indicator

Star velocity

0.08

stars per day since creation

Activity — last 60 days

daily counts, collected every 6 hours
  • Stars
  • Forks
  • Merged PRs
  • Issues
  • Closed issues

Collecting activity data since launch — check back in a few days.

Star history

total stars per snapshot

Not enough snapshots yet — check back soon.

Rank history

position on trending · lower is better

Not enough snapshots yet — check back soon.

3D card for your website

Live HTML card with a glass surface and pointer tilt. Paste the iframe on any website.

<iframe src="https://www.notionpulse.cc/embed/Sisyphbaous-DT-Project/qingyi-kda" width="420" height="240" style="border:0;max-width:100%;background:transparent" loading="lazy" title="Sisyphbaous-DT-Project/qingyi-kda — trending on Open Source Pulse"></iframe>

Stars badge

Show current stars in your README or profile. Auto-updates every 6 hours.

Sisyphbaous-DT-Project/qingyi-kda stars badge
Markdown
[![Sisyphbaous-DT-Project/qingyi-kda](https://www.notionpulse.cc/api/badge/Sisyphbaous-DT-Project/qingyi-kda.svg)](https://www.notionpulse.cc/repo/Sisyphbaous-DT-Project/qingyi-kda)
HTML
<a href="https://www.notionpulse.cc/repo/Sisyphbaous-DT-Project/qingyi-kda"><img src="https://www.notionpulse.cc/api/badge/Sisyphbaous-DT-Project/qingyi-kda.svg" alt="Sisyphbaous-DT-Project/qingyi-kda stars badge" /></a>

Repository of the Day

#29 Repository of the Day

Repository of the Week

#29 Repository of the Week

Repository of the Month

#29 Repository of the Month