Text Generation
Transformers
Safetensors
grt
geometric-rotation-transformer
mixture-of-rotations
mor
Mixture of Experts
rotational-transformer
givens-rotations
clifford-algebra
matterwave
Instructions to use MatterWaveAI/grt-30m-mor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MatterWaveAI/grt-30m-mor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MatterWaveAI/grt-30m-mor")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MatterWaveAI/grt-30m-mor", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MatterWaveAI/grt-30m-mor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MatterWaveAI/grt-30m-mor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MatterWaveAI/grt-30m-mor", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MatterWaveAI/grt-30m-mor
- SGLang
How to use MatterWaveAI/grt-30m-mor with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MatterWaveAI/grt-30m-mor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MatterWaveAI/grt-30m-mor", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MatterWaveAI/grt-30m-mor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MatterWaveAI/grt-30m-mor", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MatterWaveAI/grt-30m-mor with Docker Model Runner:
docker model run hf.co/MatterWaveAI/grt-30m-mor
Fix math formatting in README.md for Hugging Face Hub
Browse files
README.md
CHANGED
|
@@ -4,6 +4,7 @@ library_name: transformers
|
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
- grt
|
|
|
|
| 7 |
- mixture-of-rotations
|
| 8 |
- mor
|
| 9 |
- moe
|
|
@@ -18,13 +19,54 @@ base_model: MatterWaveAI/grt-30m
|
|
| 18 |
|
| 19 |
**GRT-30M-MoR** (`31,634,086` parameters, **zero `nn.Linear` layers**) is the **Mixture-of-Rotations (`MoR`)** upcycled variant of [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) (`29,305,498` parameters).
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
## Architectural Highlights
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
## Quickstart (`transformers`)
|
| 30 |
|
|
@@ -40,3 +82,16 @@ inputs = tokenizer("The Givens Rotational Transformer replaces dense matrices wi
|
|
| 40 |
out_ids = model.generate(**inputs, max_new_tokens=32, do_sample=False)
|
| 41 |
print(tokenizer.decode(out_ids[0], skip_special_tokens=True))
|
| 42 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
- grt
|
| 7 |
+
- geometric-rotation-transformer
|
| 8 |
- mixture-of-rotations
|
| 9 |
- mor
|
| 10 |
- moe
|
|
|
|
| 19 |
|
| 20 |
**GRT-30M-MoR** (`31,634,086` parameters, **zero `nn.Linear` layers**) is the **Mixture-of-Rotations (`MoR`)** upcycled variant of [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) (`29,305,498` parameters).
|
| 21 |
|
| 22 |
+
Instead of routing tokens through multiple separate dense `nn.Linear` feed-forward matrices, **GRT-30M-MoR** exploits the abelian Lie group structure of planar `2×2` Givens rotations (`SO(2)^P` at each butterfly stage): the router blends the `E = 4` expert rotation angles and log-scales in parameter space **before** executing a single `cos / sin` Givens rotation cascade per stage — providing **`4×` FFN rotational capacity at `1×` trigonometric rotation compute**.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Model Details
|
| 27 |
+
|
| 28 |
+
| Property | Value |
|
| 29 |
+
| :--- | :--- |
|
| 30 |
+
| **Architecture** | `GRTForCausalLM` (`model_type: "grt"`, Mixture-of-Rotations) |
|
| 31 |
+
| **Base model** | [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) |
|
| 32 |
+
| **Total stored parameters** | `31,634,086` (`31.63M`, `+2,328,588` over `grt-30m`) |
|
| 33 |
+
| **Non-embedding backbone parameters** | `12,068,785` (`12.07M` across 12 MoR blocks) |
|
| 34 |
+
| **Number of FFN rotational experts (`ffn_n_experts`)** | `4` per block (`48` rotational FFN experts across 12 layers) |
|
| 35 |
+
| **MoR parameterization (`mor_mode`)** | `"direct"` (`expert_expand_angles [4, 21, 512]`, `expert_expand_scales [4, 21, 1024]`, `expert_contract_angles [4, 21, 512]`, `expert_contract_scales [4, 21, 1024]`) |
|
| 36 |
+
| **Router architecture (`mor_router_mode`)** | `"rotational"` (`GRTRotationalRouter` — cosine phase-angle alignment on `(S¹)^128`, **0 `nn.Linear` layers**) |
|
| 37 |
+
| **`nn.Linear` layers** | **`0`** |
|
| 38 |
+
| **`hidden_size` (`d_model`) / `intermediate_size` (`d_ff`)** | `256` / `1,024` |
|
| 39 |
+
| **`num_hidden_layers` / `num_attention_heads`** | `12` / `4` (`head_dim = 64`) |
|
| 40 |
+
| **`n_qkv_rotations` / `n_mixer_rotations` / `ffn_n_rotations`** | `11` / `1` / `21` |
|
| 41 |
+
| **Vocabulary** | `151,669` (Qwen 3 BPE, tied polar cosine head) |
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
## Architectural Highlights
|
| 46 |
|
| 47 |
+
1. **4× FFN Rotational Capacity at 1× Rotation Compute (`_mor_rotate`)**:
|
| 48 |
+
Each of the 12 `GRTFeedForward` blocks maintains `ffn_n_experts = 4` rotational cascades. Given per-token router probabilities `w[n, e]` (`sum_e w[n, e] = 1`), the effective rotation angle and positive scale at stage `k`, pair `p` / dimension `d` are blended prior to rotation:
|
| 49 |
+
```text
|
| 50 |
+
θ_blended[n, k, p] = Σ_{e=0..3} w[n, e] · θ_expert[e, k, p]
|
| 51 |
+
s_blended[n, k, d] = Σ_{e=0..3} w[n, e] · softplus(s_raw_expert[e, k, d])
|
| 52 |
+
```
|
| 53 |
+
A single Givens rotation `(cos θ_blended, sin θ_blended)` is then applied per pair.
|
| 54 |
+
2. **100% Rotational Router (`GRTRotationalRouter`, 0 `nn.Linear` Layers)**:
|
| 55 |
+
Tokens are routed to experts via scaled cosine alignment between L2-normalized planar coordinate pairs `(u_p, v_p)` and `E = 4` learned phase-angle prototypes `(cos φ_{e,p}, sin φ_{e,p})` with learned `softplus(output_scale)` temperature.
|
| 56 |
+
3. **Zero-Sum Walsh–Hadamard Upcycling & Multi-Domain Specialization (`PairAdam`)**:
|
| 57 |
+
Initialized from `MatterWaveAI/grt-30m` via zero-sum Walsh–Hadamard angular perturbations (`Σ_e Δ^(e) = 0`) and specialized on a 4-domain corpus (`rotational_geometry`, `science_and_physics`, `code_and_algorithms`, `reasoning_and_language`) on an Intel Arc 140T XPU (`xpu:0`) with `PairAdam` and Switch-style load balancing:
|
| 58 |
+
|
| 59 |
+
| Metric | Initial Upcycle | After MoR Specialization (`PairAdam`) |
|
| 60 |
+
| :--- | :---: | :---: |
|
| 61 |
+
| **Held-Out Validation Loss** | `5.8467` | **`0.5115`** |
|
| 62 |
+
| **Held-Out Validation Perplexity** | `346.10` | **`1.67`** |
|
| 63 |
+
| **Domain Loss — `code_and_algorithms`** | `5.4092` | **`0.4334`** |
|
| 64 |
+
| **Domain Loss — `rotational_geometry`** | `6.6421` | **`0.4991`** |
|
| 65 |
+
| **Domain Loss — `science_and_physics`** | `5.3337` | **`0.5293`** |
|
| 66 |
+
| **Domain Loss — `reasoning_and_language`** | `6.1720` | **`0.6442`** |
|
| 67 |
+
| **Mean Expert Routing Load (`E = 4`)** | `[0.25, 0.25, 0.25, 0.25]` | **`[0.250, 0.248, 0.256, 0.245]`** (`entropy = 1.386 / 1.386`) |
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
|
| 71 |
## Quickstart (`transformers`)
|
| 72 |
|
|
|
|
| 82 |
out_ids = model.generate(**inputs, max_new_tokens=32, do_sample=False)
|
| 83 |
print(tokenizer.decode(out_ids[0], skip_special_tokens=True))
|
| 84 |
```
|
| 85 |
+
|
| 86 |
+
## Quickstart (`vLLM`)
|
| 87 |
+
|
| 88 |
+
```python
|
| 89 |
+
from vllm import LLM, SamplingParams
|
| 90 |
+
|
| 91 |
+
llm = LLM(model="MatterWaveAI/grt-30m-mor", model_impl="transformers", dtype="float32")
|
| 92 |
+
outputs = llm.generate(
|
| 93 |
+
["The Givens Rotational Transformer replaces dense matrices with"],
|
| 94 |
+
SamplingParams(temperature=0.0, max_tokens=32),
|
| 95 |
+
)
|
| 96 |
+
print(outputs[0].outputs[0].text)
|
| 97 |
+
```
|