Skip to content

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

TypeDescription
LatencyRecordA single timed sample with label
LatencyStatsComputed statistics (mean, p50, p95, p99)
MemoryTrackerCaptures memory snapshots over time
MemorySnapshotPoint-in-time memory usage reading
MemoryReportAggregated memory usage report
PowerTrackerTracks energy consumption samples
PowerSampleA single power reading
EnergyResultTotal energy computed from power samples
BenchConfigBenchmark configuration for hashing
ResultRowCombined result row for CSV export

Released under the MIT License.