commit 6ac2fdb8841adc9e035afd0342f0d2493a386c3f
parent fd2dd8912dbb784155fd3d46cf835c599b6458f9
Author: David Freifeld <freifeld.david@gmail.com>
Date: Mon, 29 Jun 2020 11:26:49 -0700
Updated README
Diffstat:
3 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/example.py b/example.py
@@ -28,16 +28,16 @@ while(i < 1340):
x.append(i)
i+=1
print(y)
-# plt.plot(x,y, label = "ML-in-Parallel (Sequential)")
-# i = 20
-# otherlist = []
-# while(i < 1340):
-# otherlist.append(i)
-# i += 20
-
-# plt.plot(otherlist, [2.3994078636169434, 1.2735769748687744, 1.0030598640441895, 0.8972160816192627, 0.801548957824707, 0.752018928527832, 0.7073678970336914, 0.6857280731201172, 0.6707980632781982, 0.6421489715576172, 0.6614980697631836, 0.6403779983520508, 0.7251319885253906, 0.6796879768371582, 0.6601080894470215, 0.6711599826812744, 0.6432759761810303, 0.6491389274597168, 0.6762490272521973, 0.6859049797058105, 0.7067179679870605, 0.7142889499664307, 0.7258059978485107, 0.7868969440460205, 0.7326970100402832, 0.7365641593933105, 0.7576079368591309, 0.7772500514984131, 0.8062641620635986, 0.7768490314483643, 0.8253629207611084, 0.8264601230621338, 0.8459320068359375, 0.9670729637145996, 0.8388969898223877, 0.9129719734191895, 0.9009649753570557, 0.8916170597076416, 0.8926799297332764, 0.9171609878540039, 0.9242072105407715, 0.9534740447998047, 0.947465181350708, 0.9723358154296875, 1.018247127532959, 1.1208629608154297, 1.014026165008545, 1.034980058670044, 1.0626468658447266, 1.080394983291626, 1.0627479553222656, 1.0839190483093262, 1.0938241481781006, 1.127730131149292, 1.1265759468078613, 1.136888027191162, 1.140428066253662, 1.1712510585784912, 1.206390142440796, 1.2087180614471436, 1.4066569805145264, 1.2425589561462402, 1.280066967010498, 1.2891559600830078, 1.3243582248687744, 1.3152379989624023], label="Keras")
-# plt.legend()
-# plt.show()
+plt.plot(x,y, label = "ML-in-Parallel (Sequential)")
+i = 20
+otherlist = [1, 5, 10, 15]
+while(i < 1340):
+ otherlist.append(i)
+ i += 20
+
+plt.plot(otherlist, [38.563481092453, 8.210114002227783, 4.5140931606292725, 3.3074569702148438, 2.3994078636169434, 1.2735769748687744, 1.0030598640441895, 0.8972160816192627, 0.801548957824707, 0.752018928527832, 0.7073678970336914, 0.6857280731201172, 0.6707980632781982, 0.6421489715576172, 0.6614980697631836, 0.6403779983520508, 0.7251319885253906, 0.6796879768371582, 0.6601080894470215, 0.6711599826812744, 0.6432759761810303, 0.6491389274597168, 0.6762490272521973, 0.6859049797058105, 0.7067179679870605, 0.7142889499664307, 0.7258059978485107, 0.7868969440460205, 0.7326970100402832, 0.7365641593933105, 0.7576079368591309, 0.7772500514984131, 0.8062641620635986, 0.7768490314483643, 0.8253629207611084, 0.8264601230621338, 0.8459320068359375, 0.9670729637145996, 0.8388969898223877, 0.9129719734191895, 0.9009649753570557, 0.8916170597076416, 0.8926799297332764, 0.9171609878540039, 0.9242072105407715, 0.9534740447998047, 0.947465181350708, 0.9723358154296875, 1.018247127532959, 1.1208629608154297, 1.014026165008545, 1.034980058670044, 1.0626468658447266, 1.080394983291626, 1.0627479553222656, 1.0839190483093262, 1.0938241481781006, 1.127730131149292, 1.1265759468078613, 1.136888027191162, 1.140428066253662, 1.1712510585784912, 1.206390142440796, 1.2087180614471436, 1.4066569805145264, 1.2425589561462402, 1.280066967010498, 1.2891559600830078, 1.3243582248687744, 1.3152379989624023], label="Keras")
+plt.legend()
+plt.show()
# sum = 0
# for i in range(10):
diff --git a/mapreduce.a b/mapreduce.a
Binary files differ.
diff --git a/readme.md b/readme.md
@@ -1,43 +1,53 @@
# ML in Parallel
## About
-"ML in Parallel" (better name pending) is a work-in-progress machine learning library written in C++ designed to run quickly and in parallel. Parallelization is achieved by utilizing Google's powerful MapReduce framework with [a custom implementation in C](https://github.com/richardfeynmanrocks/mapreduce), and the compiled nature of C++/C as well as the optimizations enabled by gcc's O2 layer enable further speedups. On the same benchmark task (of running a small neural network for 50 epochs on a specified dataset) In some preliminary benchmarks "ML in Parallel" has ran up to 50x faster than a simple Keras program. This library is also easily accessible
+"ML in Parallel" (better name pending) is a work-in-progress machine learning library written in C++ designed to run as fast as possible. Parallelization will be achieved by utilizing Google's powerful MapReduce framework with [a custom implementation in C](https://github.com/richardfeynmanrocks/mapreduce), and the compiled nature of C++/C as well as the optimizations enabled by compilers enable further speedups. On the same benchmark task (of running a small neural network for 50 epochs on a specified dataset) In some preliminary benchmarks "ML in Parallel" has ran up to ~90-110x faster than a simple Keras program. This library is also easily accessible and initializing and using a neural network can be done in just 10 lines of code.
## Benchmark Info
-Coming soon: A detailed rundown of the speed of "ML in Parallel" vs popular machine learning libraries for Python (and eventually comparisons to C++ libraries as well) as well as a handy and flexible Python script for creating benchmark graphs on the fly.
-## Testing/Demo
-As of now, a demo of a neural network with feedforward and backpropagation is available (as well as a Keras demo for reference). **Note: You'll need to add the `mapreduce` archive file to the project directory, which can be found [here](https://github.com/richardfeynmanrocks/mapreduce).**
+Batch size of model vs. total runtime for this project and Keras:
-### Sequential
-See the sequential demo by including the header file in you project, calling `demo`, and building/running with the following commands:
-```
-g++ YOUR_FILE bpnn.cpp mapreduce.a -O2 -o bpnn -std=c++11 -w
-./bpnn
-```
+
-### Parallel
-Similarly, build and run the parallel demo with these commands:
-```
-g++ mr_bpnn_2.cpp bpnn.cpp mapreduce.a -O2 -o bpnn -std=c++11 -w
-./bpnn NUM_PARALLEL_NETWORKS PATH_TO_DATA YOUR_PUBLIC_IP 1
-```
+Average runtime for batch size of 10 for 10 trials:
-### Other
-Compare these demonstrations with a sample Keras demo by running `python kerasdemo.py`
+
+
+Coming soon: A more detailed rundown of the speed of "ML in Parallel" vs popular machine learning libraries for Python (and eventually comparisons to C++ libraries as well) as well as a handy and flexible Python script for creating benchmark graphs on the fly.
## Usage
-As of now "ML in Parallel" is not fully fit for usage inside code.
+As of now using "ML in Parallel" inside C++ code requires manual building.
+
+### Precompiled Libraries
+Head to the 'Releases' section and pick up the right python library for you if you don't want to build from source.
+
+### Build Configurations
+
+There are 5 build configurations, each one prioritizing program speed more than the last. *Warning!* Makefile assumes the presence of the Intel C++ Compiler (`icpc`). If you don't have this, replace all instances of `icpc` in the Makefile with `g++`.
+
+- Level 1: `make`
+Simply builds the project with no optimization at all. Use this if you don't want to wait long for the library to compile and don't care too much about speed in the moment.
+
+- Level 2: `make fast`
+Builds the project with the O3 optimization setting, essentially the highest optimization configuration without manually passing optimization flags (Ofast proves slower). Use this if you want some speed but shorter build commands and compile times.
+
+- Level 3: `make faster`
+Builds the project with O3 as well as specific optimization flags relevant to matrix operations. Links with Intel's Math Kernel Library (make sure you have this!). Provides an extra boost to speed. Use this if you care a lot about speed but are not willing to sacrifice anything but compile times for it.
+
+- Level 4: `make tradeoffs`
+Builds the project with O3, specific optimization flags, and *more* specific optimization flags that sacrifice things like precision and make assumptions to increase speed even further. Use this if you care about speed more than precision and are willing to make some tradeoffs (and also don't mind longer compile times).
+
+In the future this setting may try to parallelize operations (even if the network is already parallelized with MapReduce). It may also work with branch prediction and cache optimization, but it's possible just leaving that to the compiler is better.
+
+- Level 5: `make reckless`
+This option is not implemented as of now.
+All the aforementioned compiler options as well as compiler options that are potentially unsafe. Defines the `RECKLESS` macro which will skip anything that is not absolutely necessary in the code (with preprocessor statements like `#ifndef`).
### Python Bindings
-This feature is largely experimental but is the preferred way to demo as of now.
1. Install both the C++ end of pybind11 and the python end.
-2. Build with `make` or the much uglier alternative:
-```
-c++ -w -O2 -Wall -shared -std=c++11 -undefined dynamic_lookup `python3 -m pybind11 --includes` mr_bpnn_2.cpp bpnn.cpp mapreduce.a -o mrbpnn`python3-config --extension-suffix`
-```
+2. Build with your chosen configuration using `make`.
3. Copy the `mrbpnn.cpython-37m-darwin.so` file into your personal project directory.
4. Import `mrbpnn` from your Python code and use it.
-5. Profit.
+5. Look to the `example.py` file for simple usage of the library.