You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
observatory: pipeline_graph_collector groups records into quantization+edge regions
Brings the AOT pipeline records under two top-level Region groups so the
HTML left-panel tree view stays compact and meaningful:
Session "<script-name>"
├── quantization/ top-level (aten-graph work)
│ ├── Annotated Model (prepare_pt2e)
│ ├── Calibrated Model (convert_pt2e input)
│ └── Quantized Model (convert_pt2e output)
└── edge/ top-level (edge dialect)
├── Pre-EdgeTransform/<method>
├── EdgeProgramManager EP
└── etrecord/ lazy nested under edge
├── ETRecord Exported/<method>
├── ETRecord Edge/<method>
└── ETRecord Extra/<module>
Design rationale:
- Quantization outputs (Annotated/Calibrated/Quantized Model) are still
aten graphs, not edge dialect, so they belong under their own top-level
region rather than under "edge".
- ETRecord operations are AOT-time (they save the float aten and edge
dialect programs), so they live under "edge" via a nested "etrecord"
group rather than appearing as a standalone "runtime" region.
- No per-call sub-regions ("prepare_pt2e", "convert_pt2e", "etc.") --
every region holds at least 2 records, and the per-call identity is
already in the record name.
Implementation:
- The runtime region stack only ever holds one chain at a time, so the
lens opens "quantization" and "edge" lazily through transition helpers
(`_transition_to_quantization`, `_transition_to_edge`) and closes the
previous sibling when transitioning. This is monotonic for the typical
AOT order (prepare -> convert -> to_edge -> ETRecord) but tolerates
a backward transition defensively.
- `_ensure_etrecord_region` first transitions to edge, then opens
"etrecord" as a child via a second contextlib.ExitStack.
- Three ExitStacks total (quantization, edge, etrecord) all close in
on_session_end in safe order (innermost first).
observatory.py fix: enter_context now pushes the Region onto the stack
*before* firing on_session_start so a lens that opens its own
enter_context inside that hook (as pipeline_graph_collector does) sees
the new frame as an inner Region rather than recursing into a fresh
outermost call.
tests/test_pipeline_graph_collector_regions.py (new):
- 8 tests covering: lazy region opening at session_start, transition
to_quantization, forward transition to_edge closes quantization,
etrecord nesting under edge, idempotent lazy etrecord open, every
region holds >=2 records, on_session_end closes all open stacks,
lens hooks fire exactly once per CLI run.
Verification:
PYTHONPATH=~ python -m pytest \
~/executorch/devtools/observatory/tests/ -v
-> 49 passed, 1 pre-existing unrelated failure
(test_per_layer_accuracy_lens, "psnr" key, untouched here).
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
0 commit comments