MLX implementation of Manifold-Constrained Hyper-Connections (mHC) for Apple Silicon
Project description
mlx-mhc
First MLX implementation of DeepSeek's Manifold-Constrained Hyper-Connections (mHC) for Apple Silicon.
Based on: arXiv:2512.24880
Installation
pip install mlx-mhc
Quick Start
import mlx.core as mx
import mlx_mhc as mhc
# Sinkhorn-Knopp projection to doubly stochastic matrix
matrix = mx.random.normal((8, 8))
doubly_stochastic = mhc.sinkhorn_knopp(matrix)
# Manifold Hyper-Connection module
connection = mhc.ManifoldHyperConnection(dims=512, expansion=2)
output = connection(x, layer_output)
What is mHC?
mHC (Manifold-Constrained Hyper-Connections) improves training stability for large language models by constraining residual connection mixing matrices to the Birkhoff polytope (doubly stochastic matrices).
Key benefits:
- Prevents gradient explosion in deep networks
- Maintains identity mapping property
- 2.1% improvement on benchmarks with only 6.7% overhead
API
sinkhorn_knopp(matrix, max_iterations=100, epsilon=1e-6, log_space=True)
Project a matrix onto the Birkhoff polytope (set of doubly stochastic matrices).
ManifoldHyperConnection(dims, expansion=2, sinkhorn_iterations=10)
MLX module implementing mHC for transformer residual connections.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlx_mhc-0.4.0.tar.gz.
File metadata
- Download URL: mlx_mhc-0.4.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eed3e4ae24fbd676db132a427f829f3a9cdf23ca2bcdf6e32c7a87a2ff72ff8f
|
|
| MD5 |
2696d6eb04bab5b7fa6fedea301459b6
|
|
| BLAKE2b-256 |
9fafc8c5bb28f757ee0706e0ffafe3b1c123b1c5298b5e45682b935fd0e6b251
|
File details
Details for the file mlx_mhc-0.4.0-py3-none-any.whl.
File metadata
- Download URL: mlx_mhc-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
889cb52c6e04a4fd21c8fdbc909db0b317fe863f4d287a440e4002bc4c6987bc
|
|
| MD5 |
56d4a174b766bf4ec8df539d2e58065d
|
|
| BLAKE2b-256 |
2be869faba5c271dd9d3a444ad557cbd55d86788d68f7af0859adb2acc43ada9
|