Skip to content

Commit 73f847e

Browse files
authored
Merge pull request #1786 from Shashank-Tripathi-07/fix/labs-vol2-lab07-16-audit
Lab numerical corrections: lab_08 crossover (3-4 weeks), lab_09 FlashAttention savings, lab_11 false alerts (778/day matches inline formula), lab_14 energy deficit (2,400,000x verified).
2 parents 22833e7 + 429973a commit 73f847e

6 files changed

Lines changed: 61 additions & 27 deletions

File tree

labs/vol2/lab_08_inference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# Tabbed Structure (35-40 minutes):
1818
# Part A — The Serving Cost Inversion (12-15 min)
19-
# Serving cost > training cost within ~6 weeks at 100 QPS.
19+
# Serving cost > training cost within ~3-4 weeks at 100 QPS.
2020
# Batching trades latency for throughput along a hockey stick.
2121
#
2222
# Part B — The KV Cache Wall + Fleet Design Challenge (20-25 min)
@@ -199,7 +199,7 @@ def _(mo):
199199
options={
200200
"A) 6 months -- training dominates for a long time": "A",
201201
"B) 3 months -- serving catches up gradually": "B",
202-
"C) ~6 weeks -- serving cost grows fast": "C",
202+
"C) ~3-4 weeks -- serving cost grows fast": "C",
203203
"D) Never -- training is always more expensive": "D",
204204
},
205205
label="You spent $2M training a 70B LLM. At 100 QPS and $0.01/query, when does cumulative serving cost exceed training cost?",

labs/vol2/lab_09_perf_engineering.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _(LAB_CSS, mo):
189189
</div>
190190
<div style="display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;">
191191
<span class="badge badge-fail">H100 at 0.3% utilization</span>
192-
<span class="badge badge-warn">FlashAttention 256x savings at 32K</span>
192+
<span class="badge badge-warn">FlashAttention 128x savings at 32K</span>
193193
<span class="badge badge-info">Profile first, optimize second</span>
194194
</div>
195195
</div>
@@ -878,7 +878,7 @@ def build_part_c():
878878
<div style="font-style: italic; font-size: 1.0rem; color: #1e293b; line-height: 1.65;">
879879
"Standard attention materializes an N x N score matrix in HBM, costing O(N^2)
880880
memory. FlashAttention tiles the computation to SRAM, reducing memory to O(N).
881-
The savings ratio grows linearly with sequence length: 32x at 8K, 256x at 32K."
881+
The savings ratio grows linearly with sequence length: 32x at 8K, 128x at 32K."
882882
</div>
883883
</div>
884884
"""))
@@ -1351,8 +1351,8 @@ def build_synthesis():
13511351
<div style="margin-bottom: 10px;">
13521352
<strong>2. Not all fusion is equal.</strong>
13531353
FlashAttention saves 60x more HBM traffic than elementwise fusion because
1354-
the attention score matrix grows as O(N^2). The savings ratio widens to 256x
1355-
at 32K tokens and 1024x at 128K tokens.
1354+
the attention score matrix grows as O(N^2). The savings ratio widens to 128x
1355+
at 32K tokens and 512x at 128K tokens.
13561356
</div>
13571357
<div>
13581358
<strong>3. Profile first, optimize second.</strong>
@@ -1420,7 +1420,7 @@ def _(COLORS, ledger, mo, pA_pred):
14201420
if pA_pred.value is not None:
14211421
ledger.save(chapter=9, design={
14221422
"roofline_diagnostic": "memory-bound",
1423-
"flash_savings_ratio_32k": 256,
1423+
"flash_savings_ratio_32k": 128,
14241424
"optimization_methodology": "profile-diagnose-treat",
14251425
})
14261426

@@ -1435,7 +1435,7 @@ def _(COLORS, ledger, mo, pA_pred):
14351435
<span style="color: #64748b;">roofline_diagnostic:</span>
14361436
<span style="color: {COLORS['RedLine']};">memory-bound</span><br/>
14371437
<span style="color: #64748b;">flash_savings_32k:</span>
1438-
<span style="color: {COLORS['GreenLine']};">256x</span><br/>
1438+
<span style="color: {COLORS['GreenLine']};">128x</span><br/>
14391439
<span style="color: #64748b;">methodology:</span>
14401440
<span style="color: {COLORS['BlueLine']};">profile &rarr; diagnose &rarr; treat</span>
14411441
</div>

labs/vol2/lab_11_ops_scale.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Staged rollout observation windows depend on traffic and canary %.
2323
#
2424
# Part E — The Alert Fatigue Wall (10 min)
25-
# 3-sigma alerting on 1000 metrics produces 864 false alerts/day.
25+
# 3-sigma alerting on 1000 metrics produces 778 false alerts/day.
2626
#
2727
# Design Ledger: chapter="v2_11"
2828
# ─────────────────────────────────────────────────────────────────────────────
@@ -152,7 +152,7 @@ def _(LAB_CSS, mo):
152152
<div style="display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;">
153153
<span class="badge badge-fail">$1.08M/day silent failure</span>
154154
<span class="badge badge-warn">Capacity crossed at 50 models</span>
155-
<span class="badge badge-info">864 false alerts/day at 3-sigma</span>
155+
<span class="badge badge-info">778 false alerts/day at 3-sigma</span>
156156
</div>
157157
</div>
158158
"""),
@@ -1006,7 +1006,7 @@ def build_part_e():
10061006
<div style="color: {COLORS['TextSec']}; font-size: 0.92rem; margin-top: 6px;
10071007
line-height: 1.55; max-width: 700px;">
10081008
With 3-sigma alerting on 1,000 metrics checked every 5 minutes, the fleet
1009-
produces ~864 false alerts per day. Per-metric raw alerting is mathematically
1009+
produces ~778 false alerts per day. Per-metric raw alerting is mathematically
10101010
useless at fleet scale. Hierarchical monitoring is the only viable solution.
10111011
</div>
10121012
</div>
@@ -1114,7 +1114,7 @@ def build_synthesis():
11141114
"complexity_crossover": 50,
11151115
"silent_failure_24h_cost": 1_080_000,
11161116
"platform_breakeven": 20,
1117-
"alert_fatigue_threshold": 864,
1117+
"alert_fatigue_threshold": 778,
11181118
})
11191119

