torch-mlir

The Torch-MLIR project aims to provide first class support from the PyTorch ecosystem to the MLIR ecosystem.

https://github.com/llvm/torch-mlir

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    6 of 227 committers (2.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

compiler mlir pytorch

Keywords from Contributors

jax cryptocurrencies transformers cryptography interpretability hack agents meshing standardization pipeline-testing
Last synced: 6 months ago · JSON representation ·

Repository

The Torch-MLIR project aims to provide first class support from the PyTorch ecosystem to the MLIR ecosystem.

Basic Info
  • Host: GitHub
  • Owner: llvm
  • License: other
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 23.7 MB
Statistics
  • Stars: 1,621
  • Watchers: 251
  • Forks: 630
  • Open Issues: 475
  • Releases: 1,000
Topics
compiler mlir pytorch
Created over 5 years ago · Last pushed 6 months ago
Metadata Files
Readme License Citation Roadmap

README.md

The Torch-MLIR Project

The Torch-MLIR project aims to provide first class compiler support from the PyTorch ecosystem to the MLIR ecosystem.

This project is participating in the LLVM Incubator process: as such, it is not part of any official LLVM release. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project is not yet endorsed as a component of LLVM.

PyTorch PyTorch is an open source machine learning framework that facilitates the seamless transition from research and prototyping to production-level deployment.

MLIR The MLIR project offers a novel approach for building extensible and reusable compiler architectures, which address the issue of software fragmentation, reduce the cost of developing domain-specific compilers, improve compilation for heterogeneous hardware, and promote compatibility between existing compilers.

Torch-MLIR Several vendors have adopted MLIR as the middle layer in their systems, enabling them to map frameworks such as PyTorch, JAX, and TensorFlow into MLIR and subsequently lower them to their target hardware. We have observed half a dozen custom lowerings from PyTorch to MLIR, making it easier for hardware vendors to focus on their unique value, rather than needing to implement yet another PyTorch frontend for MLIR. The ultimate aim is to be similar to the current hardware vendors adding LLVM target support, rather than each one implementing Clang or a C++ frontend.

pre-commit

All the roads from PyTorch to Torch MLIR Dialect

We have few paths to lower down to the Torch MLIR Dialect. - ONNX as the entry points. - Fx as the entry points

Project Communication

  • #torch-mlir channel on the LLVM Discord - this is the most active communication channel
  • Github issues here
  • torch-mlir section of LLVM Discourse

Install torch-mlir snapshot

At the time of writing, we release pre-built snapshots of torch-mlir for Python 3.11 and Python 3.10.

If you have supported Python version, the following commands initialize a virtual environment. shell python3.11 -m venv mlir_venv source mlir_venv/bin/activate

Or, if you want to switch over multiple versions of Python using conda, you can create a conda environment with Python 3.11. shell conda create -n torch-mlir python=3.11 conda activate torch-mlir python -m pip install --upgrade pip

Then, we can install torch-mlir with the corresponding torch and torchvision nightlies. pip install --pre torch-mlir torchvision \ --extra-index-url https://download.pytorch.org/whl/nightly/cpu \ -f https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels

Using torch-mlir

Torch-MLIR is primarily a project that is integrated into compilers to bridge them to PyTorch and ONNX. If contemplating a new integration, it may be helpful to refer to existing downstreams:

While most of the project is exercised via testing paths, there are some ways that an end user can directly use the APIs without further integration:

FxImporter ResNet18

```shell

Get the latest example if you haven't checked out the code

wget https://raw.githubusercontent.com/llvm/torch-mlir/main/projects/pt1/examples/fximporter_resnet18.py

Run ResNet18 as a standalone script.

python projects/pt1/examples/fximporter_resnet18.py

Output

load image from https://upload.wikimedia.org/wikipedia/commons/2/26/YellowLabradorLooking_new.jpg ... PyTorch prediction [('Labrador retriever', 70.65674591064453), ('golden retriever', 4.988346099853516), ('Saluki, gazelle hound', 4.477451324462891)] torch-mlir prediction [('Labrador retriever', 70.6567153930664), ('golden retriever', 4.988325119018555), ('Saluki, gazelle hound', 4.477458477020264)] ```

Repository Layout

The project follows the conventions of typical MLIR-based projects:

  • include/torch-mlir, lib structure for C++ MLIR compiler dialects/passes.
  • test for holding test code.
  • tools for torch-mlir-opt and such.
  • python top level directory for Python code

Developers

If you would like to develop and build torch-mlir from source please look at Development Notes

Owner

  • Name: LLVM
  • Login: llvm
  • Kind: organization

This is the LLVM organization on GitHub for the LLVM Project: a collection of modular and reusable compiler and toolchain technologies.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Torch-MLIR
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - name: LLVM
repository-code: 'https://github.com/llvm/torch-mlir'
abstract: >-
  The Torch-MLIR project aims to provide first class support
  from the PyTorch ecosystem to the MLIR ecosystem.
keywords:
  - Compiler
  - PyTorch
  - MLIR
license:
  - Apache-2.0 with LLVM Exceptions
  - BSD

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 3,418
  • Total Committers: 227
  • Avg Commits per committer: 15.057
  • Development Distribution Score (DDS): 0.849
Past Year
  • Commits: 646
  • Committers: 95
  • Avg Commits per committer: 6.8
  • Development Distribution Score (DDS): 0.868
Top Committers
Name Email Commits
Sean Silva s****n@g****m 515
Stella Laurenzo s****t@g****m 330
Vivek Khandelwal v****4@g****m 296
Rob Suderman s****n@g****m 132
Yuanqiang Liu l****u@b****m 127
Ramiro Leal-Cavazos r****0@g****m 123
Ashay Rane a****y 118
Roll PyTorch Action t****r 115
powderluv p****v 101
zjgarvey 4****y 76
Yi Zhang c****i@g****m 63
Sambhav Jain s****n@g****m 57
Prashant Kumar p****t@n****m 49
penguin_wwy 9****6@q****m 47
Aart Bik a****k@g****m 46
Gaurav Shukla g****v@n****m 46
Jiawei Wu w****l@b****m 43
Tanyo Kwok t****y@a****m 37
Xinyu Yang y****2@b****m 35
Henry Tu h****u@c****t 35
Maksim Levental m****l@g****m 33
Jae Hoon (Antonio) Kim 1****m 33
Xida Ren (Cedar) c****n@g****m 32
Matthias Gehre 9****d 29
jinchen 4****2 27
Suraj Sudhir 1****s 26
Marius Brehler m****r@a****m 25
stephenneuendorffer s****r@x****m 25
George Petterson g****s@p****m 23
Jacob Gordon j****n@a****m 21
and 197 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 290
  • Total pull requests: 2,267
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 14 days
  • Total issue authors: 145
  • Total pull request authors: 174
  • Average comments per issue: 1.46
  • Average comments per pull request: 1.02
  • Merged pull requests: 1,701
  • Bot issues: 0
  • Bot pull requests: 13
Past Year
  • Issues: 132
  • Pull requests: 834
  • Average time to close issues: 10 days
  • Average time to close pull requests: 10 days
  • Issue authors: 72
  • Pull request authors: 105
  • Average comments per issue: 0.77
  • Average comments per pull request: 1.03
  • Merged pull requests: 574
  • Bot issues: 0
  • Bot pull requests: 13
Top Authors
Issue Authors
  • renxida (21)
  • zjgarvey (19)
  • vivekkhandelwal1 (15)
  • zahidwx (11)
  • josel-amd (10)
  • Abhishek-TyRnT (6)
  • dbabokin (5)
  • mgehre-amd (5)
  • kumardeepakamd (5)
  • rsuderman (5)
  • stellaraccident (4)
  • sharavana20 (4)
  • muwys518 (4)
  • IanWood1 (3)
  • vinitdeodhar (3)
Pull Request Authors
  • vivekkhandelwal1 (241)
  • rsuderman (239)
  • zjgarvey (153)
  • qingyunqu (148)
  • penguin-wwy (108)
  • aartbik (77)
  • Xinyu302 (74)
  • justin-ngo-arm (63)
  • renxida (59)
  • jinchen62 (52)
  • bjacobgordon (47)
  • yyp0 (45)
  • AmosLewis (35)
  • stellaraccident (32)
  • sjain-stanford (31)
Top Labels
Issue Labels
help wanted (2) question (1) good first issue (1) bug (1)
Pull Request Labels
dependencies (13) github_actions (7) documentation (1) enhancement (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 471 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 15
  • Total versions: 11
  • Total maintainers: 2
pypi.org: torch-mlir

First-class interop between PyTorch and MLIR

  • Versions: 11
  • Dependent Packages: 0
  • Dependent Repositories: 15
  • Downloads: 471 Last month
Rankings
Dependent repos count: 3.7%
Average: 7.7%
Downloads: 9.2%
Dependent packages count: 10.1%
Maintainers (2)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • cmake *
  • ninja *
  • numpy *
  • pillow *
  • pybind11 *
  • setuptools *
  • torch *
  • torchvision *
  • wheel *
setup.py pypi
  • TODO *
  • To *
  • exact *
  • numpy *
  • restrictive *
  • torch ==
.github/actions/setup-build/action.yml actions
  • actions/cache v3 composite
  • actions/setup-python v4 composite
.github/workflows/RollPyTorch.yml actions
  • ./.github/actions/setup-build * composite
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • peter-evans/create-or-update-comment v2 composite
  • peter-evans/create-pull-request v5.0.1 composite
.github/workflows/bazelBuildAndTest.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • dawidd6/action-send-mail v3 composite
.github/workflows/buildAndTest.yml actions
  • ./.github/actions/setup-build * composite
  • actions/cache/restore v3 composite
  • actions/cache/save v3 composite
  • actions/checkout v3 composite
  • egor-tensin/vs-shell v2 composite
.github/workflows/buildRelease.yml actions
  • ./.github/actions/setup-build * composite
  • actions/checkout v3 composite
  • actions/upload-artifact v2 composite
  • benc-uk/workflow-dispatch v1 composite
  • dwenegar/upload-release-assets v1 composite
  • egor-tensin/vs-shell v2 composite
  • eregon/publish-release v1 composite
.github/workflows/gh-pages-releases.yml actions
  • actions/checkout v3 composite
  • ad-m/github-push-action v0.6.0 composite
.github/workflows/merge-rollpytorch.yml actions
  • actions/checkout v3 composite
.github/workflows/oneshotSnapshotPackage.yml actions
  • actions/checkout v3 composite
  • actions/create-release v1 composite
  • ad-m/github-push-action v0.6.0 composite
  • benc-uk/workflow-dispatch v1 composite
.github/workflows/releaseSnapshotPackage.yml actions
  • actions/checkout v3 composite
  • actions/create-release v1 composite
  • ad-m/github-push-action v0.6.0 composite
  • benc-uk/workflow-dispatch v1 composite
build_tools/docker/Dockerfile docker
  • ${BASE_IMG} latest build
utils/bazel/docker/Dockerfile docker
  • ${BASE_IMG} latest build
build-requirements.txt pypi
  • cmake *
  • ninja *
  • numpy *
  • packaging *
  • pybind11 *
  • pyyaml *
  • setuptools *
  • wheel *
pytorch-requirements.txt pypi
  • torch ==2.2.0.dev20231204
test-requirements.txt pypi
  • dill * test
  • multiprocess * test
  • onnx ==1.15.0 test
  • pillow * test
torchvision-requirements.txt pypi
  • torchvision ==0.17.0.dev20231204
whl-requirements.txt pypi