Getting Started¶
TGLite currently only support PyTorch as backend.
Installation with pip¶
Prerequisites¶
python |
gcc |
torch |
torch-scatter |
≥ 3.7 |
≥ 6.1 |
≥ 1.12.1 |
≥ 2.1.0 |
Installation¶
Ensure at least PyTorch 1.12.1 and torch-scatter 2.1.0 are installed (refer to PyTorch and torch-scatter for installation instructions), simply run
$ pip install tglite
Verification¶
To verify the installation, run the following in Python:
import tglite
print(tglite.__version__)
Note
Currently, the library is only tested on Linux. MacOS and Windows support is not guaranteed.
Building from source¶
To install the latest TGLite code for testing or development on the core, you will need to build TGlite from source. Here, we show how to build TGLite with Python 3.7, PyTorch 1.12.1 and torch-scatter 2.1.0.
Create and activate a python environment:
$ conda create -n tglite python=3.7
$ conda activate tglite
Install dependencies that have CUDA versions:
$ pip install torch==1.12.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116
$ pip install torch-scatter==2.1.0+pt112cu116 -f https://data.pyg.org/whl/torch-1.12.1+cu116.html
Get the TGLite source:
$ git clone https://github.com/ADAPT-uiuc/tglite.git
$ cd tglite
Then install the package locally:
$ python setup.py install
This will build the C++ extension (which requires C++14 and OpenMP), install the rest of the dependencies (as listed in pyproject.toml), and then install the tglite package.
Development Mode¶
Development mode allows easily editing the code without having to re-install the package. However, this only applies to the python code. When editing the C++ extension code, it needs to be re-compiled again. Use develop instead of install to use dev mode:
$ python setup.py develop
Running Tests¶
Unit tests are located in tests directory. First, install the testing dependencies specified in pyproject.toml. Doing so might overwrite the dev mode install, so you might need to re-enable dev mode. Then, exercise the tests using the pytest utility.
# install test dependencies
$ pip install '.[test]'
# re-enable dev mode install
$ pip uninstall -y tglite
$ python setup.py develop
# run with test coverage report
$ pytest --cov=tglite
Running Examples¶
Inside the examples directory of the repository, several CTDG models have been implemented using tglite. To run these example models, install the additional dependencies and download the datasets:
$ cd examples
$ pip install -r requirements.txt # or "conda install -c conda-forge pandas scikit-learn" using conda
$ ./download-data.sh
$ python gen-data-files.py --data wiki-talk
This will download the datasets inside examples/data/, one can also download data to other places.
Use the scripts in examples/exp as a starting point, e.g.:
$ ./exp/tgat.sh --data-path . -d wiki --epochs 3
Building this document locally¶
# install doc dependencies
$ pip install '.[docs]'
# build docs
$ cd docs
$ make html
# launch in browser
$ sh run.sh