Repository navigation
feat(trace): read TraceLens system findings into the specialist evidence and the profiler digest - #2844
Conversation
…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
Code metrics gate: PASSEDJudged: 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.
Module length warning: over 800 lines, within the 1200-line failure limit (not failing): 1
Thresholds and sources: |
…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>
…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
left a comment
There was a problem hiding this comment.
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_analyzeand state.json gainsystem_findings, and the coordinator prompt gains asystem_findingsblock 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
explorevariant 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
- [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 takesnext(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 parsesanalysis.jsonback 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 %forIdle %, a third table column,**Data**:for**Data:**), and the repo's fixturetracelens_v03_llama70b_analysis.md:196-211(an older-formattier=systemblock 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) andbuild_specialist_promptsraises 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 reasonemergencyafter 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 insystem_finding_summary, the one owner both renderers call: a missing share row readsn/alike an unreadable one, so a bottleneck TraceLens flagged stays visible. If off-contract blocks should stay out of the prompts instead, skip them insystem_findings. Either way, correct the "every finding has one" sentence in the docstring and the description. - [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[]forsystem_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 ananalysis.jsonbeside analysis.md with one conformant finding and one without a share row, callSharedState.record_trace_analyze, and assert that the conformant finding'ssystem_finding_summaryline is inbuild_profiler_digest's output and inroofline_evidence_section's afterwarm_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.
Both findings are fixed at 6717f5f; see the re-review comment.
PR #2844 -- feat(trace): read TraceLens system findings into the specialist evidence and the profiler digestWhat it does: TraceLens' Risk: high --
Blocking issues: none Checked: the delta 7c902e6..6717f5f and the whole diff; LGTM |
Refs #2714
Problem and resulting behavior
TraceLens'
analysis.jsonlists the system bottlenecks it finds undersystem_optimizations.metric,value,unit), a reportpriority, anodeon multi-node reports, and aresolution.1f6d618) emits it:system_tasks()inpost_processing/analysis_json.py, andSystemTask/SystemMemberincandidate_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:dominant_directionroutes the dominant idle or comm share to a specialist domain.## System-Level Optimizationsheading of analysis.md, which it sees only after callingshow_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
explorevariants.Change
The change mirrors the fusion-findings path #2649 added.
tracelens_report.system_findingsreads the list from theanalysis.jsonbesideanalysis.md, in TraceLens' order.operation,node(empty off multi-node),priorityand its metric rows (valueis None when TraceLens could not read it). Theresolutionstays in the report, where the agents read it.system_finding_summaryrenders 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 readsshare: n/aand the finding stays listed. Both consumers below use it.record_trace_analyzestores the list aslast_trace_analyze["system_findings"], next tofusion_findings.roofline_evidencecarries the findings, capped at 8 rows like the hot kernels and fusion findings.## System-Level Optimizationsin 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 anexplorevariant, 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.[], never reads as "no bottleneck".profiler_digestgains asystem_findingsblock with the same one-line summaries.orchestration.mdpoints 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: anexplorevariant 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_findingsreads TraceLens' order, metric rows including a null value, node and priority, and carries no resolution;system_finding_summaryshows the first%row (the share TraceLens ranks by),n/afor an unreadable value, and the node.test_record_trace_analyze_lock.py: the canonical key set gainssystem_findings(17 keys).test_specialist_roofline_evidence.py: one flow test writes ananalysis.jsonwith a conformant finding and one without a share row beside analysis.md, records it throughSharedState.record_trace_analyze, and asserts both one-line summaries reach the coordinator'sto_prompt_summary()and the specialist's section afterwarm_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:
pyteston the files above plustest_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.pyandtest_shared_state_kernel_opt.py. All pass.ruff checkandruff format --checkon 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.jsonwith system findings was available locally, because TraceLens imports its whole library on import.Size/complexity
No trigger crossed.
record_trace_analyzeandwarm_specialist_paramseach went from 20 to 19 (radon). Their findings and evidence-row reads moved into_tracelens_findingsand_evidence_rows; the latter also replaces three copies of the same[:8]slice.build_profiler_digeststays at 19, with the new block in_system_findings_lines.dispatch.pywas already over the 800-line warning.Observable effect
## System-Level Optimizationsin 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.profiler_digestgains asystem_findingsblock, so it sees the system bottlenecks without callingshow_analysis_md.last_trace_analyzegainssystem_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
system_optimizations: []by construction.