Skip to content

Platform Profiler

Cross-platform SNN performance profiler (CPU, GPU, Rust, simulated FPGA).

from sc_neurocore.profiler import PlatformProfiler

profiler = PlatformProfiler()
report = profiler.profile(model, inputs, backends=["python", "rust"])

See Tutorial 43: Platform Profiler.

sc_neurocore.profiler

Cross-platform SNN performance profiler.

PlatformResult dataclass

Performance result for one platform.

Source code in src/sc_neurocore/profiler/platform_profiler.py
20
21
22
23
24
25
26
27
28
29
30
@dataclass
class PlatformResult:
    """Performance result for one platform."""

    platform: str
    latency_ms: float
    throughput_inf_per_s: float
    power_mw: float
    energy_per_inf_nj: float
    available: bool = True
    notes: str = ""

compare(layer_sizes, duration=0.1, dt=0.001, bitstream_length=256, platforms=None)

Compare SNN performance across platforms.

Parameters

layer_sizes : list of (n_inputs, n_neurons) Network architecture. duration : float Simulation duration in seconds. dt : float Timestep. bitstream_length : int SC bitstream length for FPGA estimates. platforms : list of str, optional Platforms to compare. Default: all available. Options: 'python', 'rust', 'fpga_ice40', 'fpga_artix7'

Returns

list of PlatformResult One result per platform, sorted by energy efficiency.

Source code in src/sc_neurocore/profiler/platform_profiler.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def compare(
    layer_sizes: list[tuple[int, int]],
    duration: float = 0.1,
    dt: float = 0.001,
    bitstream_length: int = 256,
    platforms: list[str] | None = None,
) -> list[PlatformResult]:
    """Compare SNN performance across platforms.

    Parameters
    ----------
    layer_sizes : list of (n_inputs, n_neurons)
        Network architecture.
    duration : float
        Simulation duration in seconds.
    dt : float
        Timestep.
    bitstream_length : int
        SC bitstream length for FPGA estimates.
    platforms : list of str, optional
        Platforms to compare. Default: all available.
        Options: 'python', 'rust', 'fpga_ice40', 'fpga_artix7'

    Returns
    -------
    list of PlatformResult
        One result per platform, sorted by energy efficiency.
    """
    if platforms is None:
        platforms = ["python", "rust", "fpga_ice40", "fpga_artix7"]

    results = []
    for platform in platforms:
        if platform == "python":
            results.append(_profile_python(layer_sizes, duration, dt))
        elif platform == "rust":
            results.append(_profile_rust(layer_sizes, duration, dt))
        elif platform.startswith("fpga_"):
            target = platform.replace("fpga_", "")
            results.append(_profile_fpga(layer_sizes, target, bitstream_length))
        else:
            results.append(
                PlatformResult(
                    platform=platform,
                    latency_ms=0,
                    throughput_inf_per_s=0,
                    power_mw=0,
                    energy_per_inf_nj=0,
                    available=False,
                    notes=f"Unknown platform '{platform}'",
                )
            )

    results.sort(key=lambda r: r.energy_per_inf_nj if r.available else float("inf"))
    return results