Skip to content

feat(trace): read TraceLens system findings into the specialist evidence and the profiler digest - #2844

Merged
chaojhou merged 7 commits into
mainfrom
feat/tracelens-system-findings
Nov 27, 2026
Merged

chaojhou merged 7 commits into
mainfrom
feat/tracelens-system-findings

Conversation

@lishuoshuo-amd

@lishuoshuo-amd lishuoshuo-amd commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2714

Problem and resulting behavior

TraceLens' analysis.json lists the system bottlenecks it finds under system_optimizations.

  • There are five fixed titles: High GPU Idle Time, Exposed Collective Communication, and H2D / D2H / D2D Memory Copy Overhead.
  • Each entry carries fixed metric rows (metric, value, unit), a report priority, a node on multi-node reports, and a resolution.
  • The TraceLens revision Hyperloom pins (1f6d618) emits it: system_tasks() in post_processing/analysis_json.py, and SystemTask / SystemMember in candidate_schema.py.

Nothing in Hyperloom read the list. Its only occurrence was the empty placeholder the non-LLM route writes (_perf_report_analysis.py:112). System bottlenecks reached the loop two indirect ways:

  • Executive Summary shares: the profiler digest's dominant_direction routes the dominant idle or comm share to a specialist domain.
  • Prose: the coordinator prompt pointed at the ## System-Level Optimizations heading of analysis.md, which it sees only after calling show_analysis_md. Specialists got only the report path.

The resolutions, which name the lever, and the H2D / D2H / D2D split were therefore never in front of the agents that author explore variants.

Change

The change mirrors the fusion-findings path #2649 added.

  • Reader: tracelens_report.system_findings reads the list from the analysis.json beside analysis.md, in TraceLens' order.
    • Each finding keeps operation, node (empty off multi-node), priority and its metric rows (value is None when TraceLens could not read it). The resolution stays in the report, where the agents read it.
    • system_finding_summary renders a finding on one line: priority, title, node and its share metric (the first % row, the one TraceLens ranks by). TraceLens parses analysis.json back from the model-written analysis.md, so a block whose table is off-contract has no % row (an older-format block reads "members": []); its share reads share: n/a and the finding stays listed. Both consumers below use it.
  • State: record_trace_analyze stores the list as last_trace_analyze["system_findings"], next to fusion_findings.
  • Specialists:
    • roofline_evidence carries the findings, capped at 8 rows like the hot kernels and fusion findings.
    • Section 4a lists each finding on that one line and points at its fix under ## System-Level Optimizations in the analysis.md whose path the section already prints; the fix text is not copied into the prompt. A short paragraph maps each family to its knobs (idle: CUDA-graph capture, batch size, async scheduling; exposed communication: parallel layout, compute/communication overlap; memory copies: pinned memory, non-blocking copies, keeping tensors on device), splits the two routes as the fusion paragraph does (a server arg or env is an explore variant, a source change at a call site such as .item() or a redundant .contiguous() is a patch there, neither a kernel rewrite), and says a family with no finding is one TraceLens did not flag.
    • The section is absent when the list is empty, so the non-LLM route, which always writes [], never reads as "no bottleneck".
  • Coordinator:
    • profiler_digest gains a system_findings block with the same one-line summaries.
    • orchestration.md points the system-bottleneck guidance at that block, says the specialist gets the same lines, and that each fix is under the analysis.md heading. It applies the same split: an explore variant where a server arg or env exists, otherwise a specialist patch at the call site the fix names.

Gating or reordering kernel dispatch on these findings is left out, as the triage on #2714 proposed. So are new thresholds and switches. Producing system findings on the non-LLM route would need TraceLens changes.

Tests

The tests pin the reader of TraceLens' format, the one-line summary, the state key set and the flow into both prompts. No test asserts prompt wording (review rule T6).

  • common/tests/test_tracelens_report.py:
    • system_findings reads TraceLens' order, metric rows including a null value, node and priority, and carries no resolution;
    • a report without the key, and a missing report, read as none;
    • system_finding_summary shows the first % row (the share TraceLens ranks by), n/a for an unreadable value, and the node.
  • test_record_trace_analyze_lock.py: the canonical key set gains system_findings (17 keys).
  • test_specialist_roofline_evidence.py: one flow test writes an analysis.json with a conformant finding and one without a share row beside analysis.md, records it through SharedState.record_trace_analyze, and asserts both one-line summaries reach the coordinator's to_prompt_summary() and the specialist's section after warm_specialist_params, with no exception for the share-less finding and neither block for an empty list. It fails when the state stores [], when dispatch drops the key, when either renderer's call is removed, or when the share-less finding raises.

