spt-profiler
Memory, power, and latency profiling hooks with CSV emitters for benchmarking attention mechanisms
Overview
spt-profiler provides lightweight profiling infrastructure for benchmarking SPT attention mechanisms and inference pipelines. It captures memory snapshots, latency distributions, and power consumption samples, then exports results to CSV for analysis. A config hashing utility ensures benchmark configurations are uniquely identified for reproducibility.
Key Features
- Latency profiling -- record and compute statistics (mean, p50, p95, p99) over timing samples
- Memory tracking -- capture memory snapshots and generate usage reports
- Power measurement -- track energy consumption with pluggable power sources (including mock)
- CSV export -- write latency, memory, and combined results to CSV files
- Config hashing -- deterministic hash of benchmark configurations for reproducibility
Dependencies
Key internal dependencies:
serde/serde_json-- serialization of profiling records and configs
Usage
rust
use spt_profiler::{LatencyRecord, compute_latency_stats, write_latency_csv};
let records = vec![
LatencyRecord { label: "attn".into(), duration_ns: 1200 },
LatencyRecord { label: "attn".into(), duration_ns: 1500 },
];
let stats = compute_latency_stats(&records);
// write_latency_csv("bench.csv", &records).unwrap();API Reference
Core Types
| Type | Description |
|---|---|
LatencyRecord | A single timed sample with label |
LatencyStats | Computed statistics (mean, p50, p95, p99) |
MemoryTracker | Captures memory snapshots over time |
MemorySnapshot | Point-in-time memory usage reading |
MemoryReport | Aggregated memory usage report |
PowerTracker | Tracks energy consumption samples |
PowerSample | A single power reading |
EnergyResult | Total energy computed from power samples |
BenchConfig | Benchmark configuration for hashing |
ResultRow | Combined result row for CSV export |