{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "K7mToM4fKBHc" }, "source": [ "To run this, press \"*Runtime*\" and press \"*Run all*\" on a **free** Tesla T4 Google Colab instance!\n", "
\n", "\n", "To install Unsloth your local device, follow [our guide](https://docs.unsloth.ai/get-started/install-and-update). This notebook is licensed [LGPL-3.0](https://github.com/unslothai/notebooks?tab=LGPL-3.0-1-ov-file#readme).\n", "\n", "You will learn how to do [data prep](#Data), how to [train](#Train), how to [run the model](#Inference), & [how to save it](#Save)\n" ] }, { "cell_type": "markdown", "metadata": { "id": "tUv6-kLHKBHf" }, "source": [ "### News" ] }, { "cell_type": "markdown", "metadata": { "id": "A2PoyiWgKBHh" }, "source": [ "Long-Context GRPO for reinforcement learning — train stably at massive sequence lengths. Fine-tune models with up to 7x more context length efficiently. [Read Blog](https://unsloth.ai/docs/new/grpo-long-context)\n", "\n", "3× faster training with optimized sequence packing — higher throughput with no quality loss.[Read Blog](https://unsloth.ai/docs/new/3x-faster-training-packing)\n", "\n", "500k context-length fine-tuning — push long-context models further with memory-efficient training. [Read Blog](https://unsloth.ai/docs/new/500k-context-length-fine-tuning)\n", "\n", "Introducing FP8 precision training for faster RL inference. [Read Blog](https://docs.unsloth.ai/new/fp8-reinforcement-learning).\n", "\n", "Unsloth's [Docker image](https://hub.docker.com/r/unsloth/unsloth) is here! Start training with no setup & environment issues. [Read our Guide](https://docs.unsloth.ai/new/how-to-train-llms-with-unsloth-and-docker).\n", "\n", "Visit our docs for all our [model uploads](https://docs.unsloth.ai/get-started/all-our-models) and [notebooks](https://docs.unsloth.ai/get-started/unsloth-notebooks).\n" ] }, { "cell_type": "markdown", "metadata": { "id": "r9TxxHjLKBHj" }, "source": [ "### Installation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "iQoGqF7nKBHk" }, "outputs": [], "source": [ "%%capture\n", "import os, re\n", "if \"COLAB_\" not in \"\".join(os.environ.keys()):\n", " !pip install unsloth\n", "else:\n", " # Do this only in Colab notebooks! Otherwise use pip install unsloth\n", " import torch; v = re.match(r\"[0-9]{1,}\\.[0-9]{1,}\", str(torch.__version__)).group(0)\n", " xformers = \"xformers==\" + (\"0.0.33.post1\" if v==\"2.9\" else \"0.0.32.post2\" if v==\"2.8\" else \"0.0.29.post3\")\n", " !pip install --no-deps bitsandbytes accelerate {xformers} peft trl triton cut_cross_entropy unsloth_zoo\n", " !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n", " !pip install --no-deps unsloth\n", "!pip install transformers==4.56.2\n", "!pip install --no-deps trl==0.22.2\n", "!pip install torchao==0.14.0 executorch pytorch_tokenizers" ] }, { "cell_type": "markdown", "metadata": { "id": "iajq1W8ipjyK" }, "source": [ "### Unsloth" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 509, "referenced_widgets": [ "81a2175c450b41539f986b7b270e2ed1", "99c61c81588c406581e80427e5af5040", "27a7696c008f45ad9ba214ddc1e1308b", "e6421243f0e442fb9b051dff46c8686f", "e638f4fb8a23482b8d417c5e6d113227", "6231a1bd2f204f88883a4c0278133bf2", "9a17601a2dac4fba92e99c9d8618fa97", "501651fd06394ad0b41ef2717a4a0a5d", "41ef06de012048a299fb78e963702a8e", "6b441a68b0d74b9f84af69ec1bf8fa86", "e7fb4f5b48884354be7deb3f3bbd2269", "edd0f0631d214a9aaf411c04fec0461c", "9e5bba89d30c465ead00c34eaaf08aa2", "4faa4b976bb44222a98551dd6750b73b", "ba6e991d86384a1c8af153979e399b79", "fe584df65084482bb6e2426165ffc54b", "c270f38454eb46c7a28356d08ceeb3e5", "e40283c94be748e5abff3aaf1c7f9103", "06d05db52cf04d8691ef57e0f3f5cb0b", "b757b7c2931d45729dc98d9cb70f4d44", "2650ae4dc3244d52b7e89bdf86d32756", "128754cc00d54dd2a7be1f773e7b4381", "3c430e391cab476686272b1e0dd83b6f", "64979ef0a55b4be0b0a6eb7f5f9f72c7", "3dbbcb85d971465b80cbab1adec520e4", "cbef354a31014fe89f6f9e1be77dc61e", "7b96b202491442bb8e99f3fa76648315", "cec45986ef4d48118329abe5a02e5036", "724ec2c0413f4400b87cfda5461e3fa8", "10cd252a545349f6b9273a53d70b2c97", "a8da3221f6604221811c98f4cceb7426", "33d2398ae2ab42818f27579d02e197fb", "0f0e22f76c00446dabd6d3fd2503d8b3", "34fff5c5cba94e04a3249c4a5fa0ff5f", "f3810f8ef5064f578d48372f32b0fae8", "111e7f5b4c48484993c7c08812536b3e", "b72a8eb375b54a2b9a94da2701e2439a", "e00034097e33439f92dae5dabb87cfc5", "c0a360ba74d149818a2e09b996a0cb83", "ebd85e4db53743b48f81b0232f787b99", "5365bcf78d814b91ad5993eb56d7b330", "7b9a3e4875e14f98bb33d93a03f001cb", "8ae1e123c0fd412eb41d55276a675b88", "6f3c0db52ffb44168dc366cc67f51d49", "f8e94aca23fc43728d115b92f91b2e25", "8d6340794086472793464c3daa61572f", "0de9cd8143ed4cef808ec54f87106b11", "e4d6a6b9bca74e77bb076c4fcdad89ba", "18632e6bb93b4ee9b001735daa9ce0c7", "4a7e5af95cd24fa0b09b4a5ea4c01a86", "4e26d4fecc0d4c69a7722e9eee9f25c1", "1c4cab6ea6384880ad9c094fbc6fc6cb", "0804bb5077c544e4b4a6ba9d60bab3ae", "61e9dc1df228415e85f4757db1a3883d", "83e72191791f4f04833a2f4b255a55ce", "a274bb71852c4edb8f13a6854c1d7617", "ea98db8cf9184a86845108f85c19c682", "4b7207e8d3b147a39e2728f9382511bd", "7640109243814d00a39399bbeba9ceca", "7e134653143e4c9e91d032ba45ec4fe2", "1cb801b3da7449cda72d596a430e85e0", "57a9d35a016b4effafd8d7533d247bca", "019b32f16e624bcc931aa024ca7de006", "1b2128b614814a528290acd51467dd98", "d0cee0fc7b1f44f69a4c779a1a77e9f7", "1b353a05a90947b8b6d96215a8abb5a4", "5c2f0bda172e4b76aa99e72ca94a6c76", "50f8dd547f934a6d83e1ce2124e3ff24", "35282becfce342c4aa33c17597be04db", "5ca82ace58e24c2e9854222c03dd3e20", "d4ecd0747a6e4e809b512de677908527", "415581c36bc243729b854b9ac8c546c2", "3cd4e3d6f382498a947d295fcdf70bb1", "6135b3b8088746d4b124264c15e79ad4", "42165398d238413c8dbb1d46d0696e4b", "12ff800f1ba44cd3a80f821e9158cfb5", "580cd769354445179c72d90b90ec07da", "3f711ca5aa04466ebd48738440f44722", "684a533a93ff49caa702928e442ce8b6", "c67e7be0ea31464183192d05bc9692ef", "b56d05b2d80644c5bd6174389d00a236", "a1b0fce1979848b99ab861f916d92677", "b8df4e4c63ef4c50a4e18671c5859087", "5c34d624ec434c5fb09be4a223f6d8f5", "80f2f2df05184b18b1ab3352e0e79767", "7630c75ec1964cc19074b0965407522c", "7934f4c7e8144106a80b654d851b18ab", "300fb53416b3400f8e0358352ebb61b9", "a35c2dcbc4d24e91b423a67b2bda74fd", "9847d4dac3f94f98a00314ade94b98f2", "998472b34bee4bc59f31ee73a02a1ce4", "a29f6749ed6c44d390d28fd38a367c95", "02651bec99d146d79acaf7b6fe766fa3", "4bc05a7ec5d6412995b31a72c102b745", "4d15ac2c697f412c9674d02848d498f5", "a33e0c60ed46456ba7e66aa8dd039b56", "39c4553b60d94b988a858a74f11d95b2", "5f2392b1164844ee8fd2d2e07f14cce5", "8c89f38f40ad4d86b3c676ff8188a448" ] }, "id": "QmUBVEnvCDJv", "outputId": "a452a2d6-7061-4679-82f3-f6d3730effdd" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n", "🦥 Unsloth Zoo will now patch everything to make training faster!\n", "Unsloth: You selected full finetuning support, but 4bit / 8bit is enabled - disabling LoRA / QLoRA.\n", "==((====))== Unsloth 2026.1.4: Fast Qwen3 patching. Transformers: 4.56.2.\n", " \\\\ /| Tesla T4. Num GPUs = 1. Max memory: 14.741 GB. Platform: Linux.\n", "O^O/ \\_/ \\ Torch: 2.9.0+cu126. CUDA: 7.5. CUDA Toolkit: 12.6. Triton: 3.5.0\n", "\\ / Bfloat16 = FALSE. FA [Xformers = 0.0.33.post1. FA2 = False]\n", " \"-____-\" Free license: http://github.com/unslothai/unsloth\n", "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n", "Unsloth: Float16 full finetuning uses more memory since we upcast weights to float32.\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ "model.safetensors: 0%| | 0.00/3.44G [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "81a2175c450b41539f986b7b270e2ed1" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "generation_config.json: 0%| | 0.00/237 [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "edd0f0631d214a9aaf411c04fec0461c" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "tokenizer_config.json: 0.00B [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "3c430e391cab476686272b1e0dd83b6f" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "vocab.json: 0.00B [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "34fff5c5cba94e04a3249c4a5fa0ff5f" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "merges.txt: 0.00B [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "f8e94aca23fc43728d115b92f91b2e25" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "tokenizer.json: 0%| | 0.00/11.4M [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "a274bb71852c4edb8f13a6854c1d7617" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "added_tokens.json: 0%| | 0.00/707 [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "5c2f0bda172e4b76aa99e72ca94a6c76" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "special_tokens_map.json: 0%| | 0.00/614 [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "3f711ca5aa04466ebd48738440f44722" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "chat_template.jinja: 0.00B [00:00, ?B/s]" ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "a35c2dcbc4d24e91b423a67b2bda74fd" } }, "metadata": {} }, { "output_type": "stream", "name": "stderr", "text": [ "`torch_dtype` is deprecated! Use `dtype` instead!\n" ] }, { "output_type": "stream", "name": "stdout", "text": [ "Unsloth: Applying QAT to mitigate quantization degradation\n" ] } ], "source": [ "from unsloth import FastLanguageModel\n", "import torch\n", "\n", "# Models supported for Phone Deployment\n", "fourbit_models = [\n", " \"unsloth/Qwen3-4B\", # Any Qwen3 model like 0.6B, 4B, 8B, 32B\n", " \"unsloth/Qwen3-32B\",\n", " \"unsloth/Llama-3.1-8B-Instruct\", # Llama 3 models work\n", " \"unsloth/Llama-3.3-70B-Instruct\",\n", " \"unsloth/gemma-3-270m-it\", # Gemma 3 models work\n", " \"unsloth/gemma-3-27b-it\",\n", " \"unsloth/Qwen2.5-7B-Instruct\", # And more models!\n", " \"unsloth/Phi-4-mini-instruct\",\n", "] # More models at https://huggingface.co/unsloth\n", "\n", "model, tokenizer = FastLanguageModel.from_pretrained(\n", " model_name = \"unsloth/Qwen3-1.7B\",\n", " max_seq_length = 1024,\n", " full_finetuning = True,\n", " qat_scheme = \"phone-deployment\", # Flag for phone deployment\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "vITh0KVJ10qX" }, "source": [ "\n", "### Data Prep\n", "Qwen3 has both reasoning and a non reasoning mode. So, we should use 2 datasets:\n", "\n", "1. We use the [Open Math Reasoning]() dataset which was used to win the [AIMO](https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2/leaderboard) (AI Mathematical Olympiad - Progress Prize 2) challenge! We sample 10% of verifiable reasoning traces that used DeepSeek R1, and whicht got > 95% accuracy.\n", "\n", "2. We also leverage [Maxime Labonne's FineTome-100k](https://huggingface.co/datasets/mlabonne/FineTome-100k) dataset in ShareGPT style. But we need to convert it to HuggingFace's normal multiturn format as well." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "5kyTw2n1edte" }, "outputs": [], "source": [ "from datasets import load_dataset\n", "reasoning_dataset = load_dataset(\"unsloth/OpenMathReasoning-mini\", split = \"cot\")\n", "non_reasoning_dataset = load_dataset(\"mlabonne/FineTome-100k\", split = \"train\")" ] }, { "cell_type": "markdown", "metadata": { "id": "PTZICZtie3lQ" }, "source": [ "Let's see the structure of both datasets:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "DjgH3lt0e2Sz" }, "outputs": [], "source": [ "reasoning_dataset" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "_zoaygOAe3I2" }, "outputs": [], "source": [ "non_reasoning_dataset" ] }, { "cell_type": "markdown", "metadata": { "id": "YX8H3urDe00l" }, "source": [ "We now convert the reasoning dataset into conversational format:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "LjY75GoYUCB8" }, "outputs": [], "source": [ "def generate_conversation(examples):\n", " problems = examples[\"problem\"]\n", " solutions = examples[\"generated_solution\"]\n", " conversations = []\n", " for problem, solution in zip(problems, solutions):\n", " conversations.append([\n", " {\"role\" : \"user\", \"content\" : problem},\n", " {\"role\" : \"assistant\", \"content\" : solution},\n", " ])\n", " return { \"conversations\": conversations, }" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "gbh19fTOfHDB" }, "outputs": [], "source": [ "reasoning_conversations = tokenizer.apply_chat_template(\n", " list(reasoning_dataset.map(generate_conversation, batched = True)[\"conversations\"]),\n", " tokenize = False,\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "XTexROzQfJn5" }, "source": [ "Let's see the first transformed row:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "mkj4c6NrfIz3" }, "outputs": [], "source": [ "reasoning_conversations[0]" ] }, { "cell_type": "markdown", "metadata": { "id": "5OMhyEXkfM5e" }, "source": [ "Next we take the non reasoning dataset and convert it to conversational format as well.\n", "\n", "We have to use Unsloth's `standardize_sharegpt` function to fix up the format of the dataset first." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "nXBFaeQHfSxp" }, "outputs": [], "source": [ "from unsloth.chat_templates import standardize_sharegpt\n", "dataset = standardize_sharegpt(non_reasoning_dataset)\n", "\n", "non_reasoning_conversations = tokenizer.apply_chat_template(\n", " list(dataset[\"conversations\"]),\n", " tokenize = False,\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "Q9FcosGvfdNr" }, "source": [ "Let's see the first row" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "pb0hbEekfeqf" }, "outputs": [], "source": [ "non_reasoning_conversations[0]" ] }, { "cell_type": "markdown", "metadata": { "id": "c_0L18QMfot4" }, "source": [ "Now let's see how long both datasets are:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "unDFuUq1foWj" }, "outputs": [], "source": [ "print(len(reasoning_conversations))\n", "print(len(non_reasoning_conversations))" ] }, { "cell_type": "markdown", "metadata": { "id": "dgknnOf7fn3e" }, "source": [ "The non reasoning dataset is much longer. Let's assume we want the model to retain some reasoning capabilities, but we specifically want a chat model.\n", "\n", "Let's define a ratio of chat only data. The goal is to define some mixture of both sets of data.\n", "\n", "Let's select 75% reasoning and 25% chat based:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "_szfriCBgCkU" }, "outputs": [], "source": [ "chat_percentage = 0.25" ] }, { "cell_type": "markdown", "metadata": { "id": "DANuEJA7gL58" }, "source": [ "Let's sample the reasoning dataset by 75% (or whatever is 100% - chat_percentage)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "7-e0KO9GgFy3" }, "outputs": [], "source": [ "import pandas as pd\n", "non_reasoning_subset = pd.Series(non_reasoning_conversations)\n", "non_reasoning_subset = non_reasoning_subset.sample(\n", " int(len(reasoning_conversations)*(chat_percentage/(1 - chat_percentage))),\n", " random_state = 2407,\n", ")\n", "print(len(reasoning_conversations))\n", "print(len(non_reasoning_subset))\n", "print(len(non_reasoning_subset) / (len(non_reasoning_subset) + len(reasoning_conversations)))" ] }, { "cell_type": "markdown", "metadata": { "id": "qR-4prS_gVel" }, "source": [ "Finally combine both datasets:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "jfV47_SXgXH4" }, "outputs": [], "source": [ "data = pd.concat([\n", " pd.Series(reasoning_conversations),\n", " pd.Series(non_reasoning_subset)\n", "])\n", "data.name = \"text\"\n", "\n", "from datasets import Dataset\n", "combined_dataset = Dataset.from_pandas(pd.DataFrame(data))\n", "combined_dataset = combined_dataset.shuffle(seed = 3407)" ] }, { "cell_type": "markdown", "metadata": { "id": "idAEIeSQ3xdS" }, "source": [ "\n", "### Train the model\n", "Now let's train our model. We do 60 steps to speed things up, but you can set `num_train_epochs=1` for a full run, and turn off `max_steps=None`." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "95_Nn-89DhsL" }, "outputs": [], "source": [ "from trl import SFTTrainer, SFTConfig\n", "trainer = SFTTrainer(\n", " model = model,\n", " tokenizer = tokenizer,\n", " train_dataset = combined_dataset,\n", " eval_dataset = None, # Can set up evaluation!\n", " args = SFTConfig(\n", " dataset_text_field = \"text\",\n", " per_device_train_batch_size = 2,\n", " gradient_accumulation_steps = 4, # Use GA to mimic batch size!\n", " warmup_steps = 5,\n", " # num_train_epochs = 1, # Set this for 1 full training run.\n", " max_steps = 100,\n", " learning_rate = 5e-5,\n", " logging_steps = 1,\n", " optim = \"adamw_8bit\",\n", " weight_decay = 0.001,\n", " lr_scheduler_type = \"linear\",\n", " seed = 3407,\n", " report_to = \"none\", # Use TrackIO/WandB etc\n", " ),\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "id": "2ejIt2xSNKKp" }, "outputs": [], "source": [ "# @title Show current memory stats\n", "gpu_stats = torch.cuda.get_device_properties(0)\n", "start_gpu_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", "max_memory = round(gpu_stats.total_memory / 1024 / 1024 / 1024, 3)\n", "print(f\"GPU = {gpu_stats.name}. Max memory = {max_memory} GB.\")\n", "print(f\"{start_gpu_memory} GB of memory reserved.\")" ] }, { "cell_type": "markdown", "metadata": { "id": "M9fa371ShyhB" }, "source": [ "Let's train the model! To resume a training run, set `trainer.train(resume_from_checkpoint = True)`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "yqxqAZ7KJ4oL" }, "outputs": [], "source": [ "trainer_stats = trainer.train()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "id": "pCqnaKmlO1U9" }, "outputs": [], "source": [ "# @title Show final memory and time stats\n", "used_memory = round(torch.cuda.max_memory_reserved() / 1024 / 1024 / 1024, 3)\n", "used_memory_for_lora = round(used_memory - start_gpu_memory, 3)\n", "used_percentage = round(used_memory / max_memory * 100, 3)\n", "lora_percentage = round(used_memory_for_lora / max_memory * 100, 3)\n", "print(f\"{trainer_stats.metrics['train_runtime']} seconds used for training.\")\n", "print(\n", " f\"{round(trainer_stats.metrics['train_runtime']/60, 2)} minutes used for training.\"\n", ")\n", "print(f\"Peak reserved memory = {used_memory} GB.\")\n", "print(f\"Peak reserved memory for training = {used_memory_for_lora} GB.\")\n", "print(f\"Peak reserved memory % of max memory = {used_percentage} %.\")\n", "print(f\"Peak reserved memory for training % of max memory = {lora_percentage} %.\")" ] }, { "cell_type": "markdown", "metadata": { "id": "uMuVrWbjAzhc" }, "source": [ "\n", "### Saving, loading finetuned models\n", "\n", "To save the model for phone deployment, we first save the model via `save_pretrained_torchao`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "upcOlWe7A1vc" }, "outputs": [], "source": [ "model.save_pretrained_torchao(\"phone_model\", tokenizer = tokenizer)" ] }, { "cell_type": "markdown", "metadata": { "id": "HZR2GeIDO8FJ" }, "source": [ "We then use Executorch's Qwen3 conversion process" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "S0x9VRV0O_rV", "outputId": "be9de57f-792e-4840-c084-ae1f5136d7ba" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Skipping import of cpp extensions due to incompatible torch version 2.9.0+cu126 for torchao version 0.14.0 Please see GitHub issue #2919 for more info\n", "I tokenizers:regex.cpp:27] Registering override fallback regex\n", "