English · Español
Lab 03 — Knowledge graph: visualising the 40 phases¶
🇪🇸 Un grafo donde los nodos son conceptos clave y las aristas son dependencias entre fases. Un futuro aprendiz puede leer el grafo y entender qué encaja con qué. Es la cartografía del proyecto.
Objective¶
Produce a single SVG file: docs/phase-40-hardening-postmortem/diagrams/knowledge-graph.svg. Nodes are concepts (one per phase, roughly); edges are dependencies ("Phase N's understanding requires Phase M"). Annotated so a stranger can read it in 5 minutes.
Setup¶
graphviz(dot) for rendering, ormermaidif you prefer (uv addor system install).- The 40
PHASE_NN_README.mdfiles for the headline concept of each phase. - The "What this phase does NOT cover" sections, which often name dependencies on later phases.
Tasks¶
-
Pick the node set. Aim for 30-50 nodes. Each node is a concept, not necessarily a phase. Many phases contribute multiple concepts; some phases contribute one. Examples:
-
Phase 02 → "fp32/fp16/bf16 numerical representation" (one node).
- Phase 17 → "Pre-LN transformer block" + "tied embeddings" + "Mini-GPT assembly" (three nodes).
- Phase 21 → "Sampling: greedy/temperature/top-k/top-p" (one node).
- Phase 22 → "KV cache" (one node).
-
Phase 33 → "FastAPI serving" + "continuous batching" + "Little's law" (three nodes).
-
Pick the edge set. Edges are prerequisite relationships. If understanding concept B requires concept A, draw A → B. Examples:
-
"fp32/fp16/bf16" → "quantization" (Phase 02 → Phase 26)
- "log-sum-exp" → "softmax sampling at temperature" (Phase 05 → Phase 21)
- "Pre-LN transformer block" → "KV cache" (Phase 17 → Phase 22)
- "KV cache" → "continuous batching" (Phase 22 → Phase 33)
Aim for ≤ 3 incoming edges per node. If a node has more, it's too central — split it into two concepts or push some prereqs to be "indirect" (i.e., go through an intermediate node).
- Render with
dot:
digraph LynxCortex {
rankdir=LR;
node [shape=box, fontname="Helvetica", fontsize=10];
// Foundations
"Reproducibility (P00)" -> "Numerical Representation (P02)";
"Numerical Representation (P02)" -> "Quantization (P26)";
"Log-sum-exp (P05)" -> "Softmax sampling at τ (P21)";
"Cross-entropy (P05)" -> "Training loop (P18)";
"Tied embeddings (P17)" -> "LM head (P17)";
"Pre-LN block (P17)" -> "Mini-GPT assembly (P17)";
"Mini-GPT assembly (P17)" -> "Training loop (P18)";
"Training loop (P18)" -> "Training dynamics (P19)";
"Training loop (P18)" -> "Mini-GPT (P17)";
"KV cache (P22)" -> "Continuous batching (P33)";
"FastAPI serving (P33)" -> "Continuous batching (P33)";
"Little's law (P33)" -> "Capacity sizing (P34)";
// ... continue for ~30-50 nodes total
}
Render:
-
Cluster the graph. Use
subgraph cluster_X { ... }to group concepts by theme: -
Foundations (Phases 00-09): reproducibility, math, autograd.
- Tokenization & data (Phases 11-13): BPE, corpus design, embeddings.
- Sequence modeling (Phases 14-17): attention, positional, Mini-GPT.
- Training & evaluation (Phases 18-20): loops, dynamics, harness.
- Inference (Phases 21-22, 27): sampling, KV cache, modern attention.
- Optimization (Phases 23-28): GPU, CUDA, quantization, LoRA.
- Application (Phases 29-32): RAG, structured gen, tools, agents.
-
Operations (Phases 33-39): serving, observability, distributed, security, MLOps.
-
Render with annotations. Use
label=on key edges to denote why the dependency exists:
- Verify legibility. Open the SVG in a browser. Walk through it as if you'd never seen it before:
- Can you identify the entry points (foundational concepts, no incoming edges)?
- Can you identify the terminal nodes (capstone concepts, no outgoing edges)?
- Do clusters visibly group related concepts?
-
Is any node isolated (no edges)? Either delete or fix.
-
Link from the phase README. Add to
docs/phase-40-hardening-postmortem/README.md:
Deliverable¶
docs/phase-40-hardening-postmortem/diagrams/knowledge-graph.svg — the rendered graph.
Plus the source: docs/phase-40-hardening-postmortem/diagrams/knowledge-graph.dot (or .mmd for mermaid).
Acceptance¶
- 30-50 nodes; 50-100 edges.
- Clustered into 5-8 logical groups.
- Renders cleanly to SVG.
- No isolated nodes.
- A stranger could trace a path from "Reproducibility" to "Continuous batching" by following the arrows, with each step justified.
Pitfalls¶
- Too many nodes. Past ~60, the graph becomes unreadable. Aggregate. ("Numerical hygiene" can be one node, not three.)
- Too few edges. Concepts in an AI system are dense. If you have 50 nodes and 10 edges, you're under-connecting. Aim for ~2-3 edges per node on average.
- Cycles. The graph should be acyclic (it's a curriculum dependency graph). If you find a cycle, it's a bug in your conceptualisation — break the cycle by being more precise about which sub-concept depends on which.
- Rendering hell. Graphviz default layouts can be ugly. Try
rankdir=LR(left-to-right) for curriculum-style graphs; usesplines=orthofor clean orthogonal edges. - Conflating "phase" with "concept." A phase is a chapter; a concept is a notion. Some phases produce many concepts; some produce one.
Stretch¶
- Add color to encode something useful: e.g., red for foundations, blue for inference, green for ops. Don't over-color — 5 categories max.
- Add edge weights by, say, the strength of the dependency. Visually fades the weak ones.
- Render twice: once with all nodes (the master), once collapsed by cluster (the executive summary). Link both from the README.
Next: 04-final-reflection.md