lnn-model-design
Installation
SKILL.md
LNN 模型辅助设计
核心工作流
把这个 skill 当成训练前或部署前的 architecture gate。按“审计 -> 修改 -> 复审”的短循环推进,直到模型能够通过 Linger export 和 Thinker packaging。
- 需求收集:收集应用目标、目标平台(
venus、mars、arcs、venusa)、input shape/range、latency/memory/accuracy 目标、当前模型来源,以及模型当前处于 float、constrained、QAT 还是已导出 ONNX 状态。
如果 target platform 缺失,先让用户确认,再做 capability scan 或 pass/fail 判断。
如果 model input size、input shape 或 dynamic input range 缺失,先让用户确认,再做 parameter、activation、memory 或 compatibility 分析。 - 能力扫描:对本地 toolchain root 运行
scripts/collect_toolchain_capabilities.py。当需要查 source path、文档或命令变体时,读references/toolchain-sources.md。当需要 Linger ->tpacker-> x86 ->tvalidator->tprofile的实操顺序时,读references/workflow-playbook.md。 - 静态模型审计:如果已有 ONNX,运行
scripts/inspect_onnx_model.py;否则根据 PyTorch module 或结构描述估算 tensor/parameter size,并在 export 前识别不支持的 PyTorch op。 - 适配决策:对比 op、precision、parameter bytes、activation bytes、
tpackerthreshold、SRAM/PSRAM、dynamic shape range 和客户要求。提出结构修改建议前,先读references/adaptation-guidelines.md。判断修复方式是 architecture shrinkage、threshold tuning、stream split 还是显式 op split 前,先读references/npu-split-strategy.md。当 gate 失败原因不清晰时,先运行scripts/triage_gate_blocker.py,对 structure / split-policy / threshold / toolchain 假设做排序,再改模型。 - 全流程 gate:用 Linger 导出,用 Thinker
tpacker打包,并在 runtime library / input 可用时,通过tvalidator或直接的test_thinker/test_dynamic路径做验证。参考references/full-flow.md,也可以直接使用scripts/run_toolchain_gate.py。如果已经有失败的tvalidatorlog 或 runtime log,把它回灌到run_toolchain_gate.py,让 gate 对 runtime/consistency 问题做 triage,并按需自动生成 author issue bundle。 - Toolchain bug 移交:如果 Linger / Thinker /
tpacker/tvalidator本身表现异常,或者打包后的模型出现更像 toolchain 问题而不是 architecture 问题的 consistency mismatch,就停止大范围结构反复修改。读取references/author-handoff-template.md,运行scripts/generate_author_issue_bundle.py,生成problem.md和repro.sh,并保存最小可复现 bundle 给作者排查。 - 结果汇报:输出 pass/fail matrix、明确 blocker、精确 tuning 建议、commands/logs/artifacts、下一轮动作,以及适用时的 author handoff bundle 路径。报告结构参考
references/report-template.md。