How amisha-ranjan34/local-llm-instrumentation-tracing-and-replay-platform works
LLM Scope instruments transformer execution in a separate process, transports layer and attention packets through shared memory, and presents live diagnostics in a keyboard-driven terminal UI. The main workflow runs from model forward hooks through packet capture and transport to TUI ingestion and five diagnostic panels; demo and trace loading are alternate inputs. The graph preserves documented capabilities, but several implementation links rely on README statements because the relevant source excerpts are incomplete.
Main entry points: tui_state.hpp Viewer State · tui_engine.cpp TUI Engine · main_tui.cpp Viewer Entry · main_instrument.cpp Capture Entry
Components 18
Instrumentation
- Capture Entry
src/instrumentation/main_instrument.cpp - Hook Registry
src/instrumentation/hook_registry.cpp - Topology Parser
src/instrumentation/topology_parser.cpp - Anomaly Detector
include/llm_scope/anomaly_detector.hpp
Packet Transport
- Packet Schemas
include/llm_scope/packets.hpp - SPSC Ring Buffers
include/llm_scope/ring_buffer.hpp - Shared Memory
include/llm_scope/shared_memory.hpp - Model Topology
include/llm_scope/topology.hpp
TUI Viewer
- Viewer Entry
src/tui/main_tui.cpp - Viewer State
src/tui/tui_state.hpp - TUI Engine
src/tui/tui_engine.cpp
TUI Diagnostics
- Topology Panel
src/tui/panels/panel_topology.cpp - Packet Stream
src/tui/panels/panel_stream.cpp - Attention Heatmap
src/tui/panels/panel_attention.cpp - Layer Metrics
src/tui/panels/panel_metrics.cpp - Anomaly Ledger
src/tui/panels/panel_anomaly.cpp
Other components
- Transformer Model
- Trace File
Connections 27
- Transformer Model → Hook Registry: runs hooks
README.md - Capture Entry → Hook Registry: starts capture
src/instrumentation/main_instrument.cpp - Hook Registry → Anomaly Detector: checks packets
- Hook Registry → Packet Schemas: emits packets
- Hook Registry → SPSC Ring Buffers: writes packets
- Capture Entry → Shared Memory: creates segments
src/instrumentation/main_instrument.cpp - Capture Entry → SPSC Ring Buffers: places buffers
src/instrumentation/main_instrument.cpp - Topology Parser → Model Topology: builds tree
include/llm_scope/topology.hpp - Capture Entry → Model Topology: publishes topology
README.md - Viewer Entry → Shared Memory: attaches to
src/tui/main_tui.cpp - Viewer Entry → SPSC Ring Buffers: reads packets
src/tui/main_tui.cpp - Viewer Entry → Model Topology: loads topology
src/tui/main_tui.cpp - SPSC Ring Buffers → Viewer State: drains packets
src/tui/tui_state.hpp - Viewer Entry → Viewer State: sets up
src/tui/main_tui.cpp - Viewer Entry → TUI Engine: runs viewer
src/tui/main_tui.cpp - TUI Engine → Topology Panel: creates panel
src/tui/tui_engine.cpp - TUI Engine → Packet Stream: creates panel
src/tui/tui_engine.cpp - TUI Engine → Attention Heatmap: creates panel
src/tui/tui_engine.cpp - TUI Engine → Layer Metrics: creates panel
src/tui/tui_engine.cpp - TUI Engine → Anomaly Ledger: creates panel
src/tui/tui_engine.cpp - Viewer State → Topology Panel: supplies state
- Viewer State → Packet Stream: supplies state
- Viewer State → Attention Heatmap: supplies state
- Viewer State → Layer Metrics: supplies state
- Viewer State → Anomaly Ledger: supplies state
- Capture Entry → Trace File: writes trace
README.md - Trace File → Viewer Entry: loads replay
src/tui/main_tui.cpp