{ "cells": [ { "cell_type": "code", "execution_count": 32, "id": "578786b8-092a-4de8-9955-4e87da557639", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: peft in /opt/conda/lib/python3.10/site-packages (0.11.1)\n", "Requirement already satisfied: numpy>=1.17 in /opt/conda/lib/python3.10/site-packages (from peft) (1.26.3)\n", "Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.10/site-packages (from peft) (23.1)\n", "Requirement already satisfied: psutil in /opt/conda/lib/python3.10/site-packages (from peft) (5.9.0)\n", "Requirement already satisfied: pyyaml in /opt/conda/lib/python3.10/site-packages (from peft) (6.0.1)\n", "Requirement already satisfied: torch>=1.13.0 in /opt/conda/lib/python3.10/site-packages (from peft) (2.2.0)\n", "Requirement already satisfied: transformers in /opt/conda/lib/python3.10/site-packages (from peft) (4.42.3)\n", "Requirement already satisfied: tqdm in /opt/conda/lib/python3.10/site-packages (from peft) (4.66.4)\n", "Requirement already satisfied: accelerate>=0.21.0 in /opt/conda/lib/python3.10/site-packages (from peft) (0.32.0)\n", "Requirement already satisfied: safetensors in /opt/conda/lib/python3.10/site-packages (from peft) (0.4.3)\n", "Requirement already satisfied: huggingface-hub>=0.17.0 in /opt/conda/lib/python3.10/site-packages (from peft) (0.23.4)\n", "Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.17.0->peft) (3.13.1)\n", "Requirement already satisfied: fsspec>=2023.5.0 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.17.0->peft) (2023.12.2)\n", "Requirement already satisfied: requests in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.17.0->peft) (2.32.3)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.17.0->peft) (4.9.0)\n", "Requirement already satisfied: sympy in /opt/conda/lib/python3.10/site-packages (from torch>=1.13.0->peft) (1.12)\n", "Requirement already satisfied: networkx in /opt/conda/lib/python3.10/site-packages (from torch>=1.13.0->peft) (3.1)\n", "Requirement already satisfied: jinja2 in /opt/conda/lib/python3.10/site-packages (from torch>=1.13.0->peft) (3.1.2)\n", "Requirement already satisfied: regex!=2019.12.17 in /opt/conda/lib/python3.10/site-packages (from transformers->peft) (2024.5.15)\n", "Requirement already satisfied: tokenizers<0.20,>=0.19 in /opt/conda/lib/python3.10/site-packages (from transformers->peft) (0.19.1)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from jinja2->torch>=1.13.0->peft) (2.1.3)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.17.0->peft) (2.0.4)\n", "Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.17.0->peft) (3.4)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.17.0->peft) (1.26.18)\n", "Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.17.0->peft) (2023.11.17)\n", "Requirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.10/site-packages (from sympy->torch>=1.13.0->peft) (1.3.0)\n", "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n", "\u001b[0m" ] } ], "source": [ "#!pip install huggingface_hub torch transformers datasets trl \n", "#!pip install flash-attn --no-build-isolation\n", "!pip install --upgrade peft" ] }, { "cell_type": "code", "execution_count": 35, "id": "4a74bec4-4bf0-47be-802a-046073da573e", "metadata": {}, "outputs": [], "source": [ "import sys\n", "import logging\n", "\n", "import datasets\n", "from datasets import load_dataset\n", "from peft import LoraConfig\n", "import torch\n", "import torch.nn as nn\n", "import transformers\n", "from trl import SFTTrainer, SFTConfig\n", "from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, BitsAndBytesConfig" ] }, { "cell_type": "code", "execution_count": 2, "id": "d2e94000-8097-4f09-a8dc-506801bb9f12", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8c9a7b9e2bb5463c979a2659118c4912", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='
3\u001b[0m \u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexp\u001b[49m\u001b[43m(\u001b[49m\u001b[43mloss\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcats\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparis\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mitem\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[0;31mTypeError\u001b[0m: loop of ufunc does not support argument 0 of type builtin_function_or_method which has no callable exp method" ] } ], "source": [ "import numpy as np\n", "\n", "np.exp(loss(cats, paris).item)" ] }, { "cell_type": "code", "execution_count": 68, "id": "d440d74d-2b5d-48e0-ad86-f355a25a6c16", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "tensor([ 274, 1446, 526, 451, 278, 871, 15006, 393, 508, 367,\n", " 15201, 491, 445, 4195, 29889, 360, 12099, 29892, 27127, 1169,\n", " 29892, 322, 1584, 17952, 508, 884, 8812, 515, 445, 17135,\n", " 29889, 13, 13, 1576, 25828, 4835, 310, 285, 5570, 454,\n", " 2679, 29747, 24424, 297, 20309, 508, 13100, 8679, 373, 278,\n", " 7408, 310, 278, 17135, 29889, 512, 278, 4688, 22950, 29892,\n", " 274, 1446, 1122, 1510, 694, 18906, 310, 4486, 2264, 29889,\n", " 2398, 29892, 408, 278, 17135, 6728, 267, 29892, 896, 1122,\n", " 4953, 454, 386, 1191, 293, 29892, 14074, 1009, 623, 300,\n", " 568, 29892, 322, 2693, 2381, 324, 2435, 301, 962, 561],\n", " device='cuda:0')" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output[0]" ] }, { "cell_type": "code", "execution_count": 75, "id": "8f557898-32bb-4cc9-b9de-cb80bb4ee21e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "tensor([4, 3, 0])" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = torch.tensor([123], dtype=torch.long)\n", "\n", "#loss(x,x)\n", "\n", "input = torch.randn(3, 5, requires_grad=True)\n", "target = torch.empty(3, dtype=torch.long).random_(5)\n", "\n", "target" ] }, { "cell_type": "code", "execution_count": 59, "id": "139e9973-003a-484f-95f8-42428dd436f5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cats are not the only animals that can be affected by this condition. Dogs, rabbits, and even birds can also suffer from this disease.\n", "\n", "The symptoms of feline leukemia virus infection can vary depending on the stage of the disease. In the early stages, cats may show no signs of illness. However, as the disease progresses, they may become lethargic, lose their appetite, and develop swollen lymph\n" ] } ], "source": [ "generated_text = tokenizer.decode(output[0], skip_special_tokens=True)\n", "\n", "print(generated_text)" ] }, { "cell_type": "code", "execution_count": 54, "id": "cda57a53-98f7-45eb-84c1-9ef8360926a4", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Attempting to cast a BatchEncoding to type torch.float16. This is not supported.\n", "Attempting to cast a BatchEncoding to type torch.float16. This is not supported.\n" ] }, { "ename": "RuntimeError", "evalue": "Expected floating point type for target with class probabilities, got Long", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[54], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m i \u001b[38;5;241m=\u001b[39m tokenizer(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHello\u001b[39m\u001b[38;5;124m\"\u001b[39m, return_tensors\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpt\u001b[39m\u001b[38;5;124m'\u001b[39m)\u001b[38;5;241m.\u001b[39mto(torch\u001b[38;5;241m.\u001b[39mfloat16)\n\u001b[1;32m 4\u001b[0m lab \u001b[38;5;241m=\u001b[39m tokenizer(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHella\u001b[39m\u001b[38;5;124m\"\u001b[39m, return_tensors\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpt\u001b[39m\u001b[38;5;124m'\u001b[39m)\u001b[38;5;241m.\u001b[39mto(torch\u001b[38;5;241m.\u001b[39mfloat16)\n\u001b[0;32m----> 6\u001b[0m \u001b[43mloss\u001b[49m\u001b[43m(\u001b[49m\u001b[43mgenerate_out\u001b[49m\u001b[43m(\u001b[49m\u001b[43mi\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m10\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mgenerate_out\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlab\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m10\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py:1511\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[1;32m 1510\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1511\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py:1520\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1515\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1516\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1517\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[1;32m 1518\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1519\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1520\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1522\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1523\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n", "File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/torch/nn/modules/loss.py:1179\u001b[0m, in \u001b[0;36mCrossEntropyLoss.forward\u001b[0;34m(self, input, target)\u001b[0m\n\u001b[1;32m 1178\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m: Tensor, target: Tensor) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tensor:\n\u001b[0;32m-> 1179\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mF\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcross_entropy\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtarget\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweight\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mweight\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1180\u001b[0m \u001b[43m \u001b[49m\u001b[43mignore_index\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mignore_index\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreduction\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreduction\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1181\u001b[0m \u001b[43m \u001b[49m\u001b[43mlabel_smoothing\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlabel_smoothing\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/torch/nn/functional.py:3059\u001b[0m, in \u001b[0;36mcross_entropy\u001b[0;34m(input, target, weight, size_average, ignore_index, reduce, reduction, label_smoothing)\u001b[0m\n\u001b[1;32m 3057\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m size_average \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mor\u001b[39;00m reduce \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 3058\u001b[0m reduction \u001b[38;5;241m=\u001b[39m _Reduction\u001b[38;5;241m.\u001b[39mlegacy_get_string(size_average, reduce)\n\u001b[0;32m-> 3059\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtorch\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_C\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_nn\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcross_entropy_loss\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtarget\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweight\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m_Reduction\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_enum\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreduction\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mignore_index\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlabel_smoothing\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[0;31mRuntimeError\u001b[0m: Expected floating point type for target with class probabilities, got Long" ] } ], "source": [ "loss = nn.CrossEntropyLoss()\n", "\n", "i = tokenizer(\"Hello\", return_tensors='pt').to(torch.float16)\n", "lab = tokenizer(\"Hella\", return_tensors='pt').to(torch.float16\n", "\n", "loss(generate_out(i,len=10), generate_out(lab,len=10))\n", "\n", "#loss(i, lab)\n", "\n", " " ] }, { "cell_type": "markdown", "id": "f99adf3c-aefb-4c22-a8b1-e8f79ef0b9d8", "metadata": {}, "source": [ "### Test perplexity using MMLU" ] }, { "cell_type": "code", "execution_count": null, "id": "287155f7-6808-4419-9b12-8756e1746e28", "metadata": {}, "outputs": [], "source": [ "prompt = \"When a diver points a flashlight upward toward the surface of the water at an angle 20° from the normal, the beam of light\"\n", "subject = \"conceptual_physics\"\n", "answer = \"passes into the air above\"\n", "\n", "input_text = []\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "7bdb1138-7da5-44dc-9549-df7d40ec68e1", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2024-07-04:16:55:06,590 INFO [__main__.py:272] Verbosity set to INFO\n", "2024-07-04:16:55:11,201 INFO [__main__.py:369] Selected Tasks: ['hellaswag']\n", "2024-07-04:16:55:11,202 INFO [evaluator.py:152] Setting random seed to 0 | Setting numpy seed to 1234 | Setting torch manual seed to 1234\n", "2024-07-04:16:55:11,202 INFO [evaluator.py:189] Initializing hf model, with arguments: {'pretrained': 'EleutherAI/gpt-j-6B'}\n", "2024-07-04:16:55:11,241 INFO [huggingface.py:170] Using device 'cuda:0'\n", "Downloading builder script: 100%|██████████| 4.36k/4.36k [00:00<00:00, 19.3MB/s]\n", "Downloading metadata: 100%|████████████████| 2.53k/2.53k [00:00<00:00, 17.6MB/s]\n", "Downloading readme: 100%|██████████████████| 6.84k/6.84k [00:00<00:00, 24.9MB/s]\n", "Downloading data: 47.5MB [00:00, 137MB/s] \n", "Downloading data: 11.8MB [00:00, 92.0MB/s] \n", "Downloading data: 12.2MB [00:00, 93.1MB/s] \n", "Generating train split: 100%|███| 39905/39905 [00:02<00:00, 17573.67 examples/s]\n", "Generating test split: 100%|████| 10003/10003 [00:00<00:00, 17738.73 examples/s]\n", "Generating validation split: 100%|█| 10042/10042 [00:00<00:00, 17489.21 examples\n", "Map: 100%|██████████████████████| 39905/39905 [00:03<00:00, 10310.72 examples/s]\n", "Map: 100%|███████████████████████| 10042/10042 [00:01<00:00, 9523.34 examples/s]\n", "2024-07-04:16:56:20,566 INFO [evaluator.py:261] Setting fewshot random generator seed to 1234\n", "2024-07-04:16:56:20,567 INFO [task.py:411] Building contexts for hellaswag on rank 0...\n", "100%|███████████████████████████████████| 10042/10042 [00:02<00:00, 3806.50it/s]\n", "2024-07-04:16:56:23,924 INFO [evaluator.py:438] Running loglikelihood requests\n", "Running loglikelihood requests: 0%| | 0/40168 [00:00\n", " sys.exit(cli_evaluate())\n", " File \"/lm-evaluation-harness/lm_eval/__main__.py\", line 375, in cli_evaluate\n", " results = evaluator.simple_evaluate(\n", " File \"/lm-evaluation-harness/lm_eval/utils.py\", line 395, in _wrapper\n", " return fn(*args, **kwargs)\n", " File \"/lm-evaluation-harness/lm_eval/evaluator.py\", line 277, in simple_evaluate\n", " results = evaluate(\n", " File \"/lm-evaluation-harness/lm_eval/utils.py\", line 395, in _wrapper\n", " return fn(*args, **kwargs)\n", " File \"/lm-evaluation-harness/lm_eval/evaluator.py\", line 449, in evaluate\n", " resps = getattr(lm, reqtype)(cloned_reqs)\n", " File \"/lm-evaluation-harness/lm_eval/api/model.py\", line 371, in loglikelihood\n", " return self._loglikelihood_tokens(new_reqs, disable_tqdm=disable_tqdm)\n", " File \"/lm-evaluation-harness/lm_eval/models/huggingface.py\", line 1086, in _loglikelihood_tokens\n", " self._model_call(batched_inps, **call_kwargs), dim=-1\n", " File \"/lm-evaluation-harness/lm_eval/models/huggingface.py\", line 801, in _model_call\n", " return self.model(inps).logits\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", " return self._call_impl(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", " return forward_call(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/transformers/models/gptj/modeling_gptj.py\", line 1124, in forward\n", " transformer_outputs = self.transformer(\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", " return self._call_impl(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", " return forward_call(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/transformers/models/gptj/modeling_gptj.py\", line 950, in forward\n", " outputs = block(\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", " return self._call_impl(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", " return forward_call(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/transformers/models/gptj/modeling_gptj.py\", line 590, in forward\n", " feed_forward_hidden_states = self.mlp(hidden_states)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", " return self._call_impl(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", " return forward_call(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/transformers/models/gptj/modeling_gptj.py\", line 552, in forward\n", " hidden_states = self.act(hidden_states)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", " return self._call_impl(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", " return forward_call(*args, **kwargs)\n", " File \"/opt/conda/lib/python3.10/site-packages/transformers/activations.py\", line 56, in forward\n", " return 0.5 * input * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (input + 0.044715 * torch.pow(input, 3.0))))\n", "torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 76.00 MiB. GPU 0 has a total capacity of 23.65 GiB of which 27.81 MiB is free. Process 1711577 has 23.62 GiB memory in use. Of the allocated memory 23.07 GiB is allocated by PyTorch, and 103.80 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)\n", "Running loglikelihood requests: 0%| | 0/40168 [00:00