Ledger C10–C12 match the permute-pad-bmm path and Switch aux/z-loss. Section 8 adds overview and component TikZ; MoE capacity is C_moe so it does not collide with KDA chunk size.
96 lines
3.1 KiB
TeX
96 lines
3.1 KiB
TeX
% KDA 笔记 preamble — 基于 superpaper/assets/notes-macros.tex
|
|
\usepackage[fontset=fandol]{ctex}
|
|
\usepackage{amsmath,amssymb}
|
|
\usepackage{graphicx}
|
|
\usepackage[margin=2.2cm]{geometry}
|
|
\usepackage[most]{tcolorbox}
|
|
\usepackage{etoolbox}
|
|
\usepackage{listings}
|
|
\usepackage{booktabs}
|
|
\usepackage{subcaption}
|
|
\usepackage{float}
|
|
\usepackage{tikz}
|
|
\usetikzlibrary{positioning, arrows.meta, decorations.pathreplacing, calc}
|
|
\usepackage{hyperref}
|
|
\usepackage{xcolor}
|
|
\usepackage{multicol}
|
|
\usepackage{tabularx}
|
|
\usepackage{array}
|
|
\usepackage{enumitem}
|
|
|
|
% ---------- 颜色 ----------
|
|
\definecolor{codebg}{HTML}{F7F7F7}
|
|
\definecolor{codeframe}{HTML}{CCCCCC}
|
|
\definecolor{shapecolor}{HTML}{2E86C1}
|
|
\definecolor{einsumcolor}{HTML}{884EA0}
|
|
\definecolor{notegreen}{HTML}{27AE60}
|
|
\definecolor{warnorange}{HTML}{E67E22}
|
|
|
|
% ---------- 代码样式 ----------
|
|
\lstdefinestyle{pycode}{
|
|
language=Python,
|
|
backgroundcolor=\color{codebg},
|
|
frame=single,
|
|
rulecolor=\color{codeframe},
|
|
basicstyle=\ttfamily\small,
|
|
keywordstyle=\color{blue!70!black}\bfseries,
|
|
commentstyle=\color{gray},
|
|
stringstyle=\color{red!60!black},
|
|
showstringspaces=false,
|
|
breaklines=true,
|
|
tabsize=4,
|
|
columns=flexible,
|
|
xleftmargin=4pt,
|
|
xrightmargin=4pt,
|
|
aboveskip=6pt,
|
|
belowskip=6pt,
|
|
}
|
|
\lstset{style=pycode}
|
|
|
|
% ---------- 形状标注命令 ----------
|
|
\newcommand{\shape}[1]{{\color{shapecolor}\ensuremath{[#1]}}}
|
|
\newcommand{\einsum}[1]{{\color{einsumcolor}\texttt{einsum(#1)}}}
|
|
\newcommand{\note}[1]{{\color{notegreen}\textit{#1}}}
|
|
|
|
% ---------- 盒子 ----------
|
|
\newtcolorbox{knowledgebox}[1]{
|
|
enhanced, colback=blue!5!white, colframe=blue!75!black, colbacktitle=blue!75!black,
|
|
coltitle=white, fonttitle=\bfseries, title=#1,
|
|
attach boxed title to top left={yshift=-2mm, xshift=2mm},
|
|
boxrule=1pt, sharp corners
|
|
}
|
|
\newtcolorbox{importantbox}[1]{
|
|
enhanced, colback=yellow!10!white, colframe=yellow!80!black, colbacktitle=yellow!80!black,
|
|
coltitle=black, fonttitle=\bfseries, title=#1, sharp corners
|
|
}
|
|
\newtcolorbox{warningbox}[1]{
|
|
enhanced, colback=red!5!white, colframe=red!75!black, colbacktitle=red!75!black,
|
|
coltitle=white, fonttitle=\bfseries, title=#1, sharp corners
|
|
}
|
|
\newtcolorbox{tensorbox}[1]{
|
|
enhanced, colback=blue!3!white, colframe=blue!40!black, colbacktitle=blue!50!black,
|
|
coltitle=white, fonttitle=\bfseries, title=#1, sharp corners,
|
|
boxrule=0.8pt
|
|
}
|
|
|
|
% 代码-公式并行盒子
|
|
\newtcolorbox{codemathtop}[1]{
|
|
enhanced, colback=codebg, colframe=codeframe,
|
|
fonttitle=\bfseries\ttfamily\small, title=#1,
|
|
sharp corners, boxrule=0.6pt,
|
|
left=4pt, right=4pt, top=2pt, bottom=2pt,
|
|
}
|
|
\newtcolorbox{codemathbot}{
|
|
enhanced, colback=white, colframe=blue!30!black,
|
|
sharp corners, boxrule=0.6pt,
|
|
left=4pt, right=4pt, top=4pt, bottom=4pt,
|
|
}
|
|
|
|
% ---------- 文档元信息 ----------
|
|
\newcommand{\notetitle}{KDA 训练→推理 完整笔记}
|
|
\newcommand{\notesubtitle}{递归 · 分块 · Gate · MLA · MoE · AttnRes · K3 架构}
|
|
\newcommand{\notedate}{\today}
|
|
|
|
\newcommand{\splabel}[1]{\hypertarget{sp:#1}{}\label{sp:#1}}
|
|
\newcommand{\spref}[1]{\hyperlink{sp:#1}{\texttt{#1}}}
|