t1c-viz 0.0.2
Interactive Visualizer for T1C-IR Graphs
Requires Python: >=3.10
Keywords: neuromorphic, spiking-neural-networks, snn, pytorch, deep-learning, machine-learning, visualizer, intermediate-representation, graph-visualization, visualizer

<div align="center" style="background-color: #08081e; width: 100%; padding: 0;">
  <img alt="T1C-IR Logo" src="https://www.type1compute.com/images/t1c-logo-light.png" style="max-width: 200px; height: auto; display: block;">
</div>

<br>

# T1C-Viz - Interactive Visualization for T1C-IR Graphs


T1C-Viz generates beautiful, interactive HTML visualizations of T1C-IR computation graphs using D3.js and ELK for automatic layout. View your neural network architectures in Jupyter notebooks or export standalone HTML files.

T1C-Viz provides an intuitive way to explore and understand T1C-IR computation graphs, making it easier to debug, analyze, and document neuromorphic neural network architectures.

> Read more about T1C-IR in our [documentation](https://type1compute.github.io/docs/intro)

## Installation

```bash
uv add t1c-viz@git+ssh://git@github.com:type1compute/t1cir.git
```

Or with Jupyter support:

```bash
uv add "t1c-viz[jupyter]@git+ssh://git@github.com:type1compute/t1cir.git"
```

## Quick Start

```python
from t1c import ir, viz

# Load a graph
graph = ir.read('model.t1c')

# Display interactively (opens browser or shows in Jupyter)
viz.visualize(graph, title="My SNN Model")
```

## Display Methods

### Browser Display

Outside Jupyter, opens in default browser:

```python
viz.visualize(graph, title="My SNN Model")
# Output: Visualization written to: /tmp/t1c-viz/My_SNN_Model_xxx.html
```

### Jupyter Display

In Jupyter notebooks, displays as embedded iframe:

```python
viz.visualize(graph, title="My SNN", width=960, height=640)
```

### Export to File

Save as standalone HTML:

```python
path = viz.export_html(graph, "model.html", title="Production Model")
print(f"Saved to: {path}")
```

The HTML is self-contained - no server needed.

## Features

### Graph Visualization (Left Panel)

- **Dagre layout**: Automatic hierarchical graph layout
- **SNN-specific styling**: LIF neurons shown with distinctive spiking icon
- **Interactive**: Pan, zoom, click nodes to inspect
- **Parameter display**: Shows tau/theta on neuron nodes, kernel sizes on convolutions

### Data Explorer (Right Panel)

- **HDF5 tree**: Navigate graph structure
- **Array visualization**: Heatmaps for weights, line plots for biases
- **Statistics**: Min, max, mean, std for all arrays
- **Bidirectional sync**: Click in tree to highlight node in graph

## Node Colors

| Primitive | Color | Description |
|-----------|-------|-------------|
| Input | Green | Graph entry points |
| Output | Red | Graph exit points |
| Affine | Blue | Linear layers |
| SpikingAffine | Purple | Quantized affine with spike hints |
| LIF | Cyan | Leaky integrate-and-fire neurons |
| Conv2d | Orange | 2D convolution |
| SepConv2d | Deep Orange | Depthwise separable convolution |
| MaxPool2d | Brown | Max pooling |
| AvgPool2d | Blue Grey | Average pooling |
| Flatten | Grey | Reshape operations |
| Skip | Yellow | Residual/skip connections |

## Development

From the repo root (requires [t1c-ir](https://github.com/type1compute/t1cir.git) installed first):

```bash
uv pip install -e .
pytest tests/ -v
```