Commands run:

  • pytest on the files above plus test_shared_state_renderers.py, test_record_trace_analyze_disk_recovery.py, test_roofline_executor_units.py, test_roofline_executor.py, test_roofline_comparison_pipeline.py, test_prelude_roofline.py, test_specialist_prompt_builder_coverage_unit.py, test_prompt_phase_scoping.py, test_kernel_request_handlers_units.py, test_resume.py, test_regression_locks.py, test_forge_handoff.py, test_per_domain_prompts.py, test_coordinator_runtime.py and test_shared_state_kernel_opt.py. All pass.
  • ruff check and ruff format --check on the touched files.
  • python scripts/code_metrics.py --base-ref origin/main: PASSED.

The reader's field names come from the pinned TraceLens schema and producer code. No real TraceLens-rendered analysis.json with system findings was available locally, because TraceLens imports its whole library on import.

Size/complexity

No trigger crossed.

  • record_trace_analyze and warm_specialist_params each went from 20 to 19 (radon). Their findings and evidence-row reads moved into _tracelens_findings and _evidence_rows; the latter also replaces three copies of the same [:8] slice.
  • build_profiler_digest stays at 19, with the new block in _system_findings_lines.
  • dispatch.py was already over the 800-line warning.

Observable effect

  • A dispatched specialist's roofline evidence now lists TraceLens' system bottlenecks, one line each (priority, title, node, share of GPU time), tells it to read each fix under ## System-Level Optimizations in analysis.md, and says which knob family each points at. Before, it got only the analysis.md path, with nothing saying a system bottleneck was there. For TraceLens' maximum of five findings the section is about 970 characters, against about 2,760 when each finding carried its metrics and 300 characters of its fix.
  • The coordinator's profiler_digest gains a system_findings block, so it sees the system bottlenecks without calling show_analysis_md.
  • last_trace_analyze gains system_findings. A resumed state without it reads as no findings.

Breaking changes

No.

PR addresses single concern

Yes: reading TraceLens' system findings into the agents that act on them.

Upstream root cause

None; Hyperloom-side.

Not in this PR

  • Gating or reordering kernel dispatch on a system-bound trace, which the issue names as an option. That waits until runs show the findings predict where kernel speedups stall.
  • System findings on the non-LLM route, which writes system_optimizations: [] by construction.

…nce and the profiler digest

TraceLens' analysis.json lists the system bottlenecks it finds
(system_optimizations: High GPU Idle Time, Exposed Collective
Communication, H2D / D2H / D2D Memory Copy Overhead), each with fixed
metric rows, a report priority, a node and a resolution. Nothing in
Hyperloom read it: the coordinator was pointed at the analysis.md
heading and specialists got only the report path.

- tracelens_report.system_findings reads the list beside analysis.md,
  in TraceLens' order, as record_trace_analyze already reads
  fusion_optimizations; system_metric_text renders one metric row.
- record_trace_analyze keeps it as last_trace_analyze["system_findings"].
- Specialists get it in roofline_evidence and see each finding's
  metrics and the first 300 characters of its fix, with the knob
  family each title points at; the section is absent when TraceLens
  reported none (the non-LLM route always writes an empty list).
- profiler_digest gains a system_findings block (priority, title,
  share metric), and orchestration.md points the coordinator at it.

record_trace_analyze and warm_specialist_params move their findings
and evidence-row reads into helpers, which keeps both under the
complexity ceiling.

Refs #2714
@lishuoshuo-amd
lishuoshuo-amd requested a review from a team as a code owner November 23, 2026 07:46
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code metrics gate: PASSED

Judged: the 9 files this change touches. Files it does not touch never fail it; anything found there is listed under Outside this change for information.

