Improve JAX for pretraining notebook. - #293
Conversation
|
Hi @f33ac thanks for the PR -- I was going to start reviewing it but it looks like the file size is now 41 MB when it used to be 110 kb, do you know why that is and could you mitigate it? |
emilyfertig
left a comment
There was a problem hiding this comment.
Thanks, overall I think this looks great! I left some comments (I might take another pass later), but in general I think your additions tie it all together really nicely.
A couple high-level things:
- Some of the cells are tagged
nbval-skipornbval-ignore-output. Some of these tags got deleted, so we'll need to reinstate them so the presubmits pass (some of the cells you added might need these tags too, if they're too long-running for the tests or the cell output is different on the CPU test runners e.g.) - The sphinx build is failing and I'm not sure why: https://app.readthedocs.org/api/v2/build/31206675.txt It looks like this might be the relevant line:
/home/docs/checkouts/readthedocs.org/user_builds/jax-ai-stack/checkouts/293/docs/source/JAX_for_LLM_pretraining.ipynb:650002: WARNING: skipping unknown output mime type: application/vnd.google.colaboratory.intrinsic+json [mystnb.unknown_mime_type] [mystnb.unknown_mime_type]
If you could take a look, that would be great.
| "\n", | ||
| "By the end of this tutorial, you will be able to:\n", | ||
| "\n", | ||
| "- **Understand JAX's parallelism capabilities**: Learn how to leverage data and tensor parallelism to distribute training across multiple TPU devices\n", |
There was a problem hiding this comment.
say "TPU or GPU" to emphasize JAX is multi-platform
| }, | ||
| "outputs": [], | ||
| "outputs": [ |
| "tags": [ | ||
| "nbval-ignore-output" | ||
| ] | ||
| "outputId": "29c2e1dc-e49c-484a-96db-3b6c0df901a5" |
There was a problem hiding this comment.
We probably want to keep the nbval-ignore-output tags. The notebook integration tests compare the output of the run cell with the saved output and error if they're different, and the tag bypasses the error.
There was a problem hiding this comment.
Also, could you clear the outputs of this cell?
| "outputs": [], | ||
| "source": [ | ||
| "# Verify that an accelerator (GPU/TPU) is available\n", | ||
| "# This tutorial requires hardware acceleration and cannot run on CPU\n", |
There was a problem hiding this comment.
Is there a reason not to allow it to be run on CPU, besides that it's slow? I'm wondering if this should be a warning instead.
| "- **Automatic parallelization**: JAX can automatically distribute computations across multiple devices using SPMD (Single Program, Multiple Data) parallelism\n", | ||
| "- **Functional programming**: JAX encourages pure functions, which enables reliable transformations and better performance\n", | ||
| "\n", | ||
| "For training large language models like our miniGPT, JAX's automatic parallelization capabilities are particularly valuable. They allow us to efficiently utilize multiple TPU cores without manually managing device placement and communication." |
There was a problem hiding this comment.
Let's mention GPUs here too, again to emphasize multi-platform capabilities and not imply we're TPU-only
| "metadata": { | ||
| "id": "Mtzb0NXb8TVY", | ||
| "tags": [ | ||
| "nbval-ignore-output" |
There was a problem hiding this comment.
Reinstate nbval-ignore-output?
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m242.4/242.4 kB\u001b[0m \u001b[31m24.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m221.6/221.6 kB\u001b[0m \u001b[31m22.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m377.3/377.3 kB\u001b[0m \u001b[31m32.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.4/21.4 MB\u001b[0m \u001b[31m104.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", |
There was a problem hiding this comment.
I don't think we need tensorflow anymore -- could you take a look at https://docs.jax.dev/en/latest/profiling.html and check that this is up to date?
There was a problem hiding this comment.
Hey! According to my colleague, using Perfetto here is not really feasible.
It's blocking execution, analizing single trace rather than a batch as would be the case in training (multiple training steps executions).
We can dive deeper into that if you think it's really important for this tutorial.
emilyfertig
left a comment
There was a problem hiding this comment.
Hi @f33ac could you please sign the Contributor License Agreement? (See the link in the cla/google presubmit). Thanks!
| ] | ||
| }, | ||
| { | ||
| "data": { | ||
| "application/vnd.google.colaboratory.intrinsic+json": { |
There was a problem hiding this comment.
Could you delete these three lines? (2543-2545) That should fix the readthedocs build.
|
Hey @emilyfertig! |
Description
This PR extends the notebook by replacing all placeholder "REVAMP" sections with actual content. The notebook ready for review initial review.
Note:
The vLLM section was intentionally not fully implemented, as running it inside the notebook would require more code and some hacky setup. Instead, it is briefly mentioned with guidance.
Changes
Testing
T4 GPU&v5e-1 TPUon Google Colab with no issues.