Resolving dependency issues

Author: rinapchCreated Jan 7, 2023Updated Dec 11, 2024

There has been a number of issues regarding different version conflicts and how to fix them. I've spent some time trying to make this code run, so maybe this instruction will spare someone else their efforts :)

First of all, as per this issue in jax repo https://github.com/google/jax/issues/13321, TPU VMs no longer work with jax older than 0.2.16. This repo requires jax==0.2.12. I found out that the code still works with jax versions 0.2.18 and 0.2.20

Additionally, since there are a number of dependecies in the requirements file that do not state the needed versions, I rolled back all of them to the lastest versions per January 2022 and used poetry to resolve conflics. Here is the pyproject.toml file in the end:

python = "^3.8" numpy = ">=1.19.5,<1.20.0" tqdm = ">=4.45.0,<4.46.0" wandb = "^0.13.7" einops = ">=0.3.0,<0.4.0" requests = ">=2.25.1,<2.26.0" fabric = ">=2.6.0,<2.7.0" optax = "0.0.9" dm-haiku = "0.0.5" ray = {version = "1.4.1", extras = ["default"]} jax = "0.2.18" cloudpickle = ">=1.3.0,<1.4.0" tensorflow-cpu = ">=2.6.0,<2.7.0" google-cloud-storage = ">=1.36.2,<1.37.0" transformers = ">=4.16.2,<4.17.0" smart-open = {version = ">=5.2.1,<5.3.0", extras = ["gcs"]} ftfy = ">=6.1,<7.0" lm-dataformat = "^0.0.20" pathy = "^0.10.1" func-timeout = "^4.3.5" chex = "0.0.5"

After installing all of this with poetry, install jax[tpu] with pip, so that it gets the right libtpu nightly build (pip install "jax[tpu]==0.2.18" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html)

When starting training you also can experience training being stuck at validation. As was suggested by @versae in this issue https://github.com/kingoflolz/mesh-transformer-jax/issues/218, it helps to change TPU runtime version to an alpha build. Something like gcloud alpha compute tpus tpu-vm create gptj --accelerator-type v3-8 --version v2-alpha

Source: kingoflolz/mesh-transformer-jax