Dimension Limit New Worse Improved Over the limit vs base
Cyclomatic complexity fails > 20 0 0 0 0 +0
Cognitive complexity fails > 30 0 0 0 0 +0
Function length (lines) fails > 60 0 0 0 0 +0
Nested block depth fails > 4 0 0 0 0 +0
Parameter count fails > 5 0 0 0 0 +0
Module length (lines) warns > 800, fails > 1200 0 0 0 0 +0
Duplicated lines per file fails > 0 0 0 0 0 +0
Dead code (vulture) fails > 0 0 0 0 0 +0
Directory size (entries) fails > 50 0 0 0 0 +0
Check Findings Effect
Comments 0
Broad catch without a reason 0
Broad catch that records nothing 0
English only 0
Production code imports test code 0
Repeated literals 0
A1 Private name of another package 0
A8 Flag argument 0
A9 Tuple return 0
A10 Raw vocabulary comparison 0
A11 Hidden global write 0
A12 Pure forwarder 0
A12 Single-implementation abstraction 0

Module length warning: over 800 lines, within the 1200-line failure limit (not failing): 1

Module Lines Limit
src/hyperloom/orchestrator/specialists/dispatch.py 965 warns > 800

Verdict computed by the gate scripts in /home/runner/work/_temp/code-metrics-gate, not by this tree's copy.

Thresholds and sources: [tool.hyperloom.code_metrics] in pyproject.toml. Tools: complexipy 8.0.1, jscpd 5.4.1, radon 6.0.1, ruff 0.16.2, vulture 2.16.

lishuoshuo-amd and others added 3 commits November 23, 2026 16:04
…v variant

The system-findings paragraph in section 4a called every finding
"launch-level" and "worked through server args and envs", including the
D2D copies and D2H reads whose TraceLens fix is a change at a call site
(a `.item()`, a redundant `.contiguous()` or clone), which a patch-mode
specialist delivers as a patch. The paragraph and the coordinator bullet
now split the two the way the fusion paragraph already does: a lever the
framework exposes as a server arg or env is an `explore` variant, a fix
that names a source change is a patch at that call site, and neither is
a kernel rewrite.

Refs #2714
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its fix in analysis.md

The specialist section carried every metric row and the first 300
characters of each finding's resolution, plus a long guidance paragraph.
The resolution already lives under `## System-Level Optimizations` in
the analysis.md whose path the section prints, so the section now lists
each finding on one line (priority, title, node, share) and tells the
specialist to read the fix there; the guidance is cut to the lever
families and the explore-or-patch split.

`system_finding_summary` renders that line for both the section and
the profiler digest, replacing the digest's private copy, and the
reader no longer stores the resolution nothing reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lishuoshuo-amd and others added 2 commits November 26, 2026 10:57
…and the state key set

The removed cases re-pinned the reader's output through the state, the
dispatch and both renderers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every TraceLens system finding carries a % row and is ranked by its
first one, so the summary reads that row directly: the other units'
formatting, the no-share fallback and the digest's dict guard had no
input that reaches them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chaojhou chaojhou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #2844 -- feat(trace): read TraceLens system findings into the specialist evidence and the profiler digest

What it does: TraceLens' analysis.json lists system bottlenecks (GPU idle, exposed communication, memory copies) that nothing in Hyperloom read. The PR adds a reader, stores the list in last_trace_analyze, and shows one line per finding (priority, title, share of GPU time) in the coordinator's profiler_digest and in a dispatched specialist's roofline evidence, pointing both at the fix text in analysis.md. On a report that follows TraceLens' contract it works as described: a real analysis.json rendered by the pinned TraceLens reads back as five correct lines.

