cluster4npu/core/device/bottleneck.py
abin 55040733fe feat: implement Phase 1-4 performance visualization and device management
Phase 1 — Performance Benchmarking:
- PerformanceBenchmarker: sequential vs parallel benchmark with injectable runner
- PerformanceHistory: JSON-backed benchmark history with regression support
- PerformanceDashboard: real-time FPS/latency display widget
- BenchmarkDialog: one-click benchmark with 3-phase progress bar

Phase 2 — Device Management:
- DeviceManager: NPU dongle scan, assign/unassign, load balance recommendation
- DeviceManagementPanel: live device status cards with auto-refresh
- BottleneckAlert: dataclass for pipeline bottleneck detection

Phase 3 — Advanced Features:
- OptimizationEngine: 3 optimization rules (rebalance/adjust_queue/add_devices)
- TemplateManager: 3 built-in pipeline templates (YOLOv5, fire detection, dual-model)

Phase 4 — Report Export:
- ReportExporter: PDF (reportlab, optional) and CSV export
- ExportReportDialog: format selection + path picker UI

192 unit tests, all passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 19:32:05 +08:00

33 lines
874 B
Python

"""
core/device/bottleneck.py
BottleneckAlert dataclass — describes a detected pipeline bottleneck.
Integration with InferencePipeline is deferred to a later phase.
This module only defines the data structure.
"""
from dataclasses import dataclass
@dataclass
class BottleneckAlert:
"""Describes a detected pipeline bottleneck in a single Stage.
Attributes
----------
stage_id:
The pipeline Stage that is experiencing the bottleneck.
queue_fill_rate:
Input queue utilisation as a fraction in [0.0, 1.0].
suggested_action:
Human-readable suggestion (e.g. "Add more Dongles to this stage").
severity:
Either ``"warning"`` (fill_rate > 0.8) or ``"critical"``
(fill_rate > 0.95).
"""
stage_id: str
queue_fill_rate: float
suggested_action: str
severity: str # "warning" | "critical"