Created
April 3, 2026 03:12
-
-
Save finbarrtimbers/153dae1598b17c75a9690cd848e86818 to your computer and use it in GitHub Desktop.
Continuous batching, tikz diagram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % ===================== SUBFIGURE A: Static batching ===================== | |
| \begin{subfigure}{\linewidth} | |
| \centering | |
| \begin{tikzpicture} | |
| % Grid (4 rows x 8 cols) | |
| \gridlines{0}{0}{4}{8} | |
| % ----- PROMPTS: different lengths per row ----- | |
| % Row index: 1 = top | |
| % Row 1: length 2 | |
| \fillcell{0}{0}{4}{1}{1}{prompt} | |
| \fillcell{0}{0}{4}{1}{2}{prompt} | |
| \celltext{0}{0}{4}{1}{1}{\bfseries S1} | |
| % Row 2: length 3 | |
| \fillcell{0}{0}{4}{2}{1}{prompt} | |
| \fillcell{0}{0}{4}{2}{2}{prompt} | |
| \fillcell{0}{0}{4}{2}{3}{prompt} | |
| \celltext{0}{0}{4}{2}{1}{\bfseries S2} | |
| % Row 3: length 1 | |
| \fillcell{0}{0}{4}{3}{1}{prompt} | |
| \celltext{0}{0}{4}{3}{1}{\bfseries S3} | |
| % Row 4: length 4 | |
| \fillcell{0}{0}{4}{4}{1}{prompt} | |
| \fillcell{0}{0}{4}{4}{2}{prompt} | |
| \fillcell{0}{0}{4}{4}{3}{prompt} | |
| \fillcell{0}{0}{4}{4}{4}{prompt} | |
| \celltext{0}{0}{4}{4}{1}{\bfseries S4} | |
| % ----- GENERATED + END + IDLE (same timing as your mock) ----- | |
| % Row 1: gen at c=3..5, END at 6, idle 7..8 | |
| \foreach \c in {3,4,5} { \fillcell{0}{0}{4}{1}{\c}{gen} } | |
| \fillcell{0}{0}{4}{1}{6}{eos} \celltext{0}{0}{4}{1}{6}{\bfseries END} | |
| \foreach \c in {7,8} { \fillcell{0}{0}{4}{1}{\c}{idleshade} } | |
| % Row 2: gen at c=4,5,6,7; END at 8 | |
| \foreach \c in {4,5,6,7} { \fillcell{0}{0}{4}{2}{\c}{gen} } | |
| \fillcell{0}{0}{4}{2}{8}{eos} \celltext{0}{0}{4}{2}{8}{\bfseries END} | |
| % Row 3: gen at c=2,3; END at 4; idle 5..8 | |
| \foreach \c in {2,3} { \fillcell{0}{0}{4}{3}{\c}{gen} } | |
| \fillcell{0}{0}{4}{3}{4}{eos} \celltext{0}{0}{4}{3}{4}{\bfseries END} | |
| \foreach \c in {5,6,7,8} { \fillcell{0}{0}{4}{3}{\c}{idleshade} } | |
| % Row 4: gen at c=5,6; END at 7; idle 8 | |
| \foreach \c in {5,6} { \fillcell{0}{0}{4}{4}{\c}{gen} } | |
| \fillcell{0}{0}{4}{4}{7}{eos} \celltext{0}{0}{4}{4}{7}{\bfseries END} | |
| \fillcell{0}{0}{4}{4}{8}{idleshade} | |
| \end{tikzpicture} | |
| \caption{Static batching wastes compute after early finishes (gray cells).} | |
| \end{subfigure} | |
| \vspace{0.7cm} | |
| % ===================== SUBFIGURE B: Continuous batching ===================== | |
| \begin{subfigure}{\linewidth} | |
| \centering | |
| \begin{tikzpicture} | |
| % Grid | |
| \gridlines{0}{0}{4}{8} | |
| % ----- PROMPTS (same lengths as above) ----- | |
| % Row 1 (S1) | |
| \fillcell{0}{0}{4}{1}{1}{prompt} | |
| \fillcell{0}{0}{4}{1}{2}{prompt} | |
| \celltext{0}{0}{4}{1}{1}{\bfseries S1} | |
| % Row 2 (S2) | |
| \foreach \c in {1,2,3} { \fillcell{0}{0}{4}{2}{\c}{prompt} } | |
| \celltext{0}{0}{4}{2}{1}{\bfseries S2} | |
| % Row 3 (S3) | |
| \fillcell{0}{0}{4}{3}{1}{prompt} | |
| \celltext{0}{0}{4}{3}{1}{\bfseries S3} | |
| % Row 4 (S4) | |
| \foreach \c in {1,2,3,4} { \fillcell{0}{0}{4}{4}{\c}{prompt} } | |
| \celltext{0}{0}{4}{4}{1}{\bfseries S4} | |
| % ----- GENERATED + END + BACKFILL ----- | |
| % Row 1: gen c=3..5; END at 6; backfill S5 at c=7 prompt, c=8 gen | |
| \foreach \c in {3,4,5} { \fillcell{0}{0}{4}{1}{\c}{gen} } | |
| \fillcell{0}{0}{4}{1}{6}{eos} \celltext{0}{0}{4}{1}{6}{\bfseries END} | |
| \fillcell{0}{0}{4}{1}{7}{prompt} | |
| \fillcell{0}{0}{4}{1}{8}{gen} | |
| \celltext{0}{0}{4}{1}{7}{\bfseries S5} | |
| % Row 2: gen c=4..7; END at 8 | |
| \foreach \c in {4,5,6,7} { \fillcell{0}{0}{4}{2}{\c}{gen} } | |
| \fillcell{0}{0}{4}{2}{8}{eos} \celltext{0}{0}{4}{2}{8}{\bfseries END} | |
| % Row 3: gen c=2,3; END at 4; backfill S6 with prompt c=5,6 then gen c=7,8 | |
| \foreach \c in {2,3} { \fillcell{0}{0}{4}{3}{\c}{gen} } | |
| \fillcell{0}{0}{4}{3}{4}{eos} \celltext{0}{0}{4}{3}{4}{\bfseries END} | |
| \fillcell{0}{0}{4}{3}{5}{prompt} | |
| \fillcell{0}{0}{4}{3}{6}{prompt} | |
| \fillcell{0}{0}{4}{3}{7}{gen} | |
| \fillcell{0}{0}{4}{3}{8}{gen} | |
| \celltext{0}{0}{4}{3}{5}{\bfseries S6} | |
| % Row 4: gen c=5,6; END at 7; backfill S7 with prompt at c=8 | |
| \foreach \c in {5,6} { \fillcell{0}{0}{4}{4}{\c}{gen} } | |
| \fillcell{0}{0}{4}{4}{7}{eos} \celltext{0}{0}{4}{4}{7}{\bfseries END} | |
| \fillcell{0}{0}{4}{4}{8}{prompt} | |
| \celltext{0}{0}{4}{4}{8}{\bfseries S7} | |
| \end{tikzpicture} | |
| \caption{Continuous batching backfills finished rows immediately (no gray waste).} | |
| \end{subfigure} | |
| \caption{Static vs.\ continuous batching.} | |
| \label{fig:batching_subfigs} | |
| \end{figure} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment