aien-sovereign-core
Autonomous sovereign intelligence engine and runtime core for NVIDIA DGX Spark
Brought by drakestapleton
aien-sovereign-core / imprints / en2-trinity / mojo / en2_kv_adapter.mojo
| 1 | # EN2 Sovereign Modular MAX Architecture Adapter Kernel |
| 2 | # Pure compiled Mojo dynamic library for low-latency inference on Grace Blackwell GB10 |
| 3 | |
| 4 | @export("en2_adapter_version") |
| 5 | def en2_adapter_version() -> Int32: |
| 6 | return 2 |
| 7 | |
| 8 | @export("en2_kv_expand_stride") |
| 9 | def en2_kv_expand_stride(head_dim: Int32, num_heads: Int32) -> Int32: |
| 10 | if head_dim <= 0 or num_heads <= 0: |
| 11 | return -1 |
| 12 | return head_dim * num_heads * 2 |
| 13 | |
| 14 | @export("en2_apply_kv_rope_scaling") |
| 15 | def en2_apply_kv_rope_scaling(seq_len: Int32, base_freq: Float32) -> Float32: |
| 16 | if seq_len <= 4096: |
| 17 | return base_freq |
| 18 | return base_freq * (1.0 + 0.1 * (Float32(seq_len) / 4096.0)) |