|
| 1 | +# TPU v6e |
| 2 | + |
| 3 | +Trillium (also refers to v6e) is Cloud TPU’s latest generation AI accelerator. SkyPilot support TPU v6e with provisioning, training and serving. |
| 4 | + |
| 5 | +## Catalogs |
| 6 | + |
| 7 | +Currently, for TPU v6e, the public APIs for regions and pricing is not released yet, and pricing info for `us-central1`, `us-central2`, `us-south1` is not available. We set the price to `0.0` in those regions for now. |
| 8 | + |
| 9 | +``` |
| 10 | +## Provisioning |
| 11 | +
|
| 12 | +To provision TPU v6e, use the following command: |
| 13 | +
|
| 14 | +```bash |
| 15 | +$ sky launch --gpus tpu-v6e-16 -c tpu-v6e |
| 16 | +``` |
| 17 | + |
| 18 | +After that, you can SSH to the instance and start developing your model: |
| 19 | + |
| 20 | +```bash |
| 21 | +$ ssh tpu-v6e |
| 22 | +``` |
| 23 | + |
| 24 | +## Training |
| 25 | + |
| 26 | +Examples in this directory (`train-llama3-8b.yaml`) shows how to use TPU v6e to train a Llama3 8b model, using PyTorch (XLA) on the wikitext dataset. To start the training, use the following command: |
| 27 | + |
| 28 | +```bash |
| 29 | +$ HF_TOKEN=hf_xxx sky launch train-llama3-8b.yaml -c train-llama3-8b --env HF_TOKEN |
| 30 | +``` |
| 31 | + |
| 32 | +### Single-Host Training |
| 33 | + |
| 34 | +The training throughput for a `tpu-v6e-8` instance should around 0.5 samples/s: |
| 35 | + |
| 36 | +```bash |
| 37 | +(task, pid=17499) ***** train metrics ***** |
| 38 | +(task, pid=17499) epoch = 1.1765 |
| 39 | +(task, pid=17499) total_flos = 109935420GF |
| 40 | +(task, pid=17499) train_loss = 10.6011 |
| 41 | +(task, pid=17499) train_runtime = 0:11:12.77 |
| 42 | +(task, pid=17499) train_samples = 282 |
| 43 | +(task, pid=17499) train_samples_per_second = 0.476 |
| 44 | +(task, pid=17499) train_steps_per_second = 0.03 |
| 45 | +INFO: Job finished (status: SUCCEEDED). |
| 46 | +``` |
| 47 | + |
| 48 | +### Multi-Host Training |
| 49 | + |
| 50 | +By changing the TPU type to `tpu-v6e-16` and the `--per_device_train_batch_size` to `32`, the training throughput increased to around 1 samples/s: |
| 51 | + |
| 52 | +```bash |
| 53 | +(head, rank=0, pid=17894) ***** train metrics ***** |
| 54 | +(head, rank=0, pid=17894) epoch = 2.5 |
| 55 | +(head, rank=0, pid=17894) total_flos = 219870840GF |
| 56 | +(head, rank=0, pid=17894) train_loss = 10.1527 |
| 57 | +(head, rank=0, pid=17894) train_runtime = 0:11:13.18 |
| 58 | +(head, rank=0, pid=17894) train_samples = 282 |
| 59 | +(head, rank=0, pid=17894) train_samples_per_second = 0.951 |
| 60 | +(head, rank=0, pid=17894) train_steps_per_second = 0.03 |
| 61 | + |
| 62 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) ***** train metrics ***** |
| 63 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) epoch = 2.5 |
| 64 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) total_flos = 219870840GF |
| 65 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) train_loss = 10.1527 |
| 66 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) train_runtime = 0:11:15.08 |
| 67 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) train_samples = 282 |
| 68 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) train_samples_per_second = 0.948 |
| 69 | +(worker1, rank=1, pid=15406, ip=10.164.0.57) train_steps_per_second = 0.03 |
| 70 | + |
| 71 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) ***** train metrics ***** |
| 72 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) epoch = 2.5 |
| 73 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) total_flos = 219870840GF |
| 74 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) train_loss = 10.1527 |
| 75 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) train_runtime = 0:11:15.61 |
| 76 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) train_samples = 282 |
| 77 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) train_samples_per_second = 0.947 |
| 78 | +(worker2, rank=2, pid=16552, ip=10.164.0.58) train_steps_per_second = 0.03 |
| 79 | + |
| 80 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) ***** train metrics ***** |
| 81 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) epoch = 2.5 |
| 82 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) total_flos = 219870840GF |
| 83 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) train_loss = 10.1527 |
| 84 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) train_runtime = 0:11:15.10 |
| 85 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) train_samples = 282 |
| 86 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) train_samples_per_second = 0.948 |
| 87 | +(worker3, rank=3, pid=17469, ip=10.164.0.59) train_steps_per_second = 0.03 |
| 88 | + |
| 89 | +INFO: Job finished (status: SUCCEEDED). |
| 90 | +``` |
| 91 | + |
| 92 | +# Serving |
| 93 | + |
| 94 | +TPU v6e also supports serving. Examples in this directory (`serve-llama2-7b.yaml`) shows how to use TPU v6e to serve a Llama2 7b model, using PyTorch (XLA) and the JetStream lib. To start the serving, use the following command: |
| 95 | + |
| 96 | +```bash |
| 97 | +$ HF_TOKEN=hf_xxx sky launch serve-llama2-7b.yaml -c serve-llama2-7b --env HF_TOKEN |
| 98 | +``` |
| 99 | + |
| 100 | +After the server is ready, you should see the following message: |
| 101 | + |
| 102 | +```bash |
| 103 | +(task, pid=26431) 2024-09-24 19:58:15,160 - root - INFO - Starting server on port 9000 with 64 threads |
| 104 | +(task, pid=26431) I0924 19:58:15.160293 140454572087296 server_lib.py:155] Starting server on port 9000 with 64 threads |
| 105 | +(task, pid=26431) 2024-09-24 19:58:15,161 - root - INFO - Not starting JAX profiler server: False |
| 106 | +(task, pid=26431) I0924 19:58:15.161907 140454572087296 server_lib.py:164] Not starting JAX profiler server: False |
| 107 | +(task, pid=26431) Started jetstream_server.... |
| 108 | +``` |
| 109 | + |
| 110 | +You can now start a benchmark to test the serving performance: |
| 111 | + |
| 112 | +```bash |
| 113 | +$ sky exec serve-llama2-7b benchmark-llama2-7b.yaml |
| 114 | +... (emitted logs) |
| 115 | +(task, pid=25491) Successful requests: 100 |
| 116 | +(task, pid=25491) Benchmark duration: 8.753792 s |
| 117 | +(task, pid=25491) Total input tokens: 21888 |
| 118 | +(task, pid=25491) Total generated tokens: 18803 |
| 119 | +(task, pid=25491) Request throughput: 11.42 requests/s |
| 120 | +(task, pid=25491) Input token throughput: 2500.40 tokens/s |
| 121 | +(task, pid=25491) Output token throughput: 2147.98 tokens/s |
| 122 | +(task, pid=25491) Mean TTFT: 1981.93 ms |
| 123 | +(task, pid=25491) Median TTFT: 1829.33 ms |
| 124 | +(task, pid=25491) P99 TTFT: 4511.95 ms |
| 125 | +(task, pid=25491) Mean TPOT: 130.71 ms |
| 126 | +(task, pid=25491) Median TPOT: 18.88 ms |
| 127 | +(task, pid=25491) P99 TPOT: 2487.37 ms |
| 128 | +``` |
0 commit comments