Spaces:
Build error
Build error
minor bug fix
Browse files- notebooks/00_fine-tune-with-colab.ipynb +1 -1
- requirements.txt +1 -1
- scripts/tune-mac.sh +2 -2
notebooks/00_fine-tune-with-colab.ipynb
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"0ea8b46b-839b-445b-8043-ccdf4e920ace","showTitle":false,"title":""},"id":"YLH80COBzi_F"},"outputs":[],"source":["%load_ext autoreload\n","%autoreload 2"]},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"id":"63B5exAuzq4M"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["workding_dir = \"/content/drive/MyDrive/logical-reasoning/\""],"metadata":{"id":"zFulf0bg0H-9"},"execution_count":null,"outputs":[]},{"cell_type":"code","execution_count":null,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"6d394937-6c99-4a7c-9d32-7600a280032f","showTitle":false,"title":""},"id":"Rzln0ffbzi_H"},"outputs":[],"source":["import os\n","import sys\n","from pathlib import Path\n","\n","os.chdir(workding_dir)\n","sys.path.append(workding_dir)\n","print(\"workding dir:\", workding_dir)"]},{"cell_type":"code","source":["%%capture\n","# Installs Unsloth, Xformers (Flash Attention) and all other packages!\n","!pip install \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git\"\n","!pip install --no-deps xformers \"trl<0.9.0\" peft accelerate bitsandbytes\n","\n","\n","!pip install -r requirements.txt"],"metadata":{"id":"blBRUfev1ccE"},"execution_count":null,"outputs":[]},{"cell_type":"code","execution_count":null,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"9f67ec60-2f24-411c-84eb-0dd664b44775","showTitle":false,"title":""},"id":"DIUiweYYzi_I"},"outputs":[],"source":["from dotenv import find_dotenv, load_dotenv\n","\n","found_dotenv = find_dotenv(\".env\")\n","\n","if len(found_dotenv) == 0:\n"," found_dotenv = find_dotenv(\".env.example\")\n","print(f\"loading env vars from: {found_dotenv}\")\n","load_dotenv(found_dotenv, override=True)"]},{"cell_type":"code","execution_count":null,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"f1597656-8042-4878-9d3b-9ebfb8dd86dc","showTitle":false,"title":""},"id":"wLbMLrZbzi_I"},"outputs":[],"source":["import os\n","\n","model_name = os.getenv(\"MODEL_NAME\")\n","token = os.getenv(\"HF_TOKEN\") or None\n","load_in_4bit = os.getenv(\"LOAD_IN_4BIT\") == \"true\"\n","local_model = os.getenv(\"LOCAL_MODEL\")\n","hub_model = os.getenv(\"HUB_MODEL\")\n","num_train_epochs = int(os.getenv(\"NUM_TRAIN_EPOCHS\") or 0)\n","data_path = os.getenv(\"DATA_PATH\")\n","results_path = os.getenv(\"RESULTS_PATH\")\n","\n","max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!\n","dtype = (\n"," None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+\n",")\n","\n","model_name, load_in_4bit, local_model, hub_model, max_seq_length, num_train_epochs, dtype, data_path, results_path"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"6nmbA8Tpzi_J"},"outputs":[],"source":["!nvidia-smi"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"4hQO8gkFzi_K","colab":{"base_uri":"https://localhost:8080/"},"outputId":"d36c7526-b607-48f4-8311-4a3b7ba31d56"},"outputs":[{"output_type":"stream","name":"stdout","text":["Current Directory:\n","/content/drive/.shortcut-targets-by-id/1E09lTnfbsjtTgQg65dQ3y9D2R6l8waxR/logical-reasoning\n","Wed Jun 26 22:59:53 2024 \n","+---------------------------------------------------------------------------------------+\n","| NVIDIA-SMI 535.104.05 Driver Version: 535.104.05 CUDA Version: 12.2 |\n","|-----------------------------------------+----------------------+----------------------+\n","| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n","| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n","| | | MIG M. |\n","|=========================================+======================+======================|\n","| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n","| N/A 68C P8 11W / 70W | 0MiB / 15360MiB | 0% Default |\n","| | | N/A |\n","+-----------------------------------------+----------------------+----------------------+\n"," \n","+---------------------------------------------------------------------------------------+\n","| Processes: |\n","| GPU GI CI PID Type Process name GPU Memory |\n","| ID ID Usage |\n","|=======================================================================================|\n","| No running processes found |\n","+---------------------------------------------------------------------------------------+\n","Linux f4b16e94a91c 6.1.85+ #1 SMP PREEMPT_DYNAMIC Fri May 24 14:06:39 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux\n","PRETTY_NAME=\"Ubuntu 22.04.3 LTS\"\n","NAME=\"Ubuntu\"\n","VERSION_ID=\"22.04\"\n","VERSION=\"22.04.3 LTS (Jammy Jellyfish)\"\n","VERSION_CODENAME=jammy\n","ID=ubuntu\n","ID_LIKE=debian\n","HOME_URL=\"https://www.ubuntu.com/\"\n","SUPPORT_URL=\"https://help.ubuntu.com/\"\n","BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\n","PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n","UBUNTU_CODENAME=jammy\n","Architecture: x86_64\n"," CPU op-mode(s): 32-bit, 64-bit\n"," Address sizes: 46 bits physical, 48 bits virtual\n"," Byte Order: Little Endian\n","CPU(s): 2\n"," On-line CPU(s) list: 0,1\n","Vendor ID: GenuineIntel\n"," Model name: Intel(R) Xeon(R) CPU @ 2.00GHz\n"," CPU family: 6\n"," Model: 85\n"," Thread(s) per core: 2\n"," Core(s) per socket: 1\n"," Socket(s): 1\n"," Stepping: 3\n"," BogoMIPS: 4000.29\n"," Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 cl\n"," flush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc re\n"," p_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3\n"," fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand\n"," hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp \n"," fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f a\n"," vx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveop\n"," t xsavec xgetbv1 xsaves arat md_clear arch_capabilities\n","Virtualization features: \n"," Hypervisor vendor: KVM\n"," Virtualization type: full\n","Caches (sum of all): \n"," L1d: 32 KiB (1 instance)\n"," L1i: 32 KiB (1 instance)\n"," L2: 1 MiB (1 instance)\n"," L3: 38.5 MiB (1 instance)\n","NUMA: \n"," NUMA node(s): 1\n"," NUMA node0 CPU(s): 0,1\n","Vulnerabilities: \n"," Gather data sampling: Not affected\n"," Itlb multihit: Not affected\n"," L1tf: Mitigation; PTE Inversion\n"," Mds: Vulnerable; SMT Host state unknown\n"," Meltdown: Vulnerable\n"," Mmio stale data: Vulnerable\n"," Reg file data sampling: Not affected\n"," Retbleed: Vulnerable\n"," Spec rstack overflow: Not affected\n"," Spec store bypass: Vulnerable\n"," Spectre v1: Vulnerable: __user pointer sanitization and usercopy barriers only; no swa\n"," pgs barriers\n"," Spectre v2: Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BH\n"," I: Vulnerable (Syscall hardening enabled)\n"," Srbds: Not affected\n"," Tsx async abort: Vulnerable\n","MemTotal: 13290452 kB\n","Tuning unsloth/Qwen2-0.5B-Instruct-bnb-4bit\n","loading env vars from: /content/drive/.shortcut-targets-by-id/1E09lTnfbsjtTgQg65dQ3y9D2R6l8waxR/logical-reasoning/.env\n","Adding /content/drive/.shortcut-targets-by-id/1E09lTnfbsjtTgQg65dQ3y9D2R6l8waxR/logical-reasoning to sys.path\n","🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n","2024-06-26 23:00:00.295266: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n","2024-06-26 23:00:00.295314: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n","2024-06-26 23:00:00.296863: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n","2024-06-26 23:00:00.304716: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n","To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n","2024-06-26 23:00:01.409557: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n","[nltk_data] Downloading package wordnet to /root/nltk_data...\n","[nltk_data] Package wordnet is already up-to-date!\n","[nltk_data] Downloading package punkt to /root/nltk_data...\n","[nltk_data] Package punkt is already up-to-date!\n","[nltk_data] Downloading package omw-1.4 to /root/nltk_data...\n","[nltk_data] Package omw-1.4 is already up-to-date!\n","loading /content/drive/.shortcut-targets-by-id/1E09lTnfbsjtTgQg65dQ3y9D2R6l8waxR/logical-reasoning/llm_toolkit/translation_engine.py\n","unsloth/Qwen2-0.5B-Instruct-bnb-4bit True 2048 10 None datasets/mac/mac.tsv results/mac-results-colab.csv True True False\n","(1) GPU = Tesla T4. Max memory = 14.748 GB.\n","0.0 GB of memory reserved.\n","loading model: unsloth/Qwen2-0.5B-Instruct-bnb-4bit\n","==((====))== Unsloth: Fast Qwen2 patching release 2024.6\n"," \\\\ /| GPU: Tesla T4. Max memory: 14.748 GB. Platform = Linux.\n","O^O/ \\_/ \\ Pytorch: 2.3.0+cu121. CUDA = 7.5. CUDA Toolkit = 12.1.\n","\\ / Bfloat16 = FALSE. Xformers = 0.0.26.post1. FA = False.\n"," \"-____-\" Free Apache license: http://github.com/unslothai/unsloth\n","Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n","Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n","(2) GPU = Tesla T4. Max memory = 14.748 GB.\n","0.633 GB of memory reserved.\n","loading train/test data files\n","DatasetDict({\n"," train: Dataset({\n"," features: ['chinese', 'english', 'text', 'prompt'],\n"," num_rows: 4528\n"," })\n"," test: Dataset({\n"," features: ['chinese', 'english', 'text', 'prompt'],\n"," num_rows: 1133\n"," })\n","})\n","Evaluating base model: unsloth/Qwen2-0.5B-Instruct-bnb-4bit\n"," 0% 0/1133 [00:00<?, ?it/s]--------\n","step 1: Old耿举起枪,眯缝起了三角眼,砰的一声扣动扳机,子弹轰隆隆地落下,一颗颗的金麻雀扑棱棱地落在柳树上,嘎吱嘎呀地发出声响。<|im_end|>\n","--------\n","step 2: Old耿举起枪,眯缝起了三角眼,砰的一声扣动扳机,子弹轰隆隆地落下,一颗颗的金麻雀扑棱棱地落在柳树上,嘎吱嘎呀地发出声响。\n","--------\n","step 3: Old耿举起枪,眯缝起了三角眼,砰的一声扣动扳机,子弹轰隆隆地落下,一颗颗的金麻雀扑棱棱地落在柳树上,嘎吱嘎呀地发出声响。\n","100% 1133/1133 [1:01:12<00:00, 3.24s/it]\n"," chinese ... unsloth/Qwen2-0.5B-Instruct-bnb-4bit\n","0 老耿端起枪,眯缝起一只三角眼,一搂扳机响了枪,冰雹般的金麻雀劈哩啪啦往下落,铁砂子在柳枝间飞... ... Old耿举起枪,眯缝起了三角眼,砰的一声扣动扳机,子弹轰隆隆地落下,一颗颗的金麻雀扑棱棱地落...\n","\n","[1 rows x 3 columns]\n","(3) GPU = Tesla T4. Max memory = 14.748 GB.\n","0.955 GB of memory reserved.\n","Unsloth 2024.6 patched 24 layers with 0 QKV layers, 24 O layers and 24 MLP layers.\n","/usr/local/lib/python3.10/dist-packages/multiprocess/popen_fork.py:66: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.\n"," self.pid = os.fork()\n","Map (num_proc=2): 100% 4528/4528 [00:03<00:00, 1364.29 examples/s]\n","(4) GPU = Tesla T4. Max memory = 14.748 GB.\n","0.955 GB of memory reserved.\n","==((====))== Unsloth - 2x faster free finetuning | Num GPUs = 1\n"," \\\\ /| Num examples = 4,528 | Num Epochs = 10\n","O^O/ \\_/ \\ Batch size per device = 2 | Gradient Accumulation steps = 4\n","\\ / Total batch size = 8 | Total steps = 5,660\n"," \"-____-\" Number of trainable parameters = 8,798,208\n","{'loss': 1.9475, 'grad_norm': 0.953141450881958, 'learning_rate': 0.00019667550839964635, 'epoch': 0.18}\n","{'loss': 1.7755, 'grad_norm': 0.8021742701530457, 'learning_rate': 0.00019313881520778074, 'epoch': 0.35}\n","{'loss': 1.7138, 'grad_norm': 0.9069837927818298, 'learning_rate': 0.00018960212201591512, 'epoch': 0.53}\n","{'loss': 1.7147, 'grad_norm': 0.7456142902374268, 'learning_rate': 0.00018606542882404953, 'epoch': 0.71}\n","{'loss': 1.6848, 'grad_norm': 0.8153131008148193, 'learning_rate': 0.0001825287356321839, 'epoch': 0.88}\n","{'loss': 1.6068, 'grad_norm': 0.7906574010848999, 'learning_rate': 0.00017899204244031832, 'epoch': 1.06}\n","{'loss': 1.4909, 'grad_norm': 0.8980427384376526, 'learning_rate': 0.0001754553492484527, 'epoch': 1.24}\n","{'loss': 1.5395, 'grad_norm': 0.9705032110214233, 'learning_rate': 0.0001719186560565871, 'epoch': 1.41}\n","{'loss': 1.4708, 'grad_norm': 1.0619163513183594, 'learning_rate': 0.0001683819628647215, 'epoch': 1.59}\n","{'loss': 1.4672, 'grad_norm': 0.981268048286438, 'learning_rate': 0.0001648452696728559, 'epoch': 1.77}\n","{'loss': 1.5264, 'grad_norm': 1.004439353942871, 'learning_rate': 0.00016130857648099029, 'epoch': 1.94}\n","{'loss': 1.3477, 'grad_norm': 1.1568070650100708, 'learning_rate': 0.00015777188328912467, 'epoch': 2.12}\n","{'loss': 1.2139, 'grad_norm': 1.1788620948791504, 'learning_rate': 0.00015423519009725908, 'epoch': 2.3}\n","{'loss': 1.2553, 'grad_norm': 1.2886534929275513, 'learning_rate': 0.00015069849690539346, 'epoch': 2.47}\n","{'loss': 1.2538, 'grad_norm': 1.2783722877502441, 'learning_rate': 0.00014716180371352787, 'epoch': 2.65}\n","{'loss': 1.2643, 'grad_norm': 1.1668360233306885, 'learning_rate': 0.00014362511052166225, 'epoch': 2.83}\n","{'loss': 1.2326, 'grad_norm': 1.0913087129592896, 'learning_rate': 0.00014008841732979666, 'epoch': 3.0}\n","{'loss': 0.9765, 'grad_norm': 1.468590259552002, 'learning_rate': 0.00013655172413793104, 'epoch': 3.18}\n","{'loss': 0.9891, 'grad_norm': 1.523878574371338, 'learning_rate': 0.00013301503094606545, 'epoch': 3.36}\n","{'loss': 0.9958, 'grad_norm': 1.5432509183883667, 'learning_rate': 0.0001294783377541998, 'epoch': 3.53}\n","{'loss': 0.9778, 'grad_norm': 1.551354169845581, 'learning_rate': 0.00012594164456233422, 'epoch': 3.71}\n","{'loss': 1.0205, 'grad_norm': 1.5879628658294678, 'learning_rate': 0.0001224049513704686, 'epoch': 3.89}\n","{'loss': 0.9267, 'grad_norm': 1.5796101093292236, 'learning_rate': 0.00011886825817860301, 'epoch': 4.06}\n","{'loss': 0.7359, 'grad_norm': 1.7161469459533691, 'learning_rate': 0.0001153315649867374, 'epoch': 4.24}\n","{'loss': 0.7356, 'grad_norm': 1.6962307691574097, 'learning_rate': 0.0001117948717948718, 'epoch': 4.42}\n","{'loss': 0.7703, 'grad_norm': 2.1471188068389893, 'learning_rate': 0.0001082581786030062, 'epoch': 4.59}\n","{'loss': 0.7684, 'grad_norm': 2.1669650077819824, 'learning_rate': 0.00010472148541114059, 'epoch': 4.77}\n"," 49% 2747/5660 [1:25:40<1:23:13, 1.71s/it]"]}],"source":["%%time\n","\n","!chmod +x ./scripts/tune.sh\n","!./scripts/tune.sh"]}],"metadata":{"accelerator":"GPU","application/vnd.databricks.v1+notebook":{"dashboards":[],"environmentMetadata":null,"language":"python","notebookMetadata":{"pythonIndentUnit":4},"notebookName":"07_MAC_+_Qwen2-7B-Instructi_Unsloth_train","widgets":{}},"colab":{"gpuType":"T4","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.14"}},"nbformat":4,"nbformat_minor":0}
|
|
|
1 |
+
{"cells":[{"cell_type":"code","execution_count":10,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"0ea8b46b-839b-445b-8043-ccdf4e920ace","showTitle":false,"title":""},"id":"YLH80COBzi_F","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1719451913970,"user_tz":-480,"elapsed":471,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"0104a389-132f-4fd9-89f6-aae27bb8c369"},"outputs":[{"output_type":"stream","name":"stdout","text":["The autoreload extension is already loaded. To reload it, use:\n"," %reload_ext autoreload\n"]}],"source":["%load_ext autoreload\n","%autoreload 2"]},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"id":"63B5exAuzq4M","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1719451916936,"user_tz":-480,"elapsed":2581,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"21003e67-b8be-4ea5-e210-eed179e28f0a"},"execution_count":11,"outputs":[{"output_type":"stream","name":"stdout","text":["Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"]}]},{"cell_type":"code","source":["workding_dir = \"/content/drive/MyDrive/logical-reasoning/\""],"metadata":{"id":"zFulf0bg0H-9","executionInfo":{"status":"ok","timestamp":1719451916936,"user_tz":-480,"elapsed":2,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}}},"execution_count":12,"outputs":[]},{"cell_type":"code","execution_count":13,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"6d394937-6c99-4a7c-9d32-7600a280032f","showTitle":false,"title":""},"id":"Rzln0ffbzi_H","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1719451916936,"user_tz":-480,"elapsed":2,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"7d792e4a-0c1c-4682-f398-b59f0cbf6a47"},"outputs":[{"output_type":"stream","name":"stdout","text":["workding dir: /content/drive/MyDrive/logical-reasoning/\n"]}],"source":["import os\n","import sys\n","from pathlib import Path\n","\n","os.chdir(workding_dir)\n","sys.path.append(workding_dir)\n","print(\"workding dir:\", workding_dir)"]},{"cell_type":"code","source":["%%capture\n","# Installs Unsloth, Xformers (Flash Attention) and all other packages!\n","!pip install \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git\"\n","!pip install --no-deps xformers \"trl<0.9.0\" peft accelerate bitsandbytes"],"metadata":{"id":"blBRUfev1ccE","executionInfo":{"status":"ok","timestamp":1719452306704,"user_tz":-480,"elapsed":19373,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}}},"execution_count":19,"outputs":[]},{"cell_type":"code","source":["%%capture\n","!pip install -r requirements.txt"],"metadata":{"id":"zUqv4IUmU6Yv","executionInfo":{"status":"ok","timestamp":1719452341495,"user_tz":-480,"elapsed":9646,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}}},"execution_count":22,"outputs":[]},{"cell_type":"code","execution_count":24,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"9f67ec60-2f24-411c-84eb-0dd664b44775","showTitle":false,"title":""},"id":"DIUiweYYzi_I","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1719452361195,"user_tz":-480,"elapsed":369,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"9772a343-40cf-4216-df67-6176908693ad"},"outputs":[{"output_type":"stream","name":"stdout","text":["loading env vars from: /content/drive/MyDrive/logical-reasoning/.env.example\n"]},{"output_type":"execute_result","data":{"text/plain":["True"]},"metadata":{},"execution_count":24}],"source":["from dotenv import find_dotenv, load_dotenv\n","\n","found_dotenv = find_dotenv(\".env\")\n","\n","if len(found_dotenv) == 0:\n"," found_dotenv = find_dotenv(\".env.example\")\n","print(f\"loading env vars from: {found_dotenv}\")\n","load_dotenv(found_dotenv, override=True)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"4hQO8gkFzi_K","colab":{"base_uri":"https://localhost:8080/"},"outputId":"bdd25999-bbcc-4022-bca0-6f2650e70500"},"outputs":[{"output_type":"stream","name":"stdout","text":["Current Directory:\n","/content/drive/MyDrive/logical-reasoning\n","Thu Jun 27 01:40:46 2024 \n","+---------------------------------------------------------------------------------------+\n","| NVIDIA-SMI 535.104.05 Driver Version: 535.104.05 CUDA Version: 12.2 |\n","|-----------------------------------------+----------------------+----------------------+\n","| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n","| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n","| | | MIG M. |\n","|=========================================+======================+======================|\n","| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n","| N/A 38C P8 9W / 70W | 0MiB / 15360MiB | 0% Default |\n","| | | N/A |\n","+-----------------------------------------+----------------------+----------------------+\n"," \n","+---------------------------------------------------------------------------------------+\n","| Processes: |\n","| GPU GI CI PID Type Process name GPU Memory |\n","| ID ID Usage |\n","|=======================================================================================|\n","| No running processes found |\n","+---------------------------------------------------------------------------------------+\n","Linux 1508906e64c1 6.1.85+ #1 SMP PREEMPT_DYNAMIC Fri May 24 14:06:39 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux\n","PRETTY_NAME=\"Ubuntu 22.04.3 LTS\"\n","NAME=\"Ubuntu\"\n","VERSION_ID=\"22.04\"\n","VERSION=\"22.04.3 LTS (Jammy Jellyfish)\"\n","VERSION_CODENAME=jammy\n","ID=ubuntu\n","ID_LIKE=debian\n","HOME_URL=\"https://www.ubuntu.com/\"\n","SUPPORT_URL=\"https://help.ubuntu.com/\"\n","BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\n","PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n","UBUNTU_CODENAME=jammy\n","Architecture: x86_64\n"," CPU op-mode(s): 32-bit, 64-bit\n"," Address sizes: 46 bits physical, 48 bits virtual\n"," Byte Order: Little Endian\n","CPU(s): 2\n"," On-line CPU(s) list: 0,1\n","Vendor ID: GenuineIntel\n"," Model name: Intel(R) Xeon(R) CPU @ 2.20GHz\n"," CPU family: 6\n"," Model: 79\n"," Thread(s) per core: 2\n"," Core(s) per socket: 1\n"," Socket(s): 1\n"," Stepping: 0\n"," BogoMIPS: 4399.99\n"," Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 cl\n"," flush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc re\n"," p_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3\n"," fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand\n"," hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp \n"," fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx sm\n"," ap xsaveopt arat md_clear arch_capabilities\n","Virtualization features: \n"," Hypervisor vendor: KVM\n"," Virtualization type: full\n","Caches (sum of all): \n"," L1d: 32 KiB (1 instance)\n"," L1i: 32 KiB (1 instance)\n"," L2: 256 KiB (1 instance)\n"," L3: 55 MiB (1 instance)\n","NUMA: \n"," NUMA node(s): 1\n"," NUMA node0 CPU(s): 0,1\n","Vulnerabilities: \n"," Gather data sampling: Not affected\n"," Itlb multihit: Not affected\n"," L1tf: Mitigation; PTE Inversion\n"," Mds: Vulnerable; SMT Host state unknown\n"," Meltdown: Vulnerable\n"," Mmio stale data: Vulnerable\n"," Reg file data sampling: Not affected\n"," Retbleed: Vulnerable\n"," Spec rstack overflow: Not affected\n"," Spec store bypass: Vulnerable\n"," Spectre v1: Vulnerable: __user pointer sanitization and usercopy barriers only; no swa\n"," pgs barriers\n"," Spectre v2: Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BH\n"," I: Vulnerable (Syscall hardening enabled)\n"," Srbds: Not affected\n"," Tsx async abort: Vulnerable\n","MemTotal: 13290460 kB\n","Tuning unsloth/Qwen2-0.5B-Instruct\n","loading env vars from: /content/drive/MyDrive/logical-reasoning/.env.example\n","Adding /content/drive/MyDrive/logical-reasoning to sys.path\n","🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n","2024-06-27 01:40:52.684349: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n","2024-06-27 01:40:52.684401: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n","2024-06-27 01:40:52.685772: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n","2024-06-27 01:40:52.693223: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n","To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n","2024-06-27 01:40:53.782543: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n","[nltk_data] Downloading package wordnet to /root/nltk_data...\n","[nltk_data] Package wordnet is already up-to-date!\n","[nltk_data] Downloading package punkt to /root/nltk_data...\n","[nltk_data] Package punkt is already up-to-date!\n","[nltk_data] Downloading package omw-1.4 to /root/nltk_data...\n","[nltk_data] Package omw-1.4 is already up-to-date!\n","loading /content/drive/MyDrive/logical-reasoning/llm_toolkit/translation_engine.py\n","unsloth/Qwen2-0.5B-Instruct True 2048 10 None datasets/mac/mac.tsv results/mac-results-colab.csv True False False False\n","(1) GPU = Tesla T4. Max memory = 14.748 GB.\n","0.0 GB of memory reserved.\n","loading model: unsloth/Qwen2-0.5B-Instruct\n","config.json: 100% 1.19k/1.19k [00:00<00:00, 8.35MB/s]\n","==((====))== Unsloth: Fast Qwen2 patching release 2024.6\n"," \\\\ /| GPU: Tesla T4. Max memory: 14.748 GB. Platform = Linux.\n","O^O/ \\_/ \\ Pytorch: 2.3.0+cu121. CUDA = 7.5. CUDA Toolkit = 12.1.\n","\\ / Bfloat16 = FALSE. Xformers = 0.0.26.post1. FA = False.\n"," \"-____-\" Free Apache license: http://github.com/unslothai/unsloth\n","model.safetensors: 100% 457M/457M [00:02<00:00, 222MB/s]\n","generation_config.json: 100% 242/242 [00:00<00:00, 1.28MB/s]\n","Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n","Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n","(2) GPU = Tesla T4. Max memory = 14.748 GB.\n","0.633 GB of memory reserved.\n","loading train/test data files\n","Map: 100% 4528/4528 [00:00<00:00, 21429.62 examples/s]\n","Map: 100% 1133/1133 [00:00<00:00, 25264.07 examples/s]\n","DatasetDict({\n"," train: Dataset({\n"," features: ['chinese', 'english', 'text', 'prompt'],\n"," num_rows: 4528\n"," })\n"," test: Dataset({\n"," features: ['chinese', 'english', 'text', 'prompt'],\n"," num_rows: 1133\n"," })\n","})\n","Evaluating base model: unsloth/Qwen2-0.5B-Instruct\n"," 0% 0/1133 [00:00<?, ?it/s]--------\n","step 1: Old Teng held his gun, closing his eyes and raising one triangular eye. A round shot rang out as the bullet was fired. The cannonball flew like a raindrop through the grass, cracking and clattering.<|im_end|>\n","--------\n","step 2: Old Teng held his gun, closing his eyes and raising one triangular eye. A round shot rang out as the bullet was fired. The cannonball flew like a raindrop through the grass, cracking and clattering.\n","--------\n","step 3: Old Teng held his gun, closing his eyes and raising one triangular eye. A round shot rang out as the bullet was fired. The cannonball flew like a raindrop through the grass, cracking and clattering.\n"," 26% 297/1133 [15:45<48:20, 3.47s/it]"]}],"source":["%%time\n","\n","!chmod +x ./scripts/tune-mac.sh\n","!./scripts/tune-mac.sh"]}],"metadata":{"accelerator":"GPU","application/vnd.databricks.v1+notebook":{"dashboards":[],"environmentMetadata":null,"language":"python","notebookMetadata":{"pythonIndentUnit":4},"notebookName":"07_MAC_+_Qwen2-7B-Instructi_Unsloth_train","widgets":{}},"colab":{"gpuType":"T4","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.14"}},"nbformat":4,"nbformat_minor":0}
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
huggingface_hub==0.
|
2 |
nltk==3.8.1
|
3 |
python-dotenv==1.0.1
|
4 |
black==24.4.0
|
|
|
1 |
+
huggingface_hub==0.23.0
|
2 |
nltk==3.8.1
|
3 |
python-dotenv==1.0.1
|
4 |
black==24.4.0
|
scripts/tune-mac.sh
CHANGED
@@ -14,11 +14,11 @@ grep MemTotal /proc/meminfo
|
|
14 |
# pip install -r requirements.txt
|
15 |
# FLASH_ATTENTION_FORCE_BUILD=TRUE pip install --upgrade flash-attn
|
16 |
|
17 |
-
export MODEL_NAME=unsloth/Qwen2-0.5B-Instruct
|
18 |
echo Tuning $MODEL_NAME
|
19 |
python llm_toolkit/tune_mac.py
|
20 |
|
21 |
-
export MODEL_NAME=unsloth/Qwen2-1.5B-Instruct
|
22 |
echo Tuning $MODEL_NAME
|
23 |
python llm_toolkit/tune_mac.py
|
24 |
|
|
|
14 |
# pip install -r requirements.txt
|
15 |
# FLASH_ATTENTION_FORCE_BUILD=TRUE pip install --upgrade flash-attn
|
16 |
|
17 |
+
export MODEL_NAME=unsloth/Qwen2-0.5B-Instruct
|
18 |
echo Tuning $MODEL_NAME
|
19 |
python llm_toolkit/tune_mac.py
|
20 |
|
21 |
+
export MODEL_NAME=unsloth/Qwen2-1.5B-Instruct
|
22 |
echo Tuning $MODEL_NAME
|
23 |
python llm_toolkit/tune_mac.py
|
24 |
|