|
65 | 65 | {
|
66 | 66 | "data": {
|
67 | 67 | "application/vnd.jupyter.widget-view+json": {
|
68 |
| - "model_id": "c7963d43806d432aaa3d00e2055e355c", |
| 68 | + "model_id": "68838a4f42f84545912e95b339a31034", |
69 | 69 | "version_major": 2,
|
70 | 70 | "version_minor": 0
|
71 | 71 | },
|
|
75 | 75 | },
|
76 | 76 | "metadata": {},
|
77 | 77 | "output_type": "display_data"
|
78 |
| - }, |
79 |
| - { |
80 |
| - "name": "stderr", |
81 |
| - "output_type": "stream", |
82 |
| - "text": [ |
83 |
| - "Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n" |
84 |
| - ] |
85 | 78 | }
|
86 | 79 | ],
|
87 | 80 | "source": [
|
|
101 | 94 | "train_config.context_length = 1024 if torch.cuda.get_device_properties(0).total_memory < 16e9 else 2048 # T4 16GB or A10 24GB\n",
|
102 | 95 | "train_config.batching_strategy = \"packing\"\n",
|
103 | 96 | "train_config.output_dir = \"meta-llama-samsum\"\n",
|
| 97 | + "train_config.use_peft = True\n", |
104 | 98 | "\n",
|
105 | 99 | "from transformers import BitsAndBytesConfig\n",
|
106 | 100 | "config = BitsAndBytesConfig(\n",
|
|
205 | 199 | "model_input = tokenizer(eval_prompt, return_tensors=\"pt\").to(\"cuda\")\n",
|
206 | 200 | "\n",
|
207 | 201 | "model.eval()\n",
|
208 |
| - "with torch.no_grad():\n", |
| 202 | + "with torch.inference_mode():\n", |
209 | 203 | " print(tokenizer.decode(model.generate(**model_input, max_new_tokens=100)[0], skip_special_tokens=True))"
|
210 | 204 | ]
|
211 | 205 | },
|
|
230 | 224 | "name": "stderr",
|
231 | 225 | "output_type": "stream",
|
232 | 226 | "text": [
|
233 |
| - "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/datasets/load.py:1486: FutureWarning: The repository for samsum contains custom code which must be executed to correctly load the dataset. You can inspect the repository content at https://hf.co/datasets/samsum\n", |
234 |
| - "You can avoid this message in future by passing the argument `trust_remote_code=True`.\n", |
235 |
| - "Passing `trust_remote_code=True` will be mandatory to load this dataset from the next major release of `datasets`.\n", |
236 |
| - " warnings.warn(\n", |
237 |
| - "Preprocessing dataset: 100%|██████████| 14732/14732 [00:02<00:00, 6124.69it/s]\n" |
| 227 | + "/home/ubuntu/llama-recipes/src/llama_recipes/model_checkpointing/checkpoint_handler.py:17: DeprecationWarning: `torch.distributed._shard.checkpoint` will be deprecated, use `torch.distributed.checkpoint` instead\n", |
| 228 | + " from torch.distributed._shard.checkpoint import (\n", |
| 229 | + "Preprocessing dataset: 100%|██████████| 14732/14732 [00:02<00:00, 5872.02it/s]\n" |
238 | 230 | ]
|
239 | 231 | }
|
240 | 232 | ],
|
241 | 233 | "source": [
|
242 | 234 | "from llama_recipes.configs.datasets import samsum_dataset\n",
|
243 |
| - "from llama_recipes.data.concatenator import ConcatDataset\n", |
244 |
| - "from llama_recipes.utils.config_utils import get_dataloader_kwargs\n", |
245 |
| - "from llama_recipes.utils.dataset_utils import get_preprocessed_dataset\n", |
246 |
| - "\n", |
247 |
| - "train_dataset = get_preprocessed_dataset(tokenizer, samsum_dataset, 'train')\n", |
248 |
| - "\n", |
249 |
| - "train_dl_kwargs = get_dataloader_kwargs(train_config, train_dataset, tokenizer, \"train\")\n", |
| 235 | + "from llama_recipes.utils.dataset_utils import get_dataloader\n", |
250 | 236 | "\n",
|
251 |
| - "if train_config.batching_strategy == \"packing\":\n", |
252 |
| - " train_dataset = ConcatDataset(train_dataset, chunk_size=train_config.context_length)\n", |
| 237 | + "samsum_dataset.trust_remote_code = True\n", |
253 | 238 | "\n",
|
254 |
| - "# Create DataLoaders for the training and validation dataset\n", |
255 |
| - "train_dataloader = torch.utils.data.DataLoader(\n", |
256 |
| - " train_dataset,\n", |
257 |
| - " num_workers=train_config.num_workers_dataloader,\n", |
258 |
| - " pin_memory=True,\n", |
259 |
| - " **train_dl_kwargs,\n", |
260 |
| - ")" |
| 239 | + "train_dataloader = get_dataloader(tokenizer, samsum_dataset, train_config)\n", |
| 240 | + "eval_dataloader = get_dataloader(tokenizer, samsum_dataset, train_config, \"val\")" |
261 | 241 | ]
|
262 | 242 | },
|
263 | 243 | {
|
|
310 | 290 | "name": "stderr",
|
311 | 291 | "output_type": "stream",
|
312 | 292 | "text": [
|
313 |
| - "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/torch/cuda/memory.py:330: FutureWarning: torch.cuda.reset_max_memory_allocated now calls torch.cuda.reset_peak_memory_stats, which resets /all/ peak memory stats.\n", |
| 293 | + "/home/ubuntu/llama-recipes/src/llama_recipes/utils/train_utils.py:92: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.\n", |
| 294 | + " scaler = torch.cuda.amp.GradScaler()\n", |
| 295 | + "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/torch/cuda/memory.py:343: FutureWarning: torch.cuda.reset_max_memory_allocated now calls torch.cuda.reset_peak_memory_stats, which resets /all/ peak memory stats.\n", |
314 | 296 | " warnings.warn(\n",
|
315 | 297 | "Training Epoch: 1: 0%|\u001b[34m \u001b[0m| 0/319 [00:00<?, ?it/s]huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
|
316 | 298 | "To disable this warning, you can either:\n",
|
317 | 299 | "\t- Avoid using `tokenizers` before the fork if possible\n",
|
318 | 300 | "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
|
319 |
| - "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", |
320 |
| - " warnings.warn(\n", |
| 301 | + "/home/ubuntu/llama-recipes/src/llama_recipes/utils/train_utils.py:151: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n", |
| 302 | + " with autocast():\n", |
| 303 | + "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py:600: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", |
| 304 | + " return fn(*args, **kwargs)\n", |
321 | 305 | "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/bitsandbytes/autograd/_functions.py:316: UserWarning: MatMul8bitLt: inputs will be cast from torch.float32 to float16 during quantization\n",
|
322 | 306 | " warnings.warn(f\"MatMul8bitLt: inputs will be cast from {A.dtype} to float16 during quantization\")\n",
|
323 |
| - "Training Epoch: 1/1, step 1278/1279 completed (loss: 0.27870458364486694): : 320it [2:07:09, 23.84s/it] 3.94s/it] \n" |
| 307 | + "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/torch/utils/checkpoint.py:295: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.\n", |
| 308 | + " with torch.enable_grad(), device_autocast_ctx, torch.cpu.amp.autocast(**ctx.cpu_autocast_kwargs): # type: ignore[attr-defined]\n", |
| 309 | + "Training Epoch: 1/1, step 1278/1279 completed (loss: 0.28094857931137085): : 320it [2:08:50, 24.16s/it] 4.21s/it] \n" |
324 | 310 | ]
|
325 | 311 | },
|
326 | 312 | {
|
|
332 | 318 | "Peak active CUDA memory was 15 GB\n",
|
333 | 319 | "CUDA Malloc retries : 0\n",
|
334 | 320 | "CPU Total Peak Memory consumed during the train (max): 2 GB\n",
|
335 |
| - "Epoch 1: train_perplexity=1.3403, train_epoch_loss=0.2929, epoch time 7630.169942979002s\n" |
| 321 | + "Epoch 1: train_perplexity=1.3404, train_epoch_loss=0.2930, epoch time 7730.981359725998s\n" |
336 | 322 | ]
|
337 | 323 | }
|
338 | 324 | ],
|
|
354 | 340 | "results = train(\n",
|
355 | 341 | " model,\n",
|
356 | 342 | " train_dataloader,\n",
|
357 |
| - " None,\n", |
| 343 | + " eval_dataloader,\n", |
358 | 344 | " tokenizer,\n",
|
359 | 345 | " optimizer,\n",
|
360 | 346 | " scheduler,\n",
|
|
380 | 366 | "cell_type": "code",
|
381 | 367 | "execution_count": 7,
|
382 | 368 | "metadata": {},
|
383 |
| - "outputs": [ |
384 |
| - { |
385 |
| - "name": "stderr", |
386 |
| - "output_type": "stream", |
387 |
| - "text": [ |
388 |
| - "/home/ubuntu/miniconda3/envs/llama/lib/python3.11/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", |
389 |
| - " warnings.warn(\n" |
390 |
| - ] |
391 |
| - } |
392 |
| - ], |
| 369 | + "outputs": [], |
393 | 370 | "source": [
|
394 | 371 | "model.save_pretrained(train_config.output_dir)"
|
395 | 372 | ]
|
|
440 | 417 | "A: He said he’d name it after his dead hamster – Lemmy - he's a great Motorhead fan :-)))\n",
|
441 | 418 | "---\n",
|
442 | 419 | "Summary:\n",
|
443 |
| - "A wants to get a puppy for her son. She will take him to the animal shelter tomorrow. B is not sure if he can go with her, but he's willing to.\n" |
| 420 | + "A wants to get a puppy for his son. A took him to the animal shelter last Monday and he showed A one he really liked. A wants to get him one of those little dogs. A and B agree that raising a dog is a tough issue.\n" |
444 | 421 | ]
|
445 | 422 | }
|
446 | 423 | ],
|
447 | 424 | "source": [
|
448 | 425 | "model.eval()\n",
|
449 |
| - "with torch.no_grad():\n", |
| 426 | + "with torch.inference_mode():\n", |
450 | 427 | " print(tokenizer.decode(model.generate(**model_input, max_new_tokens=100)[0], skip_special_tokens=True))\n"
|
451 | 428 | ]
|
452 | 429 | }
|
|
467 | 444 | "name": "python",
|
468 | 445 | "nbconvert_exporter": "python",
|
469 | 446 | "pygments_lexer": "ipython3",
|
470 |
| - "version": "3.10.14" |
| 447 | + "version": "3.11.9" |
471 | 448 | },
|
472 | 449 | "vscode": {
|
473 | 450 | "interpreter": {
|
|
0 commit comments