Get real, active and permanent YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

Assembly Language vs Pytorch Lightning simple neural network training time comparison

Follow
Computing Mongoose

Comparing the training time of my simple artificial neural network implemented in assembly language (x86 64bit with 32bit floating point numbers, using x87 instructions) and a similar network implemented in Pytorch Lightning. The training in assembly language is over 500 times faster (checkout the second test run). Nevertheless, Pytorch Lightning is a very good framework that I totally recommend for training advanced models. It's just interesting to see the kind of speedup that can be achieved by implementing only the needed functionality in assembly language (without additional checks or object encapsulation, which are useful in larger projects but not for very simple stuff).

For a fair comparison, I am using a virtual machine running in VMware Workstation Player, with a single CPU core, without GPU support. The neural network is trained to learn the OR function. It contains 2 artificial neurons and employs the Logistic (Sigmoid) activation function. Training is performed by backpropagation. The Pytorch Lightning implementation covers a basic approach by creating a Dataset and a Model (LightningModule), combining a Linear layer with a Sigmoid activation function. This is then trained using Stochastic Gradient Descent (SGD) with Mean Square Error (MSE) loss.

My assembly language implementation:
   • Simple Artificial Neural Network enti...  

The blueprint for the implementation (explaining the formulas):
   • Blueprint for an Artificial Neural Ne...  

The code for the assembly language implementation: https://github.com/ComputingMongoose/...

My Assembly Language playlist (contains videos for all the implemented functions):
   • x86 Assembly Language  

My Artificial Intelligence playlist:
   • Artificial Intelligence  

Chapters:
00:00 Introduction
01:36 Training data in assembly language
02:39 Pytorch dataset
03:44 Pytorch Lightning model implementation
06:19 Pytorch Lightning training code
08:18 Discussion about the tests to be performed
10:02 First test of the assembly language neural network
11:03 First test of the Pytorch Lightning implementation
12:53 Second test of the assembly language neural network
13:52 Second test of the Pytorch Lightning implementation
15:27 Discussion of the results



#assemblylanguage #ai #artificialintelligence #linux #neuralnetworks #artificialneuralnetwork #artificialneuralnetworks #x86 #64bits #8087 #python #pytorch

posted by r3min1scezz