Mixture of Convex Experts (MiCE) for PyTorch
Project description
MiCE (Mixture of Convex Experts)
What is MiCE?
MiCE is a lightweight PyTorch library for building convex mixture-of-experts models via a novel max-of-means atlas. Instead of softmax routing or hard top-k gating, MiCE fuses an ensemble of convex “petal” subnetworks with a fixed, irreducible atlas of affine charts:
- Forward projection into each petal’s chart
- Convex evaluation in chart space (Input-Convex Neural Nets)
- (Optional) exact inversion back to the global frame
- Overlapping mean-of-pairs + max fusion
This guarantees convexity, interpretability, and efficient compute without exponentials or discrete dispatch- but only inside the petals, for now. Convexity distortions do happen at the edge of petals, and work is ongoing to evaluate this problem.
Why MiCE?
-
Global convexity
Each chart is convex; max-fusion preserves convexity in any dimension. -
Two operating modes
- Forward-only (
invert=False): fast chart tiling with learnable shifts - Atlas mode (
invert=True): full chart atlas with exact reprojection, no shifts needed
- Forward-only (
-
Efficiency
No softmax, no log-sum-exp, no sparse dispatch. Fusion is just a handful of GEMMs, adds, and a single max per group. Compute scales ~2.6× a 2-layer MLP. -
Interpretability
Clear regions of dominance — visualize arg-max and margins over petals in any 2-D slice.
Feature Comparison
| Feature | MiCE (MoMx) | Softmax MoE | Hard MoE | Standard MLP |
|---|---|---|---|---|
| Routing | max(mean(…)) | softmax(weights) | top-k mask | none |
| Convexity | ✅ (vector-valued) | ✅ (scalar only) | ❌ | ❌ |
| Atlas inversion | optional (invert) |
— | — | — |
| Compute cost | ~2.6× MLP | >10× (exp/log) | ~k× experts | baseline |
| Params | ~2.6× MLP | high | high | baseline |
| Gradient smoothness | high (piecewise convex) | smooth | sparse | smooth |
| Interpretability | high | medium | low | low |
Installation
pip install torch-mice
import torch
from torch_mice import VectorHull
# Forward-only mode (default):
hull = VectorHull(in_dim=512, petals=8, out_dim=512, invert=False)
y_fwd = hull(x)
# Full atlas mode with exact inversion:
hull_atlas = VectorHull(in_dim=512, petals=8, out_dim=512, invert=True)
y_atlas = hull_atlas(x)
License
Licensed under the Gratis Public License © 2025 Joshuah Rainstar
Project details
Release history Release notifications | RSS feed
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 torch_mice-0.4.4.tar.gz.
File metadata
- Download URL: torch_mice-0.4.4.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01610134f2fa6aecbe0992e435ae9380a51f20af4c46c3705d5ed30ffb75b65c
|
|
| MD5 |
8fac67255702cc09bb30437c55db6e64
|
|
| BLAKE2b-256 |
b1778f97990477825d23454cc6c1ea6062d383a5ac0bd88df98ad6741c213272
|
File details
Details for the file torch_mice-0.4.4-py3-none-any.whl.
File metadata
- Download URL: torch_mice-0.4.4-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fdb315153bafb9fd1b3e8b1877020b1cd0244cd3292cb5986b8b906a76154f8
|
|
| MD5 |
aac2995cff603b650fa07e071e3f99b4
|
|
| BLAKE2b-256 |
3d33ab82d3ce9a89c9bb0899a90a730b998e04dbc99e2af230ec2a50d2edcaff
|