[visualizer] feat: add memory timeline HTML visualizer#70
Conversation
- Plotly-based interactive Gantt chart with operator grouping - Time-window segmentation for large datasets (max 20 segments) - Chart1 memory trend line + Chart2 operator Gantt synchronized zoom - Segment navigation with smart hint (suggest best segment for range) - Call stack display in detail panel on bar click - Overlap detection: hover and click show all stacked bars per operator - Absolute time display on x-axis tick labels and hover tooltip
There was a problem hiding this comment.
Code Review
This pull request introduces a new MemoryVisualizer and an accompanying HTML template to generate interactive memory allocation timelines and operator Gantt charts. The feedback focuses on critical performance optimizations and a potential bug fix: replacing an _build_chart1_data with a sweep-line (two-pointer) approach, vectorizing or optimizing DataFrame iterations to avoid slow iterrows() calls, and handling relative paths correctly in directory creation to prevent a FileNotFoundError.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
As a complete feature, we also need the data (/data), the datachecr(/rl_insight/data/data_checker.py)the data documentation (/docs/data), the examples (/examples), e2e test (tests/special_e2e). |
What does this PR do?
Adds a Plotly-based interactive memory timeline visualizer (
memory_html) that rendersNPU memory allocation events as an interactive Gantt chart. Key features:
shows per-operator Gantt bars, color-coded by operator name with bidirectional zoom sync.
time-window segments, each generating a standalone HTML+JS file pair with Prev/Next
navigation. Chart1 data (global timeline) is shared across all segments.
Seg N →" hint appears with a clickable link to the matching segment file.
point, the hover tooltip and detail panel both list all overlapping events with size and
timing info. Click any row in the detail panel to navigate between overlapping events.
call_stackfield is stored per event and shown in the detailpanel on bar click (empty call stacks display as
(empty)gracefully).timestamps, while internal data uses relative times for compact JSON output.
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI){modules}includepipeline,parser,visualizer,data,deployment,perf,algo,env,doc,cfg,ci,misc,like[mstx, ci]{type}is infeat,fix,refactor,chore,test[BREAKING]to the beginning of the title.[BREAKING][mstx, torch_profile] feat: support timeline parsingTest
python -m rl_insight.main input.path=xx timeline.parser.type=memory timeline.visualizer.type=memory_html output.path=xx
API and Usage Example
# Add code snippet or script demonstrating how to use thisDesign & Code Changes
New files:
rl_insight/visualizer/memory_visualizer.py—MemoryVisualizerclass registered asmemory_htmlcluster visualizer. Handles data preprocessing, segment splitting,JSON generation, and HTML template injection.
rl_insight/visualizer/memory_template.html— Plotly-based HTML template (~3 KB)with all rendering logic in vanilla JS. Data lives in a separate
detail_data.jsfile.Modified files:
rl_insight/visualizer/__init__.py— Addedfrom .memory_visualizer import MemoryVisualizerto register the
memory_htmlvisualizer.Key design decisions:
.jsfiles (not inlined in HTML), keeping the HTMLtemplate lightweight and cacheable.
call_stackstrings use a pool+index pattern (CS_POOL/CS_IDX) for deduplication,minimizing JSON output size.
x:[]andbase:[]arrays, reducing trace count from O(events) to O(unique_operators).start + duration > seg_start AND start < seg_endso eventsspanning segment boundaries appear in both files.
Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always