File size: 3,524 Bytes
69c5101
 
2c53bd2
 
 
 
 
 
 
 
69c5101
2c53bd2
 
 
3a4832f
2c53bd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
940c626
2c53bd2
 
 
 
 
 
 
 
 
 
3a4832f
2c53bd2
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
license: mit
tags:
- plasma-physics
- fusion-energy
- disruption-prediction
- transformer
- time-series
language:
- en
---

# SHARD: Signal Harmonics for Anomaly and Reactor Disruption

**SHARD** is a Transformer-based deep learning model for predicting plasma disruptions in tokamak fusion reactors. It was developed by Veer Goradia.

## Model Description

Plasma disruptions — sudden losses of plasma confinement — are the single greatest threat to sustained fusion energy. They can release megajoules of energy in milliseconds, damaging reactor walls and quenching the plasma. SHARD predicts disruptions far enough in advance to trigger mitigation systems, and explains *which* plasma signals drove each prediction.

**Architecture:**
- Linear projection of 13 plasma diagnostic signals into a 64-dimensional embedding space
- Learnable positional encoding for temporal awareness
- 3-layer Transformer encoder with multi-head self-attention (4 heads)
- Novel **Signal Attribution Layer**: cross-signal attention that identifies which plasma parameters (β_p, q₉₅, MHD modes, etc.) most influenced each prediction
- Dual output heads: disruption probability (binary classification) + time-to-disruption (regression)

**Total parameters:** 62,671

## Performance

| Metric | Value |
|--------|-------|
| ROC-AUC | 0.864 |
| PR-AUC | 0.449 |
| Improvement over HDL baseline | +6.3 points ROC-AUC |
| 5-seed ensemble ROC-AUC | 0.857 ± 0.008 |

Cross-tokamak generalization: model trained on C-Mod and evaluated zero-shot on DIII-D, demonstrating transfer without retraining.

## Training Data

- **Primary dataset:** MIT Alcator C-Mod disruption database (DisruptionBench)
- **Signals used (13):** β_p, lᵢ, q₉₅, n₁ MHD mode, n/nG (Greenwald fraction), lower gap, κ (elongation), Ip error, loop voltage, radiated power, Wmhd, dW/dt, v_loop
- **Sequence length:** 100 timesteps per shot
- **Split:** 80/10/10 train/val/test, stratified by disruption label

## Intended Use

- Research use for plasma disruption prediction and tokamak safety
- Real-time deployment on tokamak diagnostic systems (latency ~2ms per shot)
- Interpretability analysis via Signal Attribution Layer

## How to Use

```python
import torch
from model import SHARDEncoder, SIGNAL_NAMES

# Load model
model = SHARDEncoder(n_signals=13, seq_len=100, d_model=64, n_heads=4, n_layers=3)
model.load_state_dict(torch.load('shard_best.pt', map_location='cpu'))
model.eval()

# Input: (batch, seq_len, n_signals) tensor of normalized plasma signals
x = torch.randn(1, 100, 13)  # replace with real diagnostic data
disruption_prob, time_to_disruption, signal_weights = model(x)

print(f"Disruption probability: {disruption_prob.item():.3f}")
print(f"Time to disruption: {time_to_disruption.item():.1f} ms")

# Get signal attribution (which signals drove the prediction)
attribution = model.get_signal_attribution(x, SIGNAL_NAMES)
for signal, weight in sorted(attribution.items(), key=lambda x: -x[1]):
    print(f"  {signal}: {weight:.4f}")
```

## Live Demo

Try the interactive Streamlit app: [SHARD Demo](https://shard-disruption.streamlit.app)

## Citation

If you use SHARD in your research, please cite:

```
@misc{goradia2026shard,
  title={SHARD: Signal Harmonics for Anomaly and Reactor Disruption — 
         A Transformer Architecture for Interpretable Plasma Disruption Prediction},
  author={Goradia, Veer},
  year={2026}
}
```

## License

MIT License — see LICENSE file.

## Contact

Veer Goradia · vgoradia07@gmail.com