Skip to content

Commit 26e213d

Browse files
authored
Merge pull request #2 from iLevyTate/Refinements
Refinements
2 parents 087771b + b04e105 commit 26e213d

8 files changed

Lines changed: 678 additions & 438 deletions

File tree

README.md

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
# STAC: Spiking Transformer for Conversational AI
22

33
[![DOI](https://zenodo.org/badge/907152074.svg)](https://doi.org/10.5281/zenodo.14545340)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
45

56
## Overview
67

7-
STAC (Spiking Transformer Augmenting Cognition) converts pretrained transformer LLMs (e.g., DistilGPT-2, SmolLM2-1.7B-Instruct) into energy-efficient Spiking Neural Networks (SNNs) **while preserving coherent multi-turn conversational ability**.
8+
STAC (Spiking Transformer Augmenting Cognition) is a research framework with two distinct approaches:
9+
10+
- **STAC V1**: Complete end-to-end training pipeline with learnable AdEx neurons (see `stac-v1/`)
11+
- **STAC V2**: Experimental conversion framework that transforms pretrained transformer LLMs (DistilGPT-2, SmolLM2-1.7B-Instruct) into Spiking Neural Networks (SNNs) for *potential* energy savings **while retaining multi-turn conversational ability in simulation**
12+
13+
> ⚠️ **Important**: This repository currently runs *software-level* SNN simulations only. No metrics have been collected on physical neuromorphic hardware yet. Energy savings figures are theoretical projections based on spike-count analysis, not measured hardware data.
814
915
## Key Features
1016

11-
**End-to-end ANN→SNN conversion** with SpikingJelly integration
12-
**Multi-turn conversation support** with KV-cache and position ID handling
13-
**Comprehensive test suite** validating coherence, energy, and compatibility
14-
**Production-ready pipeline** with TorchScript export capabilities
15-
**Energy efficiency** targeting 3-4× reduction in power consumption
17+
✔️ **Proof-of-concept ANN→SNN conversion** using SpikingJelly
18+
✔️ **Multi-turn context retention** via a Temporal Spike Processor
19+
✔️ **Extensive software tests** for position IDs, KV-cache, and spike-rate sanity
20+
**Hardware power profiling** *planned, not implemented*
21+
**Full operator coverage & optimisation** *work in progress*
1622

1723
## Quick Start
1824

@@ -27,11 +33,12 @@ python run_conversion.py --model_name distilgpt2 --timesteps 8 --simplified
2733
python snn_multi_turn_conversation_test.py --mode snn --turns 3 --timesteps 8
2834

2935
# 4. Run comprehensive validation
30-
python test_conversational_snn.py --test_all --timesteps 8
36+
python test_conversational_snn.py --model_name distilgpt2 --test_all --timesteps 8
3137
```
3238

3339
## Core Components
3440

41+
### STAC V2 (Current)
3542
| Component | Purpose |
3643
|-----------|---------|
3744
| `smollm2_converter.py` | Specialized converter with `TemporalSpikeProcessor` |
@@ -41,34 +48,58 @@ python test_conversational_snn.py --test_all --timesteps 8
4148
| `test_conversational_snn.py` | Comprehensive test suite (1K+ lines) |
4249
| `snn_multi_turn_conversation_test.py` | Simple conversation smoke test |
4350

44-
## Implementation Status
51+
### STAC V1 (Original Research)
52+
| Component | Purpose |
53+
|-----------|---------|
54+
| `stac-v1/stacv1.ipynb` | Complete end-to-end training pipeline with learnable AdEx neurons |
55+
| `stac-v1/README.md` | V1 documentation and research contributions |
4556

46-
All **Phase 1-4** objectives are complete:
57+
## Implementation Status
4758

48-
-**Core Infrastructure**: SpikingJelly integration, GELU→ReLU, quantization
49-
-**Temporal Dynamics**: Stateful LIF neurons, timestep calibration
50-
-**Conversation Context**: Position IDs, KV-cache, attention masks
51-
-**Production Readiness**: TorchScript export, energy benchmarking
59+
### STAC V2 (Current)
60+
**Completed (prototype level)**
61+
- ✅ Core conversion flow (GELU→ReLU, quantization, ann2snn)
62+
- ✅ Temporal dynamics & KV-cache handling in PyTorch
63+
- ✅ Spike-count telemetry hooks and unit tests
64+
65+
**Pending / In Progress**
66+
- ⏳ Hardware benchmarking on Loihi-2 / Akida
67+
- ⏳ Expanded operator support (e.g., rotary embeddings, flash-attention variants)
68+
- ⏳ Integration with SCANUE multi-agent alignment layer
69+
- ⏳ Robust CLI/UX and documentation polish
70+
71+
### STAC V1 (Complete)
72+
**Completed (research prototype)**
73+
- ✅ End-to-end training pipeline with learnable AdEx neurons
74+
- ✅ Hyperdimensional Memory Module (HEMM) integration
75+
- ✅ Surrogate gradient training on WikiText-2
76+
- ✅ L1 spike regularization for energy efficiency
77+
- ✅ Comprehensive validation suite
5278

5379
## Documentation
5480

81+
### STAC V2 (Current)
5582
- 🔄 [Conversion Workflow](docs/conversion_workflow.md) - Step-by-step conversion guide
5683
- 📚 [API Reference](docs/api_reference.md) - Function and class documentation
5784
- 🖥️ [Hardware Requirements](docs/hardware_requirements.md) - System specifications
5885

86+
### STAC V1 (Original Research)
87+
- 📖 [STAC V1 Documentation](stac-v1/README.md) - End-to-end training pipeline documentation
88+
- 🧠 [STAC V1 Implementation](stac-v1/stacv1.ipynb) - Complete Jupyter notebook with learnable AdEx neurons
89+
5990
## Testing & Validation
6091

6192
The repository includes extensive testing for multi-turn conversational correctness:
6293

6394
```bash
6495
# Test specific components
65-
python test_conversational_snn.py --test_position_boundaries
66-
python test_conversational_snn.py --test_attention_mask
67-
python test_conversational_snn.py --test_multi_turn
68-
python test_conversational_snn.py --test_energy
96+
python test_conversational_snn.py --model_name distilgpt2 --test_position_boundaries
97+
python test_conversational_snn.py --model_name distilgpt2 --test_attention_mask
98+
python test_conversational_snn.py --model_name distilgpt2 --test_multi_turn
99+
python test_conversational_snn.py --model_name distilgpt2 --test_energy
69100

70101
# Run all tests
71-
python test_conversational_snn.py --test_all
102+
python test_conversational_snn.py --model_name distilgpt2 --test_all
72103
```
73104

74105
## License

0 commit comments

Comments
 (0)