mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-11-14 18:24:37 -06:00
Ground technical mechanisms across chapters 4 through 16: - Ch 04: Zero-copy serialization, parDO execution, LSM-tree compactions, columnar compression - Ch 05: Strided tensor layout, autodiff DAG memory lifecycle, cuDNN algorithmic selection, FP16 vs BF16 - Ch 06: GQA key-value heads, dilated receptive field expansion, temporal BPTT unrolling - Ch 07: GPU stream asynchronous execution, dispatch latency, memory pool fragmentation, FX graph captures - Ch 08: All-reduce ring topology, bucketed overlap, activation recomputation, loss scaling - Ch 09: Influence function inverse Hessian, MinHash LSH bands, fastText classifier, Chinchilla 6ND - Ch 10: Taylor expansion pruning, feature distillation projection, INT32 accumulation, 2:4 sparsity indices - Ch 11: SIMT warp scheduling register residency, tensor vs pipeline parallelism - Ch 12: MFU definition, CUDA event synchronization barrier, PMU hardware counters, TTFT vs ITL physics - Ch 13: Chunked prefill co-scheduling, PagedAttention block tables, speculative verification, dispatch overhead - Ch 14: Point-in-time correctness, KS supremum distance, Taylor expansion retraining interval, PSI derivation - Ch 15: Embodied carbon lifecycle, confidential computing secure enclaves, evasion attacks, model inversion, federated constraints, Shapley combinatorial complexity - Ch 16: ResNet-50 filter reuse, batch-1 decode arithmetic intensity, Physical AI control loops, cluster scaling - Binder: Allow markdown bold formatting within callout definitions and add unit test
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
"""Unit tests for check_bold_definitions ensuring emphasis-bold.md invariants."""
|
|
|
|
from pathlib import Path
|
|
from binder.cli.commands._index_checks import check_bold_definitions
|
|
|
|
|
|
def test_bold_definitions_clean_case(tmp_path: Path):
|
|
ch1 = tmp_path / "01_intro.qmd"
|
|
ch1.write_text(
|
|
"The **dual mandate**\\index{Dual mandate!definition} requires that systems balance accuracy.\n"
|
|
"Here is a regular term with normal index: runtime\\index{Runtime!execution}.\n"
|
|
)
|
|
issues = check_bold_definitions(tmp_path)
|
|
assert issues == []
|
|
|
|
|
|
def test_bold_definitions_missing_bold(tmp_path: Path):
|
|
ch1 = tmp_path / "01_intro.qmd"
|
|
ch1.write_text(
|
|
"The dual mandate\\index{Dual mandate!definition} requires balance.\n"
|
|
)
|
|
issues = check_bold_definitions(tmp_path)
|
|
assert len(issues) == 1
|
|
assert issues[0].code == "def_missing_bold"
|
|
|
|
|
|
def test_bold_definitions_bold_index_not_def(tmp_path: Path):
|
|
ch1 = tmp_path / "01_intro.qmd"
|
|
ch1.write_text(
|
|
"We consider **Apache Arrow**\\index{Apache Arrow!in-memory format} in this section.\n"
|
|
)
|
|
issues = check_bold_definitions(tmp_path)
|
|
assert len(issues) == 1
|
|
assert issues[0].code == "bold_index_not_def"
|
|
|
|
|
|
def test_bold_definitions_duplicate_definition(tmp_path: Path):
|
|
ch1 = tmp_path / "01_intro.qmd"
|
|
ch1.write_text(
|
|
"The **ridge point**\\index{Ridge point!definition} is the roofline boundary.\n"
|
|
)
|
|
ch2 = tmp_path / "02_hardware.qmd"
|
|
ch2.write_text(
|
|
"Recall that the **ridge point**\\index{Ridge point!definition} is important.\n"
|
|
)
|
|
issues = check_bold_definitions(tmp_path)
|
|
dup_issues = [i for i in issues if i.code == "dup_definition"]
|
|
assert len(dup_issues) == 1
|
|
assert "Duplicate formal definition of 'Ridge point'" in dup_issues[0].message
|
|
|
|
|
|
def test_bold_definitions_structural_labels_ignored(tmp_path: Path):
|
|
ch1 = tmp_path / "01_intro.qmd"
|
|
ch1.write_text(
|
|
"**Context**:\\index{Context!callout} The system setup.\n"
|
|
"1. **Rule**: The primary invariant.\n"
|
|
"[^fn1]: **Term (Acronym)**\\index{Term!footnote}: Definition in note.\n"
|
|
": **Table Title**: Caption text.\n"
|
|
)
|
|
issues = check_bold_definitions(tmp_path)
|
|
assert issues == []
|