Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pallas TPU] Add a note in the Pallas Quickstart documentation about the instructions of running the existing example on TPU #23889

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/pallas/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,35 @@
"On TPUs, programs are executed in a combination of parallel and sequential\n",
"(depending on the architecture) so there are slightly different considerations.\n",
"\n",
"To call the above kernel on TPU, run:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "796f928c",
"metadata": {},
"outputs": [],
"source": [
"from jax.experimental.pallas import tpu as pltpu\n",
"\n",
"def iota(size: int):\n",
" return pl.pallas_call(iota_kernel,\n",
" out_specs=pl.BlockSpec(memory_space=pltpu.TPUMemorySpace.SMEM),\n",
" out_shape=jax.ShapeDtypeStruct((size,), jnp.int32),\n",
" grid=(size,))()\n",
"iota(8)"
]
},
{
"cell_type": "markdown",
"id": "68f97b4e",
"metadata": {},
"source": [
"TPUs distinguish between vector and scalar memory spaces and in this case the\n",
"output must be placed in scalar memory (`TPUMemorySpace.SMEM`) since `i` is\n",
"a scalar. For more details read {ref}`pallas_tpu_pipelining`.\n",
"\n",
"You can read more details at {ref}`pallas_grid`."
]
},
Expand Down
17 changes: 17 additions & 0 deletions docs/pallas/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ operations like matrix multiplications really quickly.
On TPUs, programs are executed in a combination of parallel and sequential
(depending on the architecture) so there are slightly different considerations.

To call the above kernel on TPU, run:

```{code-cell} ipython3
from jax.experimental.pallas import tpu as pltpu

def iota(size: int):
return pl.pallas_call(iota_kernel,
out_specs=pl.BlockSpec(memory_space=pltpu.TPUMemorySpace.SMEM),
out_shape=jax.ShapeDtypeStruct((size,), jnp.int32),
grid=(size,))()
iota(8)
```

TPUs distinguish between vector and scalar memory spaces and in this case the
output must be placed in scalar memory (`TPUMemorySpace.SMEM`) since `i` is
a scalar. For more details read {ref}`pallas_tpu_pipelining`.

You can read more details at {ref}`pallas_grid`.

+++
Expand Down
8 changes: 8 additions & 0 deletions docs/pallas/tpu/pipelining.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7704d3bb",
"metadata": {},
"source": [
"(pallas_tpu_pipelining)="
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
2 changes: 2 additions & 0 deletions docs/pallas/tpu/pipelining.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ kernelspec:
name: python3
---

(pallas_tpu_pipelining)=

+++ {"id": "teoJ_fUwlu0l"}

# Pipelining
Expand Down