tadashi

A library for code transformations with guaranteed legality

https://github.com/vatai/tadashi

Science Score: 44.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
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

A library for code transformations with guaranteed legality

Basic Info
  • Host: GitHub
  • Owner: vatai
  • Language: C
  • Default Branch: main
  • Homepage:
  • Size: 4.27 MB
Statistics
  • Stars: 15
  • Watchers: 3
  • Forks: 1
  • Open Issues: 18
  • Releases: 0
Created about 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Citation

README.org

#+title: Tadashi

* Install

After the requirements are installed, TADASHI can be ~pip~ installed from GitHub using:

#+begin_src bash
  pip install git+https://github.com/vatai/tadashi.git
#+end_src

Requirements are LLVM, clang, autotools, pkgconfig, libyaml, libntl,
libgmp, swig. The exact ~apt-get~ packages can be found in [[file:./.github/workflows/tests.yaml][this file]].

Using [[file:./deps/docker/][Docker]] is also an option.

** Development

#+begin_src bash
   cmake -S . -B build -GNinja -DCMAKE_INSTALL_PREFIX=ctadashi -DCALL_FROM_SETUP_PY=ON
   ninja -C build install
#+end_src

Execute with:

#+begin_src bash
  PYTHONPATH=. python examples/end2end.py
#+end_src


* Documentation

After the double blind review and the end of the anonymity
requirement, detailed API documentation will be uploaded to
https://tadashi.readthedocs.io/ (or a similar URL).

** Quick start

An [[./examples/inputs/end2end.py][end-to-end]] example is provided below (split into parts with
comments and outputs).  This example can be run from the repository
root with the following command:
#+begin_src bash
  python examples/inputs/end2end.py
#+end_src

#+RESULTS:

*** End-to-end example

After importing Tadashi we obtain the loop nests (SCoPs) from a [[./tadashi/apps.py][Simple]]
app.

#+begin_src python :session s1 :results output :exports both :tangle examples/end2end.py
  from pathlib import Path

  import tadashi
  from tadashi.apps import Simple
  dir_path = Path(__file__).parent
  examples_path = dir_path if dir_path.name == "examples" else "examples"
  app = Simple(f"{examples_path}/inputs/depnodep.c")
  print(app)
#+end_src

#+RESULTS:
: 

Select a node and a transformation, and check that the transformation
is available on the selected node.
#+begin_src python :exports both :session s1 :results output :exports both :tangle examples/end2end.py
  node = app.scops[0].schedule_tree[1]
  print(f"{node=}")
  tr = tadashi.TrEnum.FULL_SHIFT_VAR
  print(f"{tr in node.available_transformations=}")
  # output:
#+end_src

#+RESULTS:
: node=Node type: NodeType.BAND, [{'params': ['N'], 'vars': ['j', 'i']}], [N] -> L_0[{ S_0[j, i] -> [(j)] }], [0]
: tr in node.available_transformations=True

Check the available arguments for the given node-transformation pair.
#+begin_src python :session s1 :results output :exports both :tangle examples/end2end.py
  print(f"{tr=}")
  lu = node.available_args(tr)
  print(f"{len(lu)=}")
  print(f"{lu[0]=}")
  print(f"{lu[1]=}")
  # output:
#+end_src

#+RESULTS:
: tr=
: len(lu)=2
: lu[0]=LowerUpperBound(lower=None, upper=None)
: lu[1]=LowerUpperBound(lower=0, upper=2)


Perform the transformation and check legality.
#+begin_src python :session s1 :results output :exports both :tangle examples/end2end.py
  args = [1, 13]
  print(f"{node.valid_args(tr, *args)=}")
  legal = node.transform(tr, *args)
  print(f"{legal=}")
  # output:
#+end_src

#+RESULTS:
: node.valid_args(tr, *args)=True
: legal=True

Generate new code, compile it and measure the performance.
#+begin_src python :session s1 :results output :exports both :tangle examples/end2end.py
  app.compile()
  print(f"{app.measure()=}")
  transformed_app = app.generate_code()
  transformed_app.compile()
  print(f"{transformed_app.measure()=}")
  # output:
#+end_src

#+RESULTS:
: app.measure()=24.0
: transformed_app.measure()=39.0

Owner

  • Name: Emil Vatai
  • Login: vatai
  • Kind: user
  • Location: Japan
  • Company: Riken, R-CCS, HPAIS

#HPC #ML #math #emacs #judo. Research scientist at @RIKEN-RCCS

Citation (CITATION.bib)

@misc{vatai2024tadashi,
  title = {Tadashi: {{Enabling AI-Based Automated Code Generation With Guaranteed Correctness}}},
  shorttitle = {Tadashi},
  author = {Vatai, Emil and Drozd, Aleksandr and Ivanov, Ivan R. and Ren, Yinghao and Wahib, Mohamed},
  year = {2024},
  month = oct,
  number = {arXiv:2410.03210},
  eprint = {2410.03210},
  publisher = {arXiv},
  doi = {10.48550/arXiv.2410.03210},
  urldate = {2024-11-09},
  abstract = {Frameworks and DSLs auto-generating code have traditionally relied on human experts developing them to have in place rigorous methods to assure the legality of the applied code transformations. Machine Learning (ML) is gaining wider adoption as a means to auto-generate code optimised for the hardware target. However, ML solutions, and in particular black-box DNNs, provide no such guarantees on legality. In this paper we propose a library, Tadashi, which leverages the polyhedral model to empower researchers seeking to curate datasets crucial for applying ML in code-generation. Tadashi provides the ability to reliably and practically check the legality of candidate transformations on polyhedral schedules applied on a baseline reference code. We provide a proof that our library guarantees the legality of generated transformations, and demonstrate its lightweight practical cost. Tadashi is available at https://github.com/vatai/tadashi/.},
  archiveprefix = {arXiv},
  preview = {proj-tadashi-sampling.png},
  keywords = {Computer Science - Machine Learning},
  file = {/home/vatai/Sync/zotero-data/pdfs/my_pub/Vatai et al. - 2024 - Tadashi Enabling AI-Based Automated Code Generation With Guaranteed Correctness.pdf;/home/vatai/Sync/zotero-data/storage/V2PELCSE/2410.html}
}

GitHub Events

Total
  • Issues event: 60
  • Watch event: 18
  • Delete event: 36
  • Member event: 2
  • Issue comment event: 11
  • Push event: 731
  • Pull request event: 53
  • Create event: 37
Last Year
  • Issues event: 60
  • Watch event: 18
  • Delete event: 36
  • Member event: 2
  • Issue comment event: 11
  • Push event: 731
  • Pull request event: 53
  • Create event: 37

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 53
  • Total pull requests: 65
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 4 days
  • Total issue authors: 5
  • Total pull request authors: 1
  • Average comments per issue: 0.23
  • Average comments per pull request: 0.02
  • Merged pull requests: 52
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 37
  • Pull requests: 51
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 3 days
  • Issue authors: 4
  • Pull request authors: 1
  • Average comments per issue: 0.16
  • Average comments per pull request: 0.02
  • Merged pull requests: 39
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • vatai (46)
  • jespb (2)
  • YingHREN (2)
  • NielsRogge (1)
  • undertherain (1)
Pull Request Authors
  • vatai (70)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/tests.yaml actions
  • actions/checkout master composite
  • actions/setup-python v5 composite
  • threeal/cmake-action v1.3.0 composite
docs/requirements.txt pypi
  • sphinx-autodoc-typehints *
  • sphinx-rtd-theme *
pyproject.toml pypi
setup.py pypi