Skip to main content

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

mlx_mhc-0.3.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlx_mhc-0.3.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file mlx_mhc-0.3.0.tar.gz.

File metadata

  • Download URL: mlx_mhc-0.3.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mlx_mhc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 205e8277b5bb098aa1b1f4a7bc9642f3f2cc332662e4f41a13c1bd00697565b3
MD5 32ba0f0a6445dcb71bce96f0ed5fd633
BLAKE2b-256 232b211677c0589c0b58fa860a7561b8ce34ee66ff053cd3a4a566700ab0d2ff

See more details on using hashes here.

File details

Details for the file mlx_mhc-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mlx_mhc-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mlx_mhc-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12617ed6246113745babea3b0462103a147ce8866e0611d76aa512a17e358949
MD5 26e37201800a4570e5314ef26a070c97
BLAKE2b-256 ac59c5f5dbd28b8de5f8679cbcdacc218ffad963e9c35bb34e2ea46d55631d9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page