PyTorch Framework
A PyTorch Framework is a Python tensor-based deep learning framework.
- Context:
- It can (typically) be used to create PyTorch-based machine learning models.
- It can (typically) be used to create PyTorch-based code.
- It can (typically) support dynamic computation graphs, allowing for real-time changes in the graph during runtime.
- It can range from being a lightweight neural network tool for beginners to a robust deep learning platform for advanced users.
- It can be related to a Torch Platform.
- It can provide a Tensor library (like NumPy) with strong GPU support.
- It can leverage CUDA for accelerated computation on GPUs.
- It can support distributed training for scaling models across multiple devices or nodes.
- It can integrate with TorchScript for optimizing and deploying models in production environments.
- It can utilize the autograd module for automatic differentiation and gradient computation.
- It can be extended through custom C++ extensions, allowing for optimized performance and low-level operations.
- It can facilitate model debugging with interactive debugging tools.
- It can incorporate data loading utilities for handling large datasets efficiently.
- It can offer pre-trained models through the torchvision library for rapid development.
- It can be used in conjunction with other frameworks like TensorFlow for hybrid workflows.
- It can provide model evaluation metrics and tools for performance assessment.
- It can support a variety of neural network architectures, including CNNs, RNNs, and transformers.
- ...
- Example(s):
- PyTorch v2.3.1 (~2024-06-05). Enhanced support for large-scale distributed training and optimizations for new GPU architectures. [1]
- PyTorch v2.1.1 (~2023-11-15). Support for new data augmentation techniques and improvements in model debugging tools. [2]
- PyTorch v1.0.0 (~2018-12-07). First stable release with significant performance improvements and a merge with Caffe2 for production use. [3]
- PyTorch v0.3.1 (~2018-02-11). Bug fixes and improvements were included in autograd and ONNX export support. [4]
- PyTorch v0.3.0 (~2017-12-03). Support for the ONNX (Open Neural Network Exchange) format and various performance optimizations. [5]
- PyTorch v0.2.0 (~2017-08-03). Support for new tensor operations and improved integration with NumPy. [6]
- PyTorch v0.1.5 (~2016-11-18). Focused on initial functionalities and core features of the framework. [7]
https://github.com/pytorch/pytorch/releases
.- ...
- Counter-Example(s):
- See: PyText, Python Package.
References
2023
- https://pytorch.org/blog/accelerating-generative-ai-2/?utm_content=273712247&utm_medium=social&utm_source=facebook&hss_channel=fbp-1620822758218702
- The article outlines optimizations done in native PyTorch to accelerate transformer-based generative AI models like GPT. The goal is to show how fast inference can be achieved with only pure, native PyTorch code.
- Optimizations discussed:
- Torch.compile to reduce CPU overhead and compile faster kernels.
- Static key-value caching for inference to enable further compilation
- int8 quantization to reduce memory bandwidth bottleneck (DNN quantization).
- Speculative decoding with a "draft" model and "verifier" model to break serialization dependency
- int4 quantization and GPTQ to further reduce weight sizes
- Tensor parallelism across GPUs to increase memory bandwidth
2018a
- "PyTorch developer ecosystem expands, 1.0 stable release now available."
- … Researchers and engineers can now readily take full advantage of the open source deep learning framework’s new features, including a hybrid front end for transitioning seamlessly between eager and graph execution modes, revamped distributed training, a pure C++ front end for high-performance research, and deep integration with cloud platforms. ...
... PyTorch has been applied to use cases from image recognition to machine translation. As a result, we’ve seen a wide variety of projects from the developer community that extend and support development. A few of these projects include:
- Horovod — a distributed training framework that makes it easy for developers to take a single-GPU program and quickly train it on multiple GPUs.
- PyTorch Geometry – a geometric computer vision library for PyTorch that provides a set of routines and differentiable modules.
- TensorBoardX – a module for logging PyTorch models to TensorBoard, allowing developers to use the visualization tool for model training.
- … Researchers and engineers can now readily take full advantage of the open source deep learning framework’s new features, including a hybrid front end for transitioning seamlessly between eager and graph execution modes, revamped distributed training, a pure C++ front end for high-performance research, and deep integration with cloud platforms. ...
2018b
- (Wikipedia, 2018) ⇒ https://en.wikipedia.org/wiki/PyTorch Retrieved:2018-1-22.
- PyTorch is an open source machine learning library for Python, used for applications such as natural language processing. It is primarily developed by Facebook's artificial-intelligence research group, and Uber's “Pyro" software for probabilistic programming is built upon it.
2018c
Software | Creator | Software licenseTemplate:Efn | Open source | Platform | Written in | Interface | OpenMP support | OpenCL support | CUDA support | Automatic differentiation[1] | Has pretrained models | Recurrent nets | Convolutional nets | RBM/DBNs | Parallel execution (multi node) |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PyTorch | ... | BSD license | Yes | Linux, macOS | Python, C, CUDA | Python | Yes | Yes | Yes | Yes | Yes | Yes |
2018d
- https://github.com/pytorch/pytorch/blob/v0.3.1/README.md
- QUOTE: At a granular level, PyTorch is a library that consists of the following components:
torch | a Tensor library like NumPy, with strong GPU support |
torch.autograd | a tape-based automatic differentiation library that supports all differentiable Tensor operations in torch |
torch.nn | a neural networks library deeply integrated with autograd designed for maximum flexibility |
torch.multiprocessing | Python multiprocessing, but with magical memory sharing of torch Tensors across processes. Useful for data loading and Hogwild training. |
torch.utils | DataLoader, Trainer and other utility functions for convenience |
torch.legacy(.nn/.optim) | legacy code that has been ported over from torch for backward compatibility reasons |
Usually one uses PyTorch either as:
- a replacement for NumPy to use the power of GPUs.
- a deep learning research platform that provides maximum flexibility and speed
If you use NumPy, then you have used Tensors (a.k.a ndarray).
PyTorch provides Tensors that can live either on the CPU or the GPU, and accelerate compute by a huge amount.
We provide a wide variety of tensor routines to accelerate and fit your scientific computation needs
such as slicing, indexing, math operations, linear algebra, reductions. And they are fast!
PyTorch has a unique way of building neural networks: using and replaying a tape recorder.
Most frameworks such as TensorFlow, Theano, Caffe and CNTK have a static view of the world. One has to build a neural network, and reuse the same structure again and again. Changing the way the network behaves means that one has to start from scratch.
With PyTorch, we use a technique called reverse-mode auto-differentiation, which allows you to
change the way your network behaves arbitrarily with zero lag or overhead. Our inspiration comes
from several research papers on this topic, as well as current and past work such as
torch-autograd[8],
autograd[9],
Chainer[10], etc.
…
2017
- http://pytorch.org/about/
- QUOTE: PyTorch is a python package that provides two high-level features:
- Tensor computation (like numpy) with strong GPU acceleration.
- Deep Neural Networks built on a tape-based autograd system.
- You can reuse your favorite python packages such as numpy, scipy and Cython to extend PyTorch when needed.
- At a granular level, PyTorch is a library that consists of the following components:
- QUOTE: PyTorch is a python package that provides two high-level features:
Package Description torch a Tensor library like NumPy, with strong GPU support torch.autograd a tape based automatic differentiation library that supports all differentiable Tensor operations in torch torch.nn a neural networks library deeply integrated with autograd designed for maximum flexibility torch.optim an optimization package to be used with torch.nn with standard optimization methods such as SGD, RMSProp, LBFGS, Adam etc. torch.multiprocessing python multiprocessing, but with magical memory sharing of torch Tensors across processes. Useful for data loading and hogwild training. torch.utils DataLoader, Trainer and other utility functions for convenience torch.legacy(.nn/.optim) legacy code that has been ported over from torch for backward compatibility reasons
- Usually one uses PyTorch either as:
- A replacement for numpy to use the power of GPUs.
- a deep learning research platform that provides maximum flexibility and speed
- Usually one uses PyTorch either as: