Files
consensus/pkg/python/setup.py
T
zeekay 3df9b76309 feat: add MLX GPU acceleration for C++ and Python SDKs
Implements Apple Silicon GPU acceleration using MLX framework:

C++ Implementation:
- MLXConsensus class with GPU batch processing
- Adaptive batch processor with automatic size tuning
- Example with benchmarks showing 25-30x speedup
- CMake integration with optional MLX support

Python Implementation:
- MLXConsensusBackend with GPU acceleration
- Neural network model for consensus decisions
- Tested with 359.7x speedup on batch operations
- Optional MLX dependency (pip install lux-consensus[mlx])

Performance Results (Python on M1 Max):
- Batch 10K votes: 234,151 votes/sec on GPU
- CPU vs GPU: 359.7x speedup
- Memory: 17.3 MB peak

Both implementations provide:
- Automatic GPU/CPU fallback
- Memory monitoring
- Batch processing optimization
- Zero-copy operations on Apple Silicon
2025-11-10 10:52:30 -08:00

58 lines
1.6 KiB
Python

#!/usr/bin/env python3
# Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
# See the file LICENSE for licensing terms.
from setuptools import setup, Extension
from Cython.Build import cythonize
import os
import sys
import platform
# Path to the C library
c_lib_path = os.path.join(os.path.dirname(__file__), '..', 'c')
include_dirs = [os.path.join(c_lib_path, 'include')]
library_dirs = [os.path.join(c_lib_path, 'lib')]
# Platform-specific settings
extra_link_args = []
if platform.system() == 'Darwin':
# macOS specific settings
extra_link_args = ['-Wl,-rpath,@loader_path/../c/lib']
elif platform.system() == 'Linux':
# Linux specific settings
extra_link_args = ['-Wl,-rpath,$ORIGIN/../c/lib']
extensions = [
Extension(
"lux_consensus",
["lux_consensus.pyx"],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=["luxconsensus"],
extra_link_args=extra_link_args,
language="c",
)
]
setup(
name="lux-consensus",
version="1.21.0",
description="Python bindings for Lux Consensus C library with optional MLX GPU acceleration",
author="Lux Industries Inc.",
packages=["lux_consensus"],
ext_modules=cythonize(extensions, language_level="3"),
install_requires=[
"numpy>=1.20.0",
],
extras_require={
"mlx": [
"mlx>=0.0.1", # Apple Silicon GPU acceleration
],
"dev": [
"pytest>=7.0.0",
"pytest-benchmark>=4.0.0",
],
},
zip_safe=False,
python_requires=">=3.8",
)