mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-19 01:14:07 -05:00
- Migrated all legacy constants from constants.py to hardware and model registries - Updated dozens of LEGO blocks in Volume 1 and Volume 2 to use Engine.solve and formulas - Resolved all resulting NameError, TypeError, and AttributeError exceptions in the inline Python blocks - Master Quarto HTML build now passes with zero execution failures
19 lines
963 B
Python
19 lines
963 B
Python
import re
|
|
import glob
|
|
|
|
qmds = glob.glob('book/quarto/contents/**/*.qmd', recursive=True)
|
|
for q in qmds:
|
|
with open(q, 'r') as f: c = f.read()
|
|
orig = c
|
|
|
|
# Check for dTime kwargs
|
|
c = c.replace('efficiency=', 'efficiency_eta=')
|
|
# Re-fix Engine.solve since that actually uses efficiency=
|
|
c = c.replace('Engine.solve(m_bert, h_a100, batch_size=batch_1, precision="fp32", efficiency_eta=1.0)', 'Engine.solve(m_bert, h_a100, batch_size=batch_1, precision="fp32", efficiency=1.0)')
|
|
c = c.replace('Engine.solve(m_bert, h_a100, batch_size=batch_32, precision="fp32", efficiency_eta=0.85)', 'Engine.solve(m_bert, h_a100, batch_size=batch_32, precision="fp32", efficiency=0.85)')
|
|
c = re.sub(r'Engine\.solve\(([^,]+),\s*([^,]+),\s*batch_size=([^,]+),\s*precision="([^"]+)",\s*efficiency_eta=([^\)]+)\)', r'Engine.solve(\1, \2, batch_size=\3, precision="\4", efficiency=\5)', c)
|
|
|
|
if c != orig:
|
|
with open(q, 'w') as f: f.write(c)
|
|
|