Risk: high -- state/_shared_state/roofline.py writes the state every agent prompt is rendered from, and the new block is built on every coordinator turn
Decisions for a human:

  • src/hyperloom/orchestrator/state/_shared_state/roofline.py -- last_trace_analyze and state.json gain system_findings, and the coordinator prompt gains a system_findings block on every turn in every phase, uncapped (the specialist's copy is capped at 8; the pinned TraceLens emits at most five) -- is a per-turn block of up to five lines in the coordinator prompt wanted, or only while a system bottleneck can still be acted on?
  • src/hyperloom/orchestrator/prompts/orchestration.md -- the coordinator is now told to turn a system finding into an explore variant or a specialist patch, and the specialist prompt names knob families per bottleneck; nothing gates or reorders kernel work on these findings, which issue #2714 also asks for and the description leaves out -- accept the prompt-only step and keep #2714 open for the gating?
  • src/hyperloom/common/tracelens_report.py -- the titles and metric names are copied from the report into both prompts without a length bound, as the fusion findings already are -- acceptable for text that comes from a model-written report?

Blocking issues: 2

  1. [free:summary-raises-without-share-row] A system finding without a share row ends the session as an emergency stop [verified]
    Problem: src/hyperloom/common/tracelens_report.py:83 takes next(m for m in finding["metrics"] if m["unit"] == "%") with no default, and it runs inside both prompt builders (src/hyperloom/inference_optimizer/roofline_snapshot.py:650, src/hyperloom/orchestrator/prompts/roofline_evidence_section.py:130). The pinned TraceLens parses analysis.json back from the model-written analysis.md and emits "members": [] for a system block with no Data table, or drops every row that is not exactly a contract metric (_parse_system_members, from_cells); its validator is a step of its own skill that proceeds after two failed retries, and Hyperloom renders the JSON unconditionally. TraceLens' own golden system block rendered by the pinned TraceLens loses its share row with a one-token deviation (GPU Idle % for Idle %, a third table column, **Data**: for **Data:**), and the repo's fixture tracelens_v03_llama70b_analysis.md:196-211 (an older-format tier=system block with a three-column table) renders to {"operation": "H2D memcpy hygiene check", "members": [], "priority": 1}. With such a finding recorded, SharedState.to_prompt_summary() raises at line 83 (in the coordinator: RuntimeError: coroutine raised StopIteration) and build_specialist_prompts raises RuntimeError; at the merge base both render. The last commit removed the summary's no-share fallback as having no input that reaches it.
    Impact: the finding is stored in state and prompt composition runs before the dispatcher pump, so every tick fails with nothing dispatched and no model call made; a coordinator run with the finding in state stops with reason emergency after 25 tick crashes, where the same run with a share row completes. The finding survives a save and reload. One off-contract table costs the session.
    Action: restore a no-share rendering in system_finding_summary, the one owner both renderers call: a missing share row reads n/a like an unreadable one, so a bottleneck TraceLens flagged stays visible. If off-contract blocks should stay out of the prompts instead, skip them in system_findings. Either way, correct the "every finding has one" sentence in the docstring and the description.
  2. [free:consumer-paths-unpinned] Nothing fails when the feature's delivery is cut [verified]
    Problem: the two effects the PR exists for have no test through any entry point. With src/hyperloom/orchestrator/state/_shared_state/roofline.py:197 storing [] for system_findings, with "system_findings" removed from src/hyperloom/orchestrator/specialists/dispatch.py:51, or with the call at src/hyperloom/inference_optimizer/roofline_snapshot.py:703 or src/hyperloom/orchestrator/prompts/roofline_evidence_section.py:221 deleted, every test still passes (four mutants, 2300 tests over the 58 related test files each); src/hyperloom/inference_optimizer/tests/test_record_trace_analyze_lock.py:25 pins only that the key exists. The fusion path this mirrors is pinned in state, in the dispatch copy and in the section. The description gives review rule T6 as the reason; T6 forbids asserting on wording, not driving the entry point and asserting the result.
    Impact: a later edit can drop the block from either prompt with CI green, and finding 1's fallback was removed with no test left to object: the tests this PR deleted included a finding without a share row. AGENTS.md Test the contract, not the plumbing asks for such flows to be covered through their entry point.
    Action: one flow test, not four layered ones: write an analysis.json beside analysis.md with one conformant finding and one without a share row, call SharedState.record_trace_analyze, and assert that the conformant finding's system_finding_summary line is in build_profiler_digest's output and in roofline_evidence_section's after warm_specialist_params, that the other finding raises nothing, and that both blocks are absent for an empty list. It asserts no prompt wording.

Checked: the whole diff; the pinned TraceLens (1f6d618) producer and parser of system_optimizations, its five titles, metric rows, ranking and validator; how Hyperloom invokes TraceLens on the agent and non-LLM routes; every writer and reader of last_trace_analyze; the path from warm_specialist_params to the specialist prompt and from build_profiler_digest to the coordinator prompt; orchestration.md's edited bullet and its phase block; docs, SKILL.md files and prompts for text enumerating the digest or the evidence; the description's numbers; issue #2714; open PRs #2856, #2760, #2849; CI at the head | Ran: the two changed test files on the head merged with main f9c6dc9 (15 passed) and the description's test list there (776 passed); a real analysis.json rendered by the pinned TraceLens and read by the head (five correct lines); a probe recording a finding with and without a share row on the merged tree and the base; nine mutants; radon on the three functions the description names; ruff. A workflow of three readers by area, two skeptics per candidate | Skill: c11e54f4ee37 | Model: claude-fable-5-2 | Base: 5c627f6 | Head: 7c902e6

…ing every prompt

TraceLens parses analysis.json back from model-written analysis.md, so a
system block whose table is off-contract comes back with no `%` row (an
older-format block reads `"members": []`). The summary took that row
without a default, so a recorded finding raised in both prompt builders
on every turn. A missing share now reads `share: n/a`, like an
unreadable one, and the finding stays listed.

One flow test records such a report through `record_trace_analyze` and
asserts both findings reach the coordinator's prompt summary and the
specialist's section after `warm_specialist_params`, and that neither
block appears for an empty list. The section's guidance paragraph is a
module constant, so the list holds no implicit string concatenation.
@chaojhou
chaojhou dismissed their stale review November 27, 2026 03:25

Both findings are fixed at 6717f5f; see the re-review comment.

@chaojhou

Copy link
Copy Markdown
Collaborator

PR #2844 -- feat(trace): read TraceLens system findings into the specialist evidence and the profiler digest

What it does: TraceLens' analysis.json lists system bottlenecks (GPU idle, exposed communication, memory copies) that nothing in Hyperloom read. The PR adds a reader, stores the list in last_trace_analyze, and shows one line per finding (priority, title, share of GPU time) in the coordinator's profiler_digest and in a dispatched specialist's roofline evidence, pointing both at the fix text in analysis.md. A finding whose table TraceLens could not read back is listed with share: n/a.

Risk: high -- state/_shared_state/roofline.py writes the state every agent prompt is rendered from, and the new block is built on every coordinator turn
Decisions for a human:

  • src/hyperloom/orchestrator/state/_shared_state/roofline.py -- last_trace_analyze and state.json gain system_findings, and the coordinator prompt gains a system_findings block on every turn in every phase, uncapped (the specialist's copy is capped at 8; the pinned TraceLens emits at most five) -- is a per-turn block of up to five lines in the coordinator prompt wanted, or only while a system bottleneck can still be acted on?
  • src/hyperloom/orchestrator/prompts/orchestration.md -- the coordinator is told to turn a system finding into an explore variant or a specialist patch, and the specialist prompt names knob families per bottleneck; nothing gates or reorders kernel work on these findings, which issue TraceLens Analysis: System Bottlenecks #2714 also asks for and the description leaves out -- accept the prompt-only step and keep TraceLens Analysis: System Bottlenecks #2714 open for the gating?
  • src/hyperloom/common/tracelens_report.py -- the titles and metric names are copied from the report into both prompts without a length bound, as the fusion findings already are -- acceptable for text that comes from a model-written report?

Blocking issues: none

Checked: the delta 7c902e6..6717f5f and the whole diff; system_finding_summary against every shape the pinned TraceLens parser can emit and the reader can return; the new flow test and its helpers; the guidance paragraph moved to a module constant (byte-identical); the description and the new commit message against the head; CI at the head (every check green: 12 test shards, both coverage jobs, code-metrics, pr-hygiene, lint, docs) | Ran: the three PR test files on the head merged with main 6d84b5a (28 passed); the round-1 probes there (a finding without a share row renders P1 H2D memcpy hygiene check share: n/a in the digest and the specialist section; the repo fixture rendered by the pinned TraceLens gives the same line; a Coordinator run with that finding in state completes 40 ticks with no crash, where round 1 stopped as an emergency at tick 25); five mutants against the flow test (the state write, the dispatch copy, either renderer's call, next() without a default: each fails it); the 56 related test files on the merged tree (2264 passed); ruff. An independent reader re-read the head | Skill: c11e54f4ee37 | Model: claude-fable-5-2 | Prior: free:summary-raises-without-share-row fixed, free:consumer-paths-unpinned fixed | Base: 5c627f6 | Head: 6717f5f

LGTM

@chaojhou chaojhou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean review at 6717f5f; merges clean on latest main. Merging with the maintainer's consent to the decisions on the card.

@chaojhou
chaojhou merged commit 8d91002 into main Nov 27, 2026
42 of 44 checks passed
@chaojhou
chaojhou deleted the feat/tracelens-system-findings branch November 27, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants