Text Classification
Transformers
PyTorch
Safetensors
English
bert
fast
monarch-matrices
mnli
efficiency
triton
hardware-efficient
sub-quadratic
fast-inference
h100-optimized
custom_code
Eval Results (legacy)
text-embeddings-inference
Instructions to use ykae/monarch-bert-base-mnli with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ykae/monarch-bert-base-mnli with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="ykae/monarch-bert-base-mnli", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("ykae/monarch-bert-base-mnli", trust_remote_code=True) model = AutoModelForSequenceClassification.from_pretrained("ykae/monarch-bert-base-mnli", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -96,4 +96,15 @@ model = torch.compile(model, mode="max-autotune")
|
|
| 96 |
inputs = tokenizer("Monarch matrices are efficiently sparse.", return_tensors="pt").to("cuda")
|
| 97 |
with torch.no_grad():
|
| 98 |
outputs = model(**inputs)
|
| 99 |
-
print(outputs.logits)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
inputs = tokenizer("Monarch matrices are efficiently sparse.", return_tensors="pt").to("cuda")
|
| 97 |
with torch.no_grad():
|
| 98 |
outputs = model(**inputs)
|
| 99 |
+
print(outputs.logits)
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
## 🧠 The "Memory Paradox" (Read this!)
|
| 103 |
+
|
| 104 |
+
You might notice that while the parameter count is lower (82M vs 110M), the peak VRAM usage during inference can be slightly higher than the baseline.
|
| 105 |
+
|
| 106 |
+
**Why?**
|
| 107 |
+
This is a **software artifact**, not a hardware limitation.
|
| 108 |
+
|
| 109 |
+
* **Math:** Monarch Matrices decompose a dense layer into: $\text{BlockDiag}_1 \to \text{Permutation} \to \text{BlockDiag}_2$.
|
| 110 |
+
* **Solution:** A custom **Fused Triton Kernel** (planned) would fuse these steps, keeping intermediate activations in the GPU's SRAM (L1 Cache). This would drop dynamic VRAM usage significantly below the baseline, matching the FLOPs reduction.
|