Reactor Core integrates MLForge as a git submodule to provide high-performance C++ ML primitives accessible from Python via pybind11 bindings.
reactor-core/
├── mlforge/ # Git submodule → MLForge C++ core
│ ├── include/ml/
│ │ ├── core/ # Matrix, utils, data structures
│ │ ├── algorithms/ # LinearRegression, NeuralNet, etc.
│ │ ├── ai/ # Transformers, RL, Quantum ML
│ │ ├── serialization/ # Model serialization
│ │ └── deployment/ # Model server, API
│ ├── src/
│ ├── tests/
│ └── CMakeLists.txt
│
├── bindings/
│ └── reactor_bindings.cpp # Python bindings (pybind11)
│
├── CMakeLists.txt # Build configuration
├── setup.py # Python build script
└── reactor_core/ # Python package
- Location:
mlforge/ - Source: https://github.com/drussell23/MLForge
- Contents:
- C++ headers in
mlforge/include/ml/ - C++ implementations in
mlforge/src/ - Tests in
mlforge/tests/ - CMake build files
- C++ headers in
- File:
CMakeLists.txt - Based on: MLForge's
CMakeLists.txt - Modifications:
- Added pybind11 integration
- Configured Python module build
- Set up linking against MLForgeLib
From MLForge's include/ml/:
core/matrix.h- Matrix operationscore/utils.h- Utility functionscore/data_structures/kd_tree.h- KD-treecore/data_structures/graph_structures.h- Graph structurescore/data_structures/trie.h- Trie
algorithms/linear_regression.h- Linear regressionalgorithms/logistic_regression.h- Logistic regressionalgorithms/neural_net.h- Neural networksalgorithms/decision_tree.h- Decision trees
ai/nlp_transformer.h- NLP transformersai/reinforcement_learning.h- Reinforcement learningai/quantum_ml.h- Quantum ML
serialization/serializer.h- Model serializationdeployment/model_server.h- Model serverdeployment/api.h- API utilities
# macOS
brew install cmake pybind11
# Ubuntu/Debian
sudo apt-get install cmake python3-pybind11git clone --recursive https://github.com/drussell23/reactor-core.git
cd reactor-core# Install Python dependencies
pip install pybind11
# Build and install
pip install -e .import reactor_core
from reactor_core import reactor_core_native
# Check version
print(reactor_core_native.__version__)
print(reactor_core_native.info())
# Test Matrix binding (placeholder)
mat = reactor_core_native.Matrix(3, 3)
print(mat) # <Matrix 3x3>- Module structure
- Version info
- Placeholder Matrix class
- MLForge Matrix bindings
- Linear regression bindings
- Neural network bindings
- Serialization bindings
- Full algorithm suite
- NLP transformer bindings
- Model server integration
- Quantum ML bindings
from reactor_core.reactor_core_native import Matrix
import numpy as np
# Create matrix from NumPy array
arr = np.array([[1, 2], [3, 4]])
mat = Matrix.from_numpy(arr)
# Perform operations (C++ accelerated)
result = mat.multiply(mat)
# Convert back to NumPy
result_np = result.to_numpy()from reactor_core import Trainer, TrainingConfig
from reactor_core.reactor_core_native import LinearRegression
# Use C++ backend for linear regression
config = TrainingConfig(
model_name="custom-regression",
use_cpp_backend=True, # Use MLForge C++
)
trainer = Trainer(config)
trainer.train("./data/regression.csv")- Edit
bindings/reactor_bindings.cpp
#include "ml/algorithms/linear_regression.h"
PYBIND11_MODULE(reactor_core_native, m) {
// Add new binding
py::class_<ml::LinearRegression>(m, "LinearRegression")
.def(py::init<>())
.def("fit", &ml::LinearRegression::fit)
.def("predict", &ml::LinearRegression::predict);
}- Rebuild
pip install -e . --force-reinstall- Test
from reactor_core.reactor_core_native import LinearRegression
model = LinearRegression()
model.fit(X_train, y_train)
predictions = model.predict(X_test)cd mlforge
mkdir build && cd build
cmake ..
make
ctest # Run C++ tests| Operation | Pure Python | MLForge C++ | Speedup |
|---|---|---|---|
| Matrix multiply (1000x1000) | 250ms | 15ms | 16.7x |
| Linear regression fit | 180ms | 12ms | 15x |
| Neural net forward pass | 320ms | 25ms | 12.8x |
(Benchmarks are estimates - actual results TBD)
git submodule update --init --recursivepip install pybind11[global]# Set macOS SDK explicitly
export CMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
pip install -e .To contribute MLForge bindings:
- Fork both
reactor-coreandMLForge - Make changes to MLForge C++ code
- Update bindings in
reactor-core/bindings/ - Submit PRs to both repos
- MLForge Repository: https://github.com/drussell23/MLForge
- pybind11 Documentation: https://pybind11.readthedocs.io/
- Reactor Core: https://github.com/drussell23/reactor-core
Status: 🚧 Work in Progress
MLForge integration is functional but bindings are minimal. Full C++ acceleration coming soon!