11201120
return mo.vstack([
@@ -1138,8 +1138,8 @@ def build_synthesis():
11381138
</div>
11391139
<div>
11401140
<strong>3. Raw alerting is mathematically useless at fleet scale.</strong>
1141-
3-sigma alerting on 1,000 metrics produces 864 false alerts/day. Hierarchical
1142-
monitoring reduces this to ~86/day. The solution mirrors hierarchical AllReduce
1141+
3-sigma alerting on 1,000 metrics produces 778 false alerts/day. Hierarchical
1142+
monitoring reduces this to ~78/day. The solution mirrors hierarchical AllReduce
11431143
from collective communication: aggregate before alerting.
11441144
</div>
11451145
</div>
@@ -1173,7 +1173,7 @@ def build_synthesis():
11731173
"Self-Assessment: Can you answer these?": mo.md("""
11741174
1. At what model count does operational load exceed team capacity, and why?
11751175
2. Why does a 0.5% CTR drop cost $1.08M when undetected for 24 hours?
1176-
3. How does hierarchical monitoring reduce false alerts from 864/day to ~86/day?
1176+
3. How does hierarchical monitoring reduce false alerts from 778/day to ~78/day?
11771177
11781178
*If you cannot answer all three from memory, revisit Parts A, B, and E.*
11791179
""")

labs/vol2/lab_14_sustainable_ai.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# Volume II, Chapter 14 — Sustainable AI
1010
#
11-
# Core Invariant: AI compute demand outpaces hardware efficiency by 195,000x.
11+
# Core Invariant: AI compute demand outpaces hardware efficiency by 2,400,000x.
1212
# Geography is a 40x carbon lever. Embodied carbon dominates on clean grids.
1313
# The Jevons Paradox means efficiency gains can INCREASE total consumption.
1414
# Only absolute caps guarantee net reduction.
@@ -145,7 +145,7 @@ def _(mo, LAB_CSS, COLORS):
145145
</span>
146146
</div>
147147
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
148-
<span class="badge badge-fail">195,000x Energy Deficit</span>
148+
<span class="badge badge-fail">2,400,000x Energy Deficit</span>
149149
<span class="badge badge-warn">40x Geography Gap</span>
150150
<span class="badge badge-info">Embodied Carbon Dominates on Clean Grids</span>
151151
<span class="badge badge-ok">Jevons Paradox: Efficiency Backfires</span>
@@ -171,7 +171,7 @@ def _(mo, COLORS):
171171
Learning Objectives
172172
</div>
173173
<div style="font-size: 0.9rem; color: {COLORS['TextSec']}; line-height: 1.7;">
174-
<div style="margin-bottom: 3px;">1. <strong>Quantify the energy deficit</strong>: calculate the 195,000&times; gap between AI compute demand growth (~3.4-month doubling) and hardware efficiency growth (~24-month doubling) over 7 years.</div>
174+
<div style="margin-bottom: 3px;">1. <strong>Quantify the energy deficit</strong>: calculate the 2,400,000&times; gap between AI compute demand growth (~3.4-month doubling) and hardware efficiency growth (~24-month doubling) over 7 years.</div>
175175
<div style="margin-bottom: 3px;">2. <strong>Apply the Jevons Paradox equation</strong> to show that 2&times; efficiency with elasticity 2.0 produces a 100% <em>increase</em> in total energy, and identify the elasticity threshold where efficiency gains guarantee net reduction.</div>
176176
<div style="margin-bottom: 3px;">3. <strong>Design a carbon-aware fleet strategy</strong> combining geographic optimization (40&times; lever), lifecycle management (embodied carbon), temporal scheduling, and absolute carbon caps to achieve a 50% emission reduction target.</div>
177177
</div>
@@ -368,7 +368,7 @@ def build_part_a():
368368
369369
You expect hardware efficiency to keep pace with AI compute demand &mdash; Moore's
370370
Law has always delivered. But AI demand doubles every 3.4 months while efficiency
371-
doubles every 24 months. Over 7 years, the gap is not 10x. It is 195,000x.
371+
doubles every 24 months. Over 7 years, the gap is not 10x. It is 2,400,000x.
372372
"""))
373373

374374
items.append(partA_pred)
@@ -458,9 +458,9 @@ def build_part_a():
458458

459459
# Prediction reveal
460460
_correct = partA_pred.value == "100000"
461-
_msg = ("You correctly identified the ~100,000x+ exponential chasm."
461+
_msg = ("You correctly identified the exponential chasm. The gap is ~2,400,000x over 7 years."
462462
if _correct else
463-
"The gap over 7 years is ~195,000x. Students intuitively expect hardware to 'keep up' "
463+
"The gap over 7 years is ~2,400,000x. Students intuitively expect hardware to 'keep up' "
464464
"because Moore's Law worked for decades. But AI demand grows 7x faster than efficiency.")
465465
items.append(mo.callout(mo.md(f"**{_msg}**"), kind="success" if _correct else "warn"))
466466

@@ -479,7 +479,7 @@ def build_part_a():
479479
480480
**At $t = 84$ months (7 years):**
481481
$$
482-
\\text{Gap} = 2^{84 \\times (1/3.4 - 1/24)} = 2^{84 \\times 0.253} = 2^{21.2} \\approx 195{,}000\\times
482+
\\text{Gap} = 2^{84 \\times (1/3.4 - 1/24)} = 2^{84 \\times 0.253} = 2^{21.2} \\approx 2{,}400{,}000\\times
483483
$$
484484
485485
Demand grows ~7x faster than efficiency. No amount of hardware improvement
@@ -1153,7 +1153,7 @@ def build_synthesis():
11531153
<div style="font-size: 0.92rem; color: {COLORS['Text']}; line-height: 1.75;">
11541154
<div style="margin-bottom: 10px;">
11551155
<strong>1. The energy wall is real and growing.</strong>
1156-
AI compute demand has outpaced hardware efficiency by ~195,000&times; over 7 years.
1156+
AI compute demand has outpaced hardware efficiency by ~2,400,000&times; over 7 years.
11571157
You cannot outrun this deficit with better chips alone.
11581158
</div>
11591159
<div style="margin-bottom: 10px;">

shared/config/footer-site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ website:
2020
- icon: github
2121
href: https://github.com/harvard-edge/cs249r_book
2222
aria-label: "View source on GitHub"
23-
background: light
23+
background: none
2424
border: true

shared/styles/_site-dark.scss

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,44 @@ table {
143143
}
144144

145145
// Footer dark mode
146-
.page-footer {
147-
background-color: #212529;
148-
border-top-color: #454d55;
146+
// Quarto renders the footer as .nav-footer; .page-footer is the SCSS variable name.
147+
// Both selectors are needed so the footer background is dark regardless of which
148+
// class Quarto generates.
149+
.page-footer,
150+
.nav-footer {
151+
background-color: #212529 !important;
152+
border-top-color: #454d55 !important;
149153
color: #adb5bd;
154+
155+
a {
156+
color: #adb5bd !important;
157+
&:hover { color: $accent-dark !important; }
158+
}
159+
}
160+
161+
// Navbar dropdown menus dark mode
162+
.navbar .dropdown-menu,
163+
.dropdown-menu {
164+
background-color: #252525 !important;
165+
border-color: #454d55 !important;
166+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4) !important;
167+
}
168+
169+
.navbar .dropdown-item,
170+
.dropdown-menu .dropdown-item {
171+
color: #d1d5db !important;
172+
background-color: transparent !important;
173+
174+
&:hover,
175+
&:focus {
176+
color: $accent-dark !important;
177+
background-color: rgba(165, 28, 48, 0.12) !important;
178+
}
179+
}
180+
181+
.navbar .dropdown-divider,
182+
.dropdown-menu .dropdown-divider {
183+
border-top-color: #454d55 !important;
150184
}
151185

152186
// Buttons

0 commit comments

Comments
 (0)