Capstone 02 — NPU Graph Optimization Pipeline

Phase: 11 — Capstone | Difficulty: ⭐⭐⭐⭐⭐ | Time: 5–6 hours

End-to-end pipeline: analyze FX graph for NPU compatibility → export ONNX → quantize → validate accuracy delta.

What you build

  • SUPPORTED_OPS set — ops supported by the simulated NPU
  • analyze_fx_graph — symbolic trace, compute op coverage %
  • export_to_onnx — export with opset 17 to BytesIO buffer
  • compute_accuracy_delta — relative error + cosine similarity + passes_gate (max < 5%)
  • run_pipeline — 4-stage pipeline report with recommendations

Integrates

Phase 04 FX graph + Phase 05 ONNX + Phase 03 quantization + Phase 07 profiling recommendations

Run

pip install -r requirements.txt
python lab.py
pytest test_lab.py -v