Generic phase splitting and steady state identification - #1009
Open
kyle-hoffmeyer wants to merge 20 commits into
Open
Generic phase splitting and steady state identification#1009kyle-hoffmeyer wants to merge 20 commits into
kyle-hoffmeyer wants to merge 20 commits into
Conversation
kyle-hoffmeyer
added this pull request to stack #1010
September 9, 2026 01:38
kyle-hoffmeyer
force-pushed
the
feat/generic_steady_state_identification
branch
from
September 9, 2026 02:00
a713d63 to
8e3c7f0
Compare
kyle-hoffmeyer
force-pushed
the
feat/generic_steady_state_identification
branch
from
September 11, 2026 18:03
7f05eef to
6420820
Compare
kyle-hoffmeyer
marked this pull request as ready for review
September 11, 2026 18:10
kyle-hoffmeyer
requested review from
ajassani,
devalshahamd,
gabeweisz,
spandoesai and
tsrikris
as code owners
September 11, 2026 18:10
…ion for llm inference
…ize tests. fix naming convention. allow for all modes to be ran at once
kyle-hoffmeyer
force-pushed
the
feat/generic_steady_state_identification
branch
from
September 11, 2026 22:32
cf34e56 to
2e70711
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Steady state identification and phase division previously required LLM inference serving annotations —
execute_*from vLLM,step[DECODE/EXTEND]from SGLang, orprefill[]/decode[]from ATOM. Steady state identification for LLM inference traces without these annotations as well as general traces was flaky.This PR introduces a tiered system where phase splitting and steady state identification adapt to the information available in the trace.
Implementation
Phase splitting (2 tiers):
Phase splitting is only relevant for LLM inference traces with distinct phases. Since there isn't a simple, reliable way of identifying LLM inference traces, we rely on the user to pass a new
--llm-inferenceflag when splitting a LLM inference trace.context_requests/generation_requestsfrom annotation names (unchanged)--llm-inferenceflag, no serving annotationscpu_opInput Dims. Extracting batch size this way has been found to be the most reliable. Iterations with batch size > 2x median are classified as prefill-bearing; the rest as decode.Tier 1 — Annotation-based phase splitting:
flowchart LR A[Iteration root] --> B[Parse annotation name] B --> C{context_requests > 0?} C -->|Yes| D[prefill_bearing] C -->|No| E{generation_requests > 0?} E -->|Yes| F[decode] E -->|No| G[skip / idle]Tier 2 — Shape-based phase splitting (
--llm-inference):flowchart LR A[All iteration roots] --> B[infer_batch_sizes_from_shapes] B --> C[batch_sizes per iteration] C --> D[Compute median batch size] D --> E{batch_size > 2x median?} E -->|Yes| F[prefill_bearing] E -->|No| G[decode]Steady state identification (3 tiers):
num_requestsis near peak (unchanged). Select windows by prefill/decode mode within the largest region.--llm-inferenceflag, no serving annotations--llm-inferenceflagDecode-baseline steady state (Tier 2):
Duration CV sliding window (Tier 3):
Other changes
Trace splitter improvements:
--store-single-iteration,--find-steady-state, and--divide-phasescan now all run in a single invocation.-iis specified without--store-single-iteration, the selected iterations are extracted as a single trace with ancestor context — parent frames from the split root up to the process entry are included, but not their other children.warmup/wrapuproots. This enables splitting of diffusion traces (e.g., HunyuanVideo: 4 denoising steps = 58% GPU → with bookends = 100%).Tests
Verification of LLM inference splitting
For each of 26 LLM inference traces, we stripped the serving annotations (
execute_*,step[*]) and ran the full pipeline on both versions: the annotated trace uses the annotation-based path, the stripped trace uses the generic detection cascade + shape-based phase classification.Root detection (26 traces):
CompiledFxGraphannotation below every model layer in addition to the TraceLens recognized annotations. The annotation approach splits by iteration whereas stripped approach splits by the model layer. Another trace follows issue 3 described here: #1018.Phase classification (23 traces where roots matched):
Steady state window overlap (23 root-matched traces):
Restricted to the 23 traces where both paths found the same number of iteration roots, so the comparison is apples-to-apples. Overlap = percentage of the stripped path's selected window that falls within the annotation path's selected window.
All 23 traces achieve 100% mixed window overlap — the shape-based path selects iterations that are entirely within the annotation path's steady state window.
Decode-only window overlap is 100% on 22 traces. The 1 exception is
gemma_prefill: a pure prefill trace where the annotation path correctly finds no decode-only run (returns empty), but the shape-based path misclassifies all iterations as decode (the pure-prefill limitation) and returns a window.The shape-based path uses decode-baseline region finding: it filters out prefill-bearing iterations, runs peak-proximity scan on the decode-only batch sizes (which approximate concurrency — 1 token per sequence in decode), then maps the region back to full iteration indices. This produces a region similar to the annotation path's concurrency-based region, since decode batch size ≈
num_requests. Within the region, mixed mode prefers windows containing at least one prefill-bearing iteration (matching the annotation path's behavior).Verification of generic splitting
Ran evaluation script on 8 multi-iteration traces spanning training (OWLv2, DLRM) and LLM inference (DeepSeek, GPT-OSS) workloads. The evaluation checks root detection, GPU coverage, kernel count consistency (CV across iterations), duration consistency, and kernel shape similarity.
All pass.
Regression tests (
tests/test_trace_split.py)New test file that runs the trace splitting tool on real traces and compares output against checked-in reference splits. Covers inference fixtures (
tests/traces/inference/) and multi-iteration fixtures (tests/traces/trace_splitter_traces/) spanning training, LLM inference, and diffusion workloads.5 test functions:
test_trace_split--store-single-iterationfor first, middle, and last iterations. Compares each output.json.gzagainstsplit_traces/references.test_trace_split_steady_state--find-steady-state. Compares output againststeady_state_traces/references.test_trace_split_divide_phases--divide-phases. Compares output againstphase_split_traces/references (LLM traces only).test_trace_split_no_annotationsuser_annotationevents from multi-iteration traces, re-runs splitting, and asserts the output matches the annotated references (minus annotations). Passes--llm-inferencefor sglang/vllm traces. Validates that generic detection produces equivalent splits.test_trace_not_splittablesmall_traces/returnNOT_SPLITTABLE.Trace fixtures:
tests/traces/trace_splitter_traces/tests/traces/trace_splitter_traces/small_traces/Multi-iteration trace breakdown (see
tests/traces/trace_splitter_traces/README.md):dlrm-rank5google_owlv2_h100google_owlv2_mi300owlv2-h100owlv2-mi300owlv2-vision-mi300sglang_deepseek_mi300vllm_gptoss_mi300All reference directories support
--update-referencesto regenerate golden outputs.Notes
Known limitations of the shape-based path:
cpu_opshapes: Some traces (e.g.,amd_vllm_gptoss_20b) have noInput Dimson anycpu_op— the entire model runs inside CUDA graphs. The--llm-inferenceflag detects this (all batch sizes are None) and falls through to the generic duration-CV path gracefully.