瀏覽代碼

Make quickstart finetuning notebook ready for T4 (#562)

Hamid Shojanazeri 10 月之前
父節點
當前提交
742f24abc9
共有 1 個文件被更改,包括 11 次插入4 次删除
  1. 11 4
      recipes/finetuning/quickstart_peft_finetuning.ipynb

+ 11 - 4
recipes/finetuning/quickstart_peft_finetuning.ipynb

@@ -6,7 +6,9 @@
    "metadata": {},
    "source": [
     "Copyright (c) Meta Platforms, Inc. and affiliates.\n",
-    "This software may be used and distributed according to the terms of the Llama 2 Community License Agreement."
+    "This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.\n",
+    "\n",
+    "<a href=\"https://colab.research.google.com/github/meta-llama/llama-recipes/blob/main/recipes/finetuning/quickstart_peft_finetuning.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
    ]
   },
   {
@@ -16,7 +18,11 @@
    "source": [
     "## PEFT Finetuning Quick Start Notebook\n",
     "\n",
-    "This notebook shows how to train a Meta Llama 3 model on a single GPU (e.g. A10 with 24GB) using int8 quantization and LoRA."
+    "This notebook shows how to train a Meta Llama 3 model on a single GPU (e.g. A10 with 24GB) using int8 quantization and LoRA finetuning.\n",
+    "\n",
+    "**_Note:_** To run this notebook on a machine with less than 24GB VRAM (e.g. T4 with 16GB) the context length of the training dataset needs to be adapted.\n",
+    "We do this based on the available VRAM during execution.\n",
+    "If you run into OOM issues try to further lower the value of train_config.context_length."
    ]
   },
   {
@@ -34,6 +40,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
+    "# uncomment if running from Colab T4\n",
     "# ! pip install llama-recipes ipywidgets\n",
     "\n",
     "# import huggingface_hub\n",
@@ -91,7 +98,7 @@
     "train_config.lr = 3e-4\n",
     "train_config.use_fast_kernels = True\n",
     "train_config.use_fp16 = True\n",
-    "train_config.context_length = 2048\n",
+    "train_config.context_length = 1024 if torch.cuda.get_device_properties(0).total_memory < 16e9 else 2048 # T4 16GB or A10 24GB\n",
     "train_config.batching_strategy = \"packing\"\n",
     "train_config.output_dir = \"meta-llama-samsum\"\n",
     "\n",
@@ -460,7 +467,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.11.9"
+   "version": "3.10.14"
   },
   "vscode": {
    "interpreter": {