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.2.0.tar.gz (10.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.2.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mlx_mhc-0.2.0.tar.gz
  • Upload date:
  • Size: 10.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.2.0.tar.gz
Algorithm Hash digest
SHA256 7fd63ee489e339bd49030ee91fbc6d14c5b33c0bb57145280f878cf4f82ca43e
MD5 538739076a51e37cb9a9593aa40c9a44
BLAKE2b-256 ab6b46795c5ba6f1f20c09f9fa7d6a0449e8db16ce0876207a51949d48f7afc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mlx_mhc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89a0c7eb70cf86662945d679700adc9d415edba2fe920822db30a4b486667e9f
MD5 f9511992f93b80dfd214eb9356e116cb
BLAKE2b-256 b4e7b3588e8dc7481ef6ab19443905efb88bfafe777ad410d7b1df909986192a

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