Skip to main content

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. Instead of softmax routing or hard top-k gating, MiCE fuses networks of convex “petal” networks by overlapping max-of-means with learnable scalar shifts—guaranteeing convexity, interpretability, and efficient compute.

This work builds on research done at Carnegie Mellon Input-Convex Neural Networks and Johannes Kepler University Principled Weight Initialisation for Input-Convex Neural Networks and the development process empirically explored a multitude of domains of convex and nuanced recombination of results. The concise explanation is that the cascaded gating approach outcompetes Kolmogorov-Arnold Network basis interpretation, while the cascaded mean-max-shift approach outcompletes LogSumExp. Both approaches outcompete the mentioned comparable systems in efficiency as well as in loss behavior over convex and non-convex problems, although it is not by this implied that this or other convex models can efficiently approximate non-convex problems.

Why MiCE?

  • Convexity guarantees
    Every MiCE model computes a convex function of its inputs. This ensures stable optimization, monotonic gradient behavior, and global convergence properties that standard MLPs and hard-MoE lack.

  • Efficiency
    No exponentials, no log-sum-exp, no discrete routing. Max-of-means fusion costs only a handful of adds, means, and a single max per group. Memory and FLOPs scale ~2.6× a 2-layer MLP with 4× expansion—far cheaper than full softmax MoE.

  • Interpretability
    Each petal specializes in a convex region; groups overlap, shifts encode priors, and the max operation cleanly partitions input space. You can visualize which expert wins where.

How MiCE Differs

Feature MiCE (MoMx) Softmax MoE Hard Routing MoE Standard MLP
Routing max(mean(…)) softmax(weights) top-k expert mask monolithic
Convexity ✅ (scalar only)
Compute cost ~2.6× MLP >10× (exponentials) ~k× experts baseline
Memory footprint ~2.6× params high (dense activations) high (expert states) baseline
Gradient flow dense in groups dense sparse (top-k only) dense
Smoothness piecewise convex smooth non-smooth smooth
Interpretability high medium low low

Relative Costs

  • Parameters & FLOPs
    MoMx uses ~2.6× the params and MACs of a 2-layer MLP (4× hidden).
  • Vs. LSE Fusion
    No log/exp → 4–10× cheaper per petal.
  • Vs. Hard-MoE
    No expert dispatch overhead or load balancing; single fused model.

Solid Arguments

Against Softmax

  • High compute & memory: O(P) exp/log per input.
  • Numerical instability: needs shift-and-scale tricks.
  • Over-smooth: blurs expert distinctions.

Against Hard Routing

  • Non-convex: breaks convex guarantees.
  • Sparse gradients: only top-k experts update.
  • Brittle: large performance swings at boundaries.

Against MLP

  • Non-convex: susceptible to poor local minima.
  • Width & depth explosion: needs huge hidden dims for expressivity.
  • Opaque: hard to interpret gradient flows.

Quickstart

pip install torch_mice
from torch_mice import VectorHull

model = VectorHull(in_dim=512, petals=8)   # convex, efficient MoE
y = model(x)                               # forward pass

License

Licensed under the Gratis Public License © 2025 Joshuah Rainstar

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

torch_mice-0.2.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

torch_mice-0.2.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_mice-0.2.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for torch_mice-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c40fe115b74e43e45e6bc43e01187fc3df1da957af8229abf7aa559ce0c21b19
MD5 1f371576c1b69343cf98bc5798e4885d
BLAKE2b-256 5f9e3957cb1a375f90b49b8d5e3afde6baf521fb973eb4dd49a979620ee56c07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torch_mice-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for torch_mice-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d66153d0fd1e65982cba8892f851252cd31251a833450fad031dc7a1da5871a7
MD5 6785a2314db61d7cdb2688ec46790e97
BLAKE2b-256 0ab14128f61ae87ee90f2aabdf1dcda29f00dbd9d7d5968f17c98ab2faf6ca06

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