b6eb97c49a
Step 1-2: Backup existing code - builtin/ → builtin_legacy/ (unchanged backup) - custom/pe_accel/ → custom/pe_accel_legacy/ (unchanged backup) Step 3-4: New pipeline types and tiling - pe_types.py: StageType, Stage, TilePlan, PipelinePlan, PipelineContext, TileToken - tiling.py: generate_gemm_plan, generate_math_plan (ported from pe_accel) Step 5: Component implementations (ADR-0021 D4-D6) - PE_SCHEDULER: _feed_loop (singleton FIFO feeder) + plan generation - PE_FETCH_STORE: new component — TCM ↔ Register File - PE_GEMM: TileToken pipeline + legacy PeInternalTxn dual-mode - PE_MATH: TileToken pipeline + legacy dual-mode - PE_DMA: TileToken pipeline + legacy + fabric Transaction triple-mode - PE_TCM: TcmRequest handler with dual-channel BW serialization Step 6: Infrastructure - topology.yaml: pe_fetch_store component + chaining edges - components.yaml: pe_fetch_store_v1 registration - builder.py: PE_COMP_OFFSETS, _add_pe_internal_edges, PE view positions - Tests: node/edge counts, PE component sets updated All components handle both TileToken (pipeline) and PeInternalTxn (legacy). Token self-routing: components read next stage from token.plan, chain via out_port. 366 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
from pathlib import Path
|
|
|
|
from kernbench.topology.builder import _read_spec, resolve_topology
|
|
|
|
TOPOLOGY_PATH = Path(__file__).parent.parent / "topology.yaml"
|
|
|
|
|
|
def test_topology_yaml_loads_without_error():
|
|
# _compile_graph is still stubbed (returns None); load must not raise
|
|
resolve_topology(str(TOPOLOGY_PATH))
|
|
|
|
|
|
def test_pe_layout_structure():
|
|
spec = _read_spec(TOPOLOGY_PATH)
|
|
pe_layout = spec["cube"]["pe_layout"]
|
|
assert set(pe_layout["corners"]) == {"NW", "NE", "SW", "SE"}
|
|
assert pe_layout["pe_per_corner"] == 2
|
|
# derived total must equal original pe_per_cube: 8
|
|
assert pe_layout["pe_per_corner"] * len(pe_layout["corners"]) == 8
|
|
|
|
|
|
def test_pe_template_components():
|
|
spec = _read_spec(TOPOLOGY_PATH)
|
|
comps = spec["cube"]["pe_template"]["components"]
|
|
assert set(comps.keys()) == {
|
|
"pe_cpu", "pe_scheduler", "pe_dma", "pe_fetch_store",
|
|
"pe_gemm", "pe_math", "pe_mmu", "pe_tcm",
|
|
}
|
|
|
|
|
|
def test_pe_template_links_present():
|
|
spec = _read_spec(TOPOLOGY_PATH)
|
|
links = spec["cube"]["pe_template"]["links"]
|
|
required = {
|
|
"pe_cpu_to_scheduler_mm",
|
|
"scheduler_to_dma_mm",
|
|
"scheduler_to_gemm_mm",
|
|
"scheduler_to_math_mm",
|
|
"dma_to_tcm_bw_gbs", "dma_to_tcm_mm",
|
|
"gemm_to_tcm_bw_gbs", "gemm_to_tcm_mm",
|
|
"math_to_tcm_bw_gbs", "math_to_tcm_mm",
|
|
}
|
|
assert required.issubset(set(links.keys()))
|
|
|
|
|
|
def test_pe_dma_not_in_cube_components():
|
|
spec = _read_spec(TOPOLOGY_PATH)
|
|
assert "pe_dma" not in spec["cube"]["components"]
|
|
|
|
|
|
def test_pe_per_cube_removed():
|
|
spec = _read_spec(TOPOLOGY_PATH)
|
|
assert "pe_per_cube" not in spec["cube"].get("device", {})
|
|
|
|
|
|
def test_shared_resource_accel_slot():
|
|
# ADR-0014 D4: PE_GEMM and PE_MATH share PE_ACCEL capacity = 1
|
|
spec = _read_spec(TOPOLOGY_PATH)
|
|
comps = spec["cube"]["pe_template"]["components"]
|
|
assert comps["pe_gemm"]["attrs"]["shared_resource"] == "accel_slot"
|
|
assert comps["pe_math"]["attrs"]["shared_resource"] == "accel_slot"
|