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.1.0.tar.gz (7.4 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.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mlx_mhc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35a7a5d0b421e1a4ad595dbefcc908847f3fc7a3f2f780d28ccd2236c268c5b6
MD5 410c4f2fae61bbd46a4b3b5d12da01f7
BLAKE2b-256 79c116e7474b2e38389aeff675aa86155d995464586778f32caf75c7646ce029

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mlx_mhc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98f44af777be550dc1fed96873025d2c2ecf86a80af27685b35b3a151560003d
MD5 a6532d568920c85aeb4eb028752298ab
BLAKE2b-256 b69c946eb89c29c92a09ad5edcecda75711a68580f3dc904b96674fe525de12f

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