PyTorch
PyTorch is an open-source deep learning library, originally developed by Meta Platforms and currently developed with support from the Linux Foundation.
≈ 12 min read
PyTorch. encyclopegia.org, snapshot enwiki-001378376798. /a/pytorch
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
PyTorch is an open-source deep learning library, originally developed by Meta Platforms and currently developed with support from the Linux Foundation. The successor to Torch, PyTorch provides a high-level API that builds upon optimised, low-level implementations of deep learning algorithms and architectures, such as the Transformer, or SGD. Notably, this API simplifies model training and inference to a few lines of code. PyTorch allows for automatic parallelization of training and, internally, implements CUDA bindings that speed training further by leveraging GPU resources.
PyTorch utilises the tensor as a fundamental data type, similarly to NumPy. Training is facilitated by a reversed automatic differentiation system, Autograd, that constructs a directed acyclic graph of the operations (and their arguments) executed by a model during its forward pass. With a loss, backpropagation is then undertaken.[4]
As of 2025[update], PyTorch remains one of the most popular deep learning libraries, alongside others such as TensorFlow and Keras.[5] It can be installed using Anaconda package managers.[6] A number of commercial deep learning systems are built on top of PyTorch, including ChatGPT,[7] Tesla Autopilot,[8] Uber's Pyro,[9] and Hugging Face's Transformers.[10][11]
History
edit edit sourceIn 2001, Torch was written and released under a GPL by the Idiap Research Institute.[12] It was a machine-learning library written in C++ and CUDA, supporting methods including neural networks, support vector machines (SVM), hidden Markov models, etc.[13][14][15] Around 2010, it was rewritten by Ronan Collobert, Clement Farabet and Koray Kavuckuoglu. This was known as Torch7 or LuaTorch. This was written so that the backend was in C and the frontend was in Lua.[16] In mid-2016, some developers refactored it to decouple the frontend and the backend, with strong influence from torch-autograd and Chainer. In turn, torch-autograd was influenced by HIPS/autograd.[17] Development on Torch7 ceased in 2018 and was subsumed by the PyTorch project.[18][19]
Meta (formerly known as Facebook) operates both PyTorch and Convolutional Architecture for Fast Feature Embedding (Caffe2), but models defined by the two frameworks were mutually incompatible. The Open Neural Network Exchange (ONNX) project was created by Meta and Microsoft in September 2017 to decouple deep learning frameworks from hardware-specific runtimes, allowing models to be converted between frameworks and optimized for execution providers like NVIDIA’s TensorRT.[20] Caffe2 was merged into PyTorch at the end of March 2018.[21] In September 2022, Meta announced that PyTorch would be governed by the independent PyTorch Foundation, a newly created subsidiary of the Linux Foundation.[22]
PyTorch 2.0 was released on 15 March 2023, introducing TorchDynamo, a Python-level compiler that makes code run up to two times faster, along with significant improvements in training and inference performance across major cloud platforms.[23][24]
PyTorch tensors
edit edit sourcePyTorch defines a class called Tensor (torch.Tensor) to store and operate on homogeneous multidimensional rectangular arrays of numbers. PyTorch supports various sub-types of multi-dimensional arrays,[25] or Tensors.[26] PyTorch Tensors are similar to NumPy Arrays, but can also be operated on by a CUDA-capable NVIDIA GPU. PyTorch has also been developing support for other GPU platforms, for example, AMD's ROCm[27] and Apple's Metal Framework.[28]
PyTorch neural networks
edit edit sourcePyTorch defines a module called nn (torch.nn) to describe neural networks and to support training. This module offers a comprehensive collection of building blocks for neural networks, including various layers and activation functions, enabling the construction of complex models. Networks are built by inheriting from the torch.nn module and defining the sequence of operations in the forward() function.
PyTorch Serialized File Format
edit edit sourcePytorch can save and load models using its own file format, which is a ZIP64 archive containing the model weights in a Python pickle file, and other information such as the byte order. The file extensions .pt and .pth are commonly used for these files.[29]
Example
edit edit sourceThe following program shows the low-level functionality of the library with a simple example.
import torch dtype = torch.float device = torch.device("cpu") # Execute all calculations on the CPU # device = torch.device("cuda:0") # Executes all calculations on the GPU # Create a tensor and fill it with random numbers a = torch.randn(2, 3, device=device, dtype=dtype) print(a) # Output: tensor([[-1.1884, 0.8498, -1.7129], # [-0.8816, 0.1944, 0.5847]]) b = torch.randn(2, 3, device=device, dtype=dtype) print(b) # Output: tensor([[ 0.7178, -0.8453, -1.3403], # [ 1.3262, 1.1512, -1.7070]]) print(a * b) # Output: tensor([[-0.8530, -0.7183, 2.58], # [-1.1692, 0.2238, -0.9981]]) print(a.sum()) # Output: tensor(-2.1540) print(a[1, 2]) # Output of the element in the third column of the second row (zero-based) # Output: tensor(0.5847) print(a.max()) # Output: tensor(0.8498)The following code block defines a neural network with linear layers using the nn module.
See also
edit edit source- Comparison of deep learning software
- Comparison of machine learning software
- Differentiable programming
- DeepSpeed
- Open-source artificial intelligence
- PyTorch Lightning
References
edit edit source- ^ Chintala, Soumith (1 September 2016). "PyTorch Alpha-1 release". GitHub. Archived from the original on 29 August 2021. Retrieved 19 August 2020. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Release 2.15.0". 28 October 2026. Retrieved 29 October 2026. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Claburn, Thomas (12 September 2022). "PyTorch gets lit under The Linux Foundation". The Register. Archived from the original on 18 October 2022. Retrieved 18 October 2022. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Autograd Mechanics". PyTorch Documentation. Retrieved 13 November 2025. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Top 30 Open Source Projects". github.com. Retrieved 13 November 2025. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Mukherjee, Amartya; Dey, Nilanjan (30 May 2019). Smart Computing with Open Source Platforms. CRC Press. p. 229. ISBN 978-1-351-12032-6. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "OpenAI standardizes on PyTorch". 30 January 2020. Retrieved 8 January 2026. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Karpathy, Andrej (6 November 2019). "PyTorch at Tesla - Andrej Karpathy, Tesla". YouTube. Archived from the original on 24 March 2023. Retrieved 2 June 2020. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Uber AI Labs Open Sources Pyro, a Deep Probabilistic Programming Language". Uber Engineering Blog. 3 November 2017. Archived from the original on 25 December 2017. Retrieved 18 December 2017. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ PYTORCH-TRANSFORMERS: PyTorch implementations of popular NLP Transformers, PyTorch Hub, 1 December 2019, archived from the original on 11 June 2023, retrieved 1 December 2019 Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Ecosystem Tools". pytorch.org. Archived from the original on 18 July 2023. Retrieved 18 June 2020. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "PyTorch License – Copyright notice". GitHub. Retrieved 12 June 2026. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Torch Tutorial", Ronan Collobert, IDIAP, 2002-10-02 Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ R. Collobert, S. Bengio and J. Mariéthoz. Torch: a modular machine learning software library. Technical Report IDIAP-RR 02-46, IDIAP, 2002. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Torch Library". Archived from the original on 31 October 2001. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Collobert, Ronan; Kavukcuoglu, Koray; Farabet, Clément (2012), "Implementing Neural Networks Efficiently", in Montavon, Grégoire; Orr, Geneviève B.; Müller, Klaus-Robert (eds.), Neural Networks: Tricks of the Trade: Second Edition, Berlin, Heidelberg: Springer, pp. 537–557, doi:10.1007/978-3-642-35289-8_28, ISBN 978-3-642-35289-8, retrieved 10 June 2025 Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ HIPS/autograd, Formerly: Harvard Intelligent Probabilistic Systems Group -- Now at Princeton, 6 April 2026, retrieved 6 April 2026 Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ torch/torch7, Commit fd0ee3b, 2018-07-02 Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Chintala, Soumith (17 December 2023). "PyTorch's design origins". soumith.ch. Retrieved 7 February 2026. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Quach, K. (7 September 2017). "Microsoft, Facebook tie the knot on AI to take on Google". The Register. The goal is to create a 'universal translator' for AI... [allowing] developers to move their models between different frameworks and hardware runtimes. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Caffe2 Merges With PyTorch". 2 April 2018. Archived from the original on 30 March 2019. Retrieved 2 January 2019. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ Edwards, Benj (12 September 2022). "Meta spins off PyTorch Foundation to make AI framework vendor neutral". Ars Technica. Archived from the original on 13 September 2022. Retrieved 13 September 2022. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Dynamo Overview". Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "PyTorch 2.0 brings new fire to open-source machine learning". VentureBeat. 15 March 2023. Archived from the original on 16 March 2023. Retrieved 16 March 2023. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "PyTorch Tensor vs NumPy Array". GeeksforGeeks. 1 March 2024. Retrieved 7 April 2026. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "An Introduction to PyTorch – A Simple yet Powerful Deep Learning Library". analyticsvidhya.com. 22 February 2018. Archived from the original on 22 October 2019. Retrieved 11 June 2018. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Installing PyTorch for ROCm". rocm.docs.amd.com. 9 February 2024. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "Introducing Accelerated PyTorch Training on Mac". pytorch.org. Archived from the original on 29 January 2024. Retrieved 4 June 2022. Wikipedia revision 1378376798, retrieved 2026-11-18
- ^ "PyTorch Serialized File Format". Library of Congress. Wikipedia revision 1378376798, retrieved 2026-11-18
External links
edit edit source Deep learning software- Apple Core ML
- IBM Watson
- Neural Designer
- Wolfram Mathematica
- MATLAB Deep Learning Toolbox
services
officers
Board
employees
source
media
- History of Facebook
- Timeline of Instagram
- Timeline of WhatsApp
- Acquisitions
- f8 conference
- Censorship
- Criticism
- Litigation
- Young v. Facebook, Inc. (2011)
- Fraley v. Facebook, Inc. (2016)
- Force v. Facebook, Inc. (2019)
- Facebook, Inc. v. Duguid (2021)
- Federal Trade Commission v. Meta Platforms, Inc. (ongoing)
- Unions
Text derived from https://en.wikipedia.org/w/index.php?oldid=1378376798 under CC BY-SA 4.0; modifications have been made.
References
1 claim could not be tied to a specific sentence and is listed in the table below instead.