diff --git "a/Hammer_0_5B_task_CPU_GPU.ipynb" "b/Hammer_0_5B_task_CPU_GPU.ipynb" new file mode 100644--- /dev/null +++ "b/Hammer_0_5B_task_CPU_GPU.ipynb" @@ -0,0 +1,1801 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "gpuType": "L4" + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qaj9T-0yEQPd", + "outputId": "4638c732-b689-4f7d-c125-cecb80b77452" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Cloning into 'ai-edge-torch'...\n", + "remote: Enumerating objects: 6174, done.\u001b[K\n", + "remote: Counting objects: 100% (707/707), done.\u001b[K\n", + "remote: Compressing objects: 100% (194/194), done.\u001b[K\n", + "remote: Total 6174 (delta 613), reused 525 (delta 512), pack-reused 5467 (from 1)\u001b[K\n", + "Receiving objects: 100% (6174/6174), 11.90 MiB | 18.41 MiB/s, done.\n", + "Resolving deltas: 100% (4430/4430), done.\n" + ] + } + ], + "source": [ + "!git clone https://github.com/google-ai-edge/ai-edge-torch.git" + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install tensorflow==2.19.0" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "oPOsX9qaEktY", + "outputId": "23765ef6-513e-45a7-f08e-1309aa682264" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting tensorflow==2.19.0\n", + " Downloading tensorflow-2.19.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.1 kB)\n", + "Requirement already satisfied: absl-py>=1.0.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (1.4.0)\n", + "Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (1.6.3)\n", + "Requirement already satisfied: flatbuffers>=24.3.25 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (25.2.10)\n", + "Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (0.6.0)\n", + "Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (0.2.0)\n", + "Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (18.1.1)\n", + "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (3.4.0)\n", + "Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (24.2)\n", + "Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.3 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (5.29.5)\n", + "Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (2.32.3)\n", + "Requirement already satisfied: setuptools in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (75.2.0)\n", + "Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (1.17.0)\n", + "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (3.1.0)\n", + "Requirement already satisfied: typing-extensions>=3.6.6 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (4.14.1)\n", + "Requirement already satisfied: wrapt>=1.11.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (1.17.2)\n", + "Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (1.73.1)\n", + "Collecting tensorboard~=2.19.0 (from tensorflow==2.19.0)\n", + " Downloading tensorboard-2.19.0-py3-none-any.whl.metadata (1.8 kB)\n", + "Requirement already satisfied: keras>=3.5.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (3.8.0)\n", + "Requirement already satisfied: numpy<2.2.0,>=1.26.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (2.0.2)\n", + "Requirement already satisfied: h5py>=3.11.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (3.14.0)\n", + "Collecting ml-dtypes<1.0.0,>=0.5.1 (from tensorflow==2.19.0)\n", + " Downloading ml_dtypes-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (21 kB)\n", + "Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /usr/local/lib/python3.11/dist-packages (from tensorflow==2.19.0) (0.37.1)\n", + "Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.11/dist-packages (from astunparse>=1.6.0->tensorflow==2.19.0) (0.45.1)\n", + "Requirement already satisfied: rich in /usr/local/lib/python3.11/dist-packages (from keras>=3.5.0->tensorflow==2.19.0) (13.9.4)\n", + "Requirement already satisfied: namex in /usr/local/lib/python3.11/dist-packages (from keras>=3.5.0->tensorflow==2.19.0) (0.1.0)\n", + "Requirement already satisfied: optree in /usr/local/lib/python3.11/dist-packages (from keras>=3.5.0->tensorflow==2.19.0) (0.16.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tensorflow==2.19.0) (3.4.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tensorflow==2.19.0) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tensorflow==2.19.0) (2.4.0)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tensorflow==2.19.0) (2025.6.15)\n", + "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.11/dist-packages (from tensorboard~=2.19.0->tensorflow==2.19.0) (3.8.2)\n", + "Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /usr/local/lib/python3.11/dist-packages (from tensorboard~=2.19.0->tensorflow==2.19.0) (0.7.2)\n", + "Requirement already satisfied: werkzeug>=1.0.1 in /usr/local/lib/python3.11/dist-packages (from tensorboard~=2.19.0->tensorflow==2.19.0) (3.1.3)\n", + "Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.11/dist-packages (from werkzeug>=1.0.1->tensorboard~=2.19.0->tensorflow==2.19.0) (3.0.2)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.11/dist-packages (from rich->keras>=3.5.0->tensorflow==2.19.0) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.11/dist-packages (from rich->keras>=3.5.0->tensorflow==2.19.0) (2.19.2)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.11/dist-packages (from markdown-it-py>=2.2.0->rich->keras>=3.5.0->tensorflow==2.19.0) (0.1.2)\n", + "Downloading tensorflow-2.19.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (644.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m644.9/644.9 MB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading ml_dtypes-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.7/4.7 MB\u001b[0m \u001b[31m119.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading tensorboard-2.19.0-py3-none-any.whl (5.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.5/5.5 MB\u001b[0m \u001b[31m130.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: ml-dtypes, tensorboard, tensorflow\n", + " Attempting uninstall: ml-dtypes\n", + " Found existing installation: ml-dtypes 0.4.1\n", + " Uninstalling ml-dtypes-0.4.1:\n", + " Successfully uninstalled ml-dtypes-0.4.1\n", + " Attempting uninstall: tensorboard\n", + " Found existing installation: tensorboard 2.18.0\n", + " Uninstalling tensorboard-2.18.0:\n", + " Successfully uninstalled tensorboard-2.18.0\n", + " Attempting uninstall: tensorflow\n", + " Found existing installation: tensorflow 2.18.0\n", + " Uninstalling tensorflow-2.18.0:\n", + " Successfully uninstalled tensorflow-2.18.0\n", + "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", + "tf-keras 2.18.0 requires tensorflow<2.19,>=2.18, but you have tensorflow 2.19.0 which is incompatible.\n", + "tensorflow-text 2.18.1 requires tensorflow<2.19,>=2.18.0, but you have tensorflow 2.19.0 which is incompatible.\n", + "tensorflow-decision-forests 1.11.0 requires tensorflow==2.18.0, but you have tensorflow 2.19.0 which is incompatible.\u001b[0m\u001b[31m\n", + "\u001b[0mSuccessfully installed ml-dtypes-0.5.1 tensorboard-2.19.0 tensorflow-2.19.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip list" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_VMnnza5EnKy", + "outputId": "b43b5a94-d51a-4984-e82f-e6426e1338d0" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Package Version\n", + "------------------------------------- ------------------\n", + "absl-py 1.4.0\n", + "accelerate 1.8.1\n", + "aiofiles 24.1.0\n", + "aiohappyeyeballs 2.6.1\n", + "aiohttp 3.11.15\n", + "aiosignal 1.4.0\n", + "alabaster 1.0.0\n", + "albucore 0.0.24\n", + "albumentations 2.0.8\n", + "ale-py 0.11.1\n", + "altair 5.5.0\n", + "annotated-types 0.7.0\n", + "antlr4-python3-runtime 4.9.3\n", + "anyio 4.9.0\n", + "argon2-cffi 25.1.0\n", + "argon2-cffi-bindings 21.2.0\n", + "array_record 0.7.2\n", + "arviz 0.21.0\n", + "astropy 7.1.0\n", + "astropy-iers-data 0.2025.7.7.0.39.39\n", + "astunparse 1.6.3\n", + "atpublic 5.1\n", + "attrs 25.3.0\n", + "audioread 3.0.1\n", + "autograd 1.8.0\n", + "babel 2.17.0\n", + "backcall 0.2.0\n", + "backports.tarfile 1.2.0\n", + "beautifulsoup4 4.13.4\n", + "betterproto 2.0.0b6\n", + "bigframes 2.8.0\n", + "bigquery-magics 0.9.0\n", + "bleach 6.2.0\n", + "blinker 1.9.0\n", + "blis 1.3.0\n", + "blobfile 3.0.0\n", + "blosc2 3.5.1\n", + "bokeh 3.7.3\n", + "Bottleneck 1.4.2\n", + "bqplot 0.12.45\n", + "branca 0.8.1\n", + "build 1.2.2.post1\n", + "CacheControl 0.14.3\n", + "cachetools 5.5.2\n", + "catalogue 2.0.10\n", + "certifi 2025.6.15\n", + "cffi 1.17.1\n", + "chardet 5.2.0\n", + "charset-normalizer 3.4.2\n", + "chex 0.1.89\n", + "clarabel 0.11.1\n", + "click 8.2.1\n", + "cloudpathlib 0.21.1\n", + "cloudpickle 3.1.1\n", + "cmake 3.31.6\n", + "cmdstanpy 1.2.5\n", + "colorcet 3.1.0\n", + "colorlover 0.3.0\n", + "colour 0.1.5\n", + "community 1.0.0b1\n", + "confection 0.1.5\n", + "cons 0.4.6\n", + "contourpy 1.3.2\n", + "cramjam 2.10.0\n", + "cryptography 43.0.3\n", + "cuda-python 12.6.2.post1\n", + "cudf-cu12 25.2.1\n", + "cudf-polars-cu12 25.2.2\n", + "cufflinks 0.17.3\n", + "cuml-cu12 25.2.1\n", + "cupy-cuda12x 13.3.0\n", + "curl_cffi 0.11.4\n", + "cuvs-cu12 25.2.1\n", + "cvxopt 1.3.2\n", + "cvxpy 1.6.6\n", + "cycler 0.12.1\n", + "cyipopt 1.5.0\n", + "cymem 2.0.11\n", + "Cython 3.0.12\n", + "dask 2024.12.1\n", + "dask-cuda 25.2.0\n", + "dask-cudf-cu12 25.2.2\n", + "dask-expr 1.1.21\n", + "dataproc-spark-connect 0.8.1\n", + "datascience 0.17.6\n", + "datasets 2.14.4\n", + "db-dtypes 1.4.3\n", + "dbus-python 1.2.18\n", + "debugpy 1.8.0\n", + "decorator 4.4.2\n", + "defusedxml 0.7.1\n", + "diffusers 0.34.0\n", + "dill 0.3.7\n", + "distributed 2024.12.1\n", + "distributed-ucxx-cu12 0.42.0\n", + "distro 1.9.0\n", + "dlib 19.24.6\n", + "dm-tree 0.1.9\n", + "docstring_parser 0.16\n", + "docutils 0.21.2\n", + "dopamine_rl 4.1.2\n", + "duckdb 1.2.2\n", + "earthengine-api 1.5.22\n", + "easydict 1.13\n", + "editdistance 0.8.1\n", + "eerepr 0.1.2\n", + "einops 0.8.1\n", + "en_core_web_sm 3.8.0\n", + "entrypoints 0.4\n", + "et_xmlfile 2.0.0\n", + "etils 1.12.2\n", + "etuples 0.3.9\n", + "Farama-Notifications 0.0.4\n", + "fastai 2.7.19\n", + "fastapi 0.115.14\n", + "fastcore 1.7.29\n", + "fastdownload 0.0.7\n", + "fastjsonschema 2.21.1\n", + "fastprogress 1.0.3\n", + "fastrlock 0.8.3\n", + "ffmpy 0.6.0\n", + "filelock 3.18.0\n", + "firebase-admin 6.9.0\n", + "Flask 3.1.1\n", + "flatbuffers 25.2.10\n", + "flax 0.10.6\n", + "folium 0.19.7\n", + "fonttools 4.58.5\n", + "frozendict 2.4.6\n", + "frozenlist 1.7.0\n", + "fsspec 2025.3.2\n", + "future 1.0.0\n", + "gast 0.6.0\n", + "gcsfs 2025.3.2\n", + "GDAL 3.8.4\n", + "gdown 5.2.0\n", + "geemap 0.35.3\n", + "geocoder 1.38.1\n", + "geographiclib 2.0\n", + "geopandas 1.0.1\n", + "geopy 2.4.1\n", + "gin-config 0.5.0\n", + "gitdb 4.0.12\n", + "GitPython 3.1.44\n", + "glob2 0.7\n", + "google 2.0.3\n", + "google-ai-generativelanguage 0.6.15\n", + "google-api-core 2.25.1\n", + "google-api-python-client 2.175.0\n", + "google-auth 2.38.0\n", + "google-auth-httplib2 0.2.0\n", + "google-auth-oauthlib 1.2.2\n", + "google-cloud-aiplatform 1.101.0\n", + "google-cloud-bigquery 3.34.0\n", + "google-cloud-bigquery-connection 1.18.3\n", + "google-cloud-bigquery-storage 2.32.0\n", + "google-cloud-core 2.4.3\n", + "google-cloud-dataproc 5.21.0\n", + "google-cloud-datastore 2.21.0\n", + "google-cloud-firestore 2.21.0\n", + "google-cloud-functions 1.20.4\n", + "google-cloud-iam 2.19.1\n", + "google-cloud-language 2.17.2\n", + "google-cloud-resource-manager 1.14.2\n", + "google-cloud-spanner 3.55.0\n", + "google-cloud-storage 2.19.0\n", + "google-cloud-translate 3.21.1\n", + "google-colab 1.0.0\n", + "google-crc32c 1.7.1\n", + "google-genai 1.24.0\n", + "google-generativeai 0.8.5\n", + "google-pasta 0.2.0\n", + "google-resumable-media 2.7.2\n", + "googleapis-common-protos 1.70.0\n", + "googledrivedownloader 1.1.0\n", + "gradio 5.31.0\n", + "gradio_client 1.10.1\n", + "graphviz 0.21\n", + "greenlet 3.2.3\n", + "groovy 0.1.2\n", + "grpc-google-iam-v1 0.14.2\n", + "grpc-interceptor 0.15.4\n", + "grpcio 1.73.1\n", + "grpcio-status 1.71.2\n", + "grpclib 0.4.8\n", + "gspread 6.2.1\n", + "gspread-dataframe 4.0.0\n", + "gym 0.25.2\n", + "gym-notices 0.0.8\n", + "gymnasium 1.2.0\n", + "h11 0.16.0\n", + "h2 4.2.0\n", + "h5netcdf 1.6.3\n", + "h5py 3.14.0\n", + "hdbscan 0.8.40\n", + "hf_transfer 0.1.9\n", + "hf-xet 1.1.5\n", + "highspy 1.11.0\n", + "holidays 0.75\n", + "holoviews 1.21.0\n", + "hpack 4.1.0\n", + "html5lib 1.1\n", + "httpcore 1.0.9\n", + "httpimport 1.4.1\n", + "httplib2 0.22.0\n", + "httpx 0.28.1\n", + "huggingface-hub 0.33.2\n", + "humanize 4.12.3\n", + "hyperframe 6.1.0\n", + "hyperopt 0.2.7\n", + "ibis-framework 9.5.0\n", + "idna 3.10\n", + "imageio 2.37.0\n", + "imageio-ffmpeg 0.6.0\n", + "imagesize 1.4.1\n", + "imbalanced-learn 0.13.0\n", + "immutabledict 4.2.1\n", + "importlib_metadata 8.7.0\n", + "importlib_resources 6.5.2\n", + "imutils 0.5.4\n", + "inflect 7.5.0\n", + "iniconfig 2.1.0\n", + "intel-cmplr-lib-ur 2025.2.0\n", + "intel-openmp 2025.2.0\n", + "ipyevents 2.0.2\n", + "ipyfilechooser 0.6.0\n", + "ipykernel 6.17.1\n", + "ipyleaflet 0.20.0\n", + "ipyparallel 8.8.0\n", + "ipython 7.34.0\n", + "ipython-genutils 0.2.0\n", + "ipython-sql 0.5.0\n", + "ipytree 0.2.2\n", + "ipywidgets 7.7.1\n", + "itsdangerous 2.2.0\n", + "jaraco.classes 3.4.0\n", + "jaraco.context 6.0.1\n", + "jaraco.functools 4.2.1\n", + "jax 0.5.2\n", + "jax-cuda12-pjrt 0.5.1\n", + "jax-cuda12-plugin 0.5.1\n", + "jaxlib 0.5.1\n", + "jeepney 0.9.0\n", + "jieba 0.42.1\n", + "Jinja2 3.1.6\n", + "jiter 0.10.0\n", + "joblib 1.5.1\n", + "jsonpatch 1.33\n", + "jsonpickle 4.1.1\n", + "jsonpointer 3.0.0\n", + "jsonschema 4.24.0\n", + "jsonschema-specifications 2025.4.1\n", + "jupyter-client 6.1.12\n", + "jupyter-console 6.1.0\n", + "jupyter_core 5.8.1\n", + "jupyter_kernel_gateway 2.5.2\n", + "jupyter-leaflet 0.20.0\n", + "jupyter-server 1.16.0\n", + "jupyterlab_pygments 0.3.0\n", + "jupyterlab_widgets 3.0.15\n", + "jupytext 1.17.2\n", + "kaggle 1.7.4.5\n", + "kagglehub 0.3.12\n", + "keras 3.8.0\n", + "keras-hub 0.18.1\n", + "keras-nlp 0.18.1\n", + "keyring 25.6.0\n", + "keyrings.google-artifactregistry-auth 1.1.2\n", + "kiwisolver 1.4.8\n", + "langchain 0.3.26\n", + "langchain-core 0.3.68\n", + "langchain-text-splitters 0.3.8\n", + "langcodes 3.5.0\n", + "langsmith 0.4.4\n", + "language_data 1.3.0\n", + "launchpadlib 1.10.16\n", + "lazr.restfulclient 0.14.4\n", + "lazr.uri 1.0.6\n", + "lazy_loader 0.4\n", + "libclang 18.1.1\n", + "libcudf-cu12 25.2.1\n", + "libcugraph-cu12 25.2.0\n", + "libcuml-cu12 25.2.1\n", + "libcuvs-cu12 25.2.1\n", + "libkvikio-cu12 25.2.1\n", + "libpysal 4.13.0\n", + "libraft-cu12 25.2.0\n", + "librosa 0.11.0\n", + "libucx-cu12 1.18.1\n", + "libucxx-cu12 0.42.0\n", + "lightgbm 4.5.0\n", + "linkify-it-py 2.0.3\n", + "llvmlite 0.43.0\n", + "locket 1.0.0\n", + "logical-unification 0.4.6\n", + "lxml 5.4.0\n", + "Mako 1.1.3\n", + "marisa-trie 1.2.1\n", + "Markdown 3.8.2\n", + "markdown-it-py 3.0.0\n", + "MarkupSafe 3.0.2\n", + "matplotlib 3.10.0\n", + "matplotlib-inline 0.1.7\n", + "matplotlib-venn 1.1.2\n", + "mdit-py-plugins 0.4.2\n", + "mdurl 0.1.2\n", + "miniKanren 1.0.3\n", + "missingno 0.5.2\n", + "mistune 3.1.3\n", + "mizani 0.13.5\n", + "mkl 2025.0.1\n", + "ml_dtypes 0.5.1\n", + "mlxtend 0.23.4\n", + "more-itertools 10.7.0\n", + "moviepy 1.0.3\n", + "mpmath 1.3.0\n", + "msgpack 1.1.1\n", + "multidict 6.6.3\n", + "multipledispatch 1.0.0\n", + "multiprocess 0.70.15\n", + "multitasking 0.0.11\n", + "murmurhash 1.0.13\n", + "music21 9.3.0\n", + "namex 0.1.0\n", + "narwhals 1.45.0\n", + "natsort 8.4.0\n", + "nbclassic 1.3.1\n", + "nbclient 0.10.2\n", + "nbconvert 7.16.6\n", + "nbformat 5.10.4\n", + "ndindex 1.10.0\n", + "nest-asyncio 1.6.0\n", + "networkx 3.5\n", + "nibabel 5.3.2\n", + "nltk 3.9.1\n", + "notebook 6.5.7\n", + "notebook_shim 0.2.4\n", + "numba 0.60.0\n", + "numba-cuda 0.2.0\n", + "numexpr 2.11.0\n", + "numpy 2.0.2\n", + "nvidia-cublas-cu12 12.5.3.2\n", + "nvidia-cuda-cupti-cu12 12.5.82\n", + "nvidia-cuda-nvcc-cu12 12.5.82\n", + "nvidia-cuda-nvrtc-cu12 12.5.82\n", + "nvidia-cuda-runtime-cu12 12.5.82\n", + "nvidia-cudnn-cu12 9.3.0.75\n", + "nvidia-cufft-cu12 11.2.3.61\n", + "nvidia-curand-cu12 10.3.6.82\n", + "nvidia-cusolver-cu12 11.6.3.83\n", + "nvidia-cusparse-cu12 12.5.1.3\n", + "nvidia-cusparselt-cu12 0.6.2\n", + "nvidia-ml-py 12.575.51\n", + "nvidia-nccl-cu12 2.21.5\n", + "nvidia-nvcomp-cu12 4.2.0.11\n", + "nvidia-nvjitlink-cu12 12.5.82\n", + "nvidia-nvtx-cu12 12.4.127\n", + "nvtx 0.2.12\n", + "nx-cugraph-cu12 25.2.0\n", + "oauth2client 4.1.3\n", + "oauthlib 3.3.1\n", + "omegaconf 2.3.0\n", + "openai 1.93.0\n", + "opencv-contrib-python 4.11.0.86\n", + "opencv-python 4.11.0.86\n", + "opencv-python-headless 4.12.0.88\n", + "openpyxl 3.1.5\n", + "opt_einsum 3.4.0\n", + "optax 0.2.5\n", + "optree 0.16.0\n", + "orbax-checkpoint 0.11.16\n", + "orjson 3.10.18\n", + "osqp 1.0.4\n", + "packaging 24.2\n", + "pandas 2.2.2\n", + "pandas-datareader 0.10.0\n", + "pandas-gbq 0.29.1\n", + "pandas-stubs 2.2.2.240909\n", + "pandocfilters 1.5.1\n", + "panel 1.7.2\n", + "param 2.2.1\n", + "parso 0.8.4\n", + "parsy 2.1\n", + "partd 1.4.2\n", + "pathlib 1.0.1\n", + "patsy 1.0.1\n", + "peewee 3.18.1\n", + "peft 0.16.0\n", + "pexpect 4.9.0\n", + "pickleshare 0.7.5\n", + "pillow 11.2.1\n", + "pip 24.1.2\n", + "platformdirs 4.3.8\n", + "plotly 5.24.1\n", + "plotnine 0.14.6\n", + "pluggy 1.6.0\n", + "ply 3.11\n", + "polars 1.21.0\n", + "pooch 1.8.2\n", + "portpicker 1.5.2\n", + "preshed 3.0.10\n", + "prettytable 3.16.0\n", + "proglog 0.1.12\n", + "progressbar2 4.5.0\n", + "prometheus_client 0.22.1\n", + "promise 2.3\n", + "prompt_toolkit 3.0.51\n", + "propcache 0.3.2\n", + "prophet 1.1.7\n", + "proto-plus 1.26.1\n", + "protobuf 5.29.5\n", + "psutil 5.9.5\n", + "psycopg2 2.9.10\n", + "ptyprocess 0.7.0\n", + "py-cpuinfo 9.0.0\n", + "py4j 0.10.9.7\n", + "pyarrow 18.1.0\n", + "pyasn1 0.6.1\n", + "pyasn1_modules 0.4.2\n", + "pycairo 1.28.0\n", + "pycocotools 2.0.10\n", + "pycparser 2.22\n", + "pycryptodomex 3.23.0\n", + "pydantic 2.11.7\n", + "pydantic_core 2.33.2\n", + "pydata-google-auth 1.9.1\n", + "pydot 3.0.4\n", + "pydotplus 2.0.2\n", + "PyDrive 1.3.1\n", + "PyDrive2 1.21.3\n", + "pydub 0.25.1\n", + "pyerfa 2.0.1.5\n", + "pygame 2.6.1\n", + "pygit2 1.18.0\n", + "Pygments 2.19.2\n", + "PyGObject 3.42.0\n", + "PyJWT 2.10.1\n", + "pylibcudf-cu12 25.2.1\n", + "pylibcugraph-cu12 25.2.0\n", + "pylibraft-cu12 25.2.0\n", + "pymc 5.23.0\n", + "pymystem3 0.2.0\n", + "pynndescent 0.5.13\n", + "pynvjitlink-cu12 0.7.0\n", + "pynvml 12.0.0\n", + "pyogrio 0.11.0\n", + "pyomo 6.9.2\n", + "PyOpenGL 3.1.9\n", + "pyOpenSSL 24.2.1\n", + "pyparsing 3.2.3\n", + "pyperclip 1.9.0\n", + "pyproj 3.7.1\n", + "pyproject_hooks 1.2.0\n", + "pyshp 2.3.1\n", + "PySocks 1.7.1\n", + "pyspark 3.5.1\n", + "pytensor 2.31.6\n", + "pytest 8.3.5\n", + "python-apt 0.0.0\n", + "python-box 7.3.2\n", + "python-dateutil 2.9.0.post0\n", + "python-louvain 0.16\n", + "python-multipart 0.0.20\n", + "python-slugify 8.0.4\n", + "python-snappy 0.7.3\n", + "python-utils 3.9.1\n", + "pytz 2025.2\n", + "pyviz_comms 3.0.6\n", + "PyWavelets 1.8.0\n", + "PyYAML 6.0.2\n", + "pyzmq 24.0.1\n", + "raft-dask-cu12 25.2.0\n", + "rapids-dask-dependency 25.2.0\n", + "ratelim 0.1.6\n", + "referencing 0.36.2\n", + "regex 2024.11.6\n", + "requests 2.32.3\n", + "requests-oauthlib 2.0.0\n", + "requests-toolbelt 1.0.0\n", + "requirements-parser 0.9.0\n", + "rich 13.9.4\n", + "rmm-cu12 25.2.0\n", + "roman-numerals-py 3.1.0\n", + "rpds-py 0.26.0\n", + "rpy2 3.5.17\n", + "rsa 4.9.1\n", + "ruff 0.12.2\n", + "safehttpx 0.1.6\n", + "safetensors 0.5.3\n", + "scikit-image 0.25.2\n", + "scikit-learn 1.6.1\n", + "scipy 1.15.3\n", + "scooby 0.10.1\n", + "scs 3.2.7.post2\n", + "seaborn 0.13.2\n", + "SecretStorage 3.3.3\n", + "semantic-version 2.10.0\n", + "Send2Trash 1.8.3\n", + "sentence-transformers 4.1.0\n", + "sentencepiece 0.2.0\n", + "sentry-sdk 2.32.0\n", + "setuptools 75.2.0\n", + "shap 0.48.0\n", + "shapely 2.1.1\n", + "shellingham 1.5.4\n", + "simple-parsing 0.1.7\n", + "simplejson 3.20.1\n", + "simsimd 6.4.10\n", + "six 1.17.0\n", + "sklearn-compat 0.1.3\n", + "sklearn-pandas 2.2.0\n", + "slicer 0.0.8\n", + "smart_open 7.3.0.post1\n", + "smmap 5.0.2\n", + "sniffio 1.3.1\n", + "snowballstemmer 3.0.1\n", + "sortedcontainers 2.4.0\n", + "soundfile 0.13.1\n", + "soupsieve 2.7\n", + "soxr 0.5.0.post1\n", + "spacy 3.8.7\n", + "spacy-legacy 3.0.12\n", + "spacy-loggers 1.0.5\n", + "spanner-graph-notebook 1.1.7\n", + "Sphinx 8.2.3\n", + "sphinxcontrib-applehelp 2.0.0\n", + "sphinxcontrib-devhelp 2.0.0\n", + "sphinxcontrib-htmlhelp 2.1.0\n", + "sphinxcontrib-jsmath 1.0.1\n", + "sphinxcontrib-qthelp 2.0.0\n", + "sphinxcontrib-serializinghtml 2.0.0\n", + "SQLAlchemy 2.0.41\n", + "sqlglot 25.20.2\n", + "sqlparse 0.5.3\n", + "srsly 2.5.1\n", + "stanio 0.5.1\n", + "starlette 0.46.2\n", + "statsmodels 0.14.4\n", + "stringzilla 3.12.5\n", + "stumpy 1.13.0\n", + "sympy 1.13.1\n", + "tables 3.10.2\n", + "tabulate 0.9.0\n", + "tbb 2022.2.0\n", + "tblib 3.1.0\n", + "tcmlib 1.4.0\n", + "tenacity 8.5.0\n", + "tensorboard 2.19.0\n", + "tensorboard-data-server 0.7.2\n", + "tensorflow 2.19.0\n", + "tensorflow-datasets 4.9.9\n", + "tensorflow_decision_forests 1.11.0\n", + "tensorflow-hub 0.16.1\n", + "tensorflow-io-gcs-filesystem 0.37.1\n", + "tensorflow-metadata 1.17.2\n", + "tensorflow-probability 0.25.0\n", + "tensorflow-text 2.18.1\n", + "tensorstore 0.1.74\n", + "termcolor 3.1.0\n", + "terminado 0.18.1\n", + "text-unidecode 1.3\n", + "textblob 0.19.0\n", + "tf_keras 2.18.0\n", + "tf-slim 1.1.0\n", + "thinc 8.3.6\n", + "threadpoolctl 3.6.0\n", + "tifffile 2025.6.11\n", + "tiktoken 0.9.0\n", + "timm 1.0.16\n", + "tinycss2 1.4.0\n", + "tokenizers 0.21.2\n", + "toml 0.10.2\n", + "tomlkit 0.13.3\n", + "toolz 0.12.1\n", + "torch 2.6.0+cu124\n", + "torchao 0.10.0\n", + "torchaudio 2.6.0+cu124\n", + "torchdata 0.11.0\n", + "torchsummary 1.5.1\n", + "torchtune 0.6.1\n", + "torchvision 0.21.0+cu124\n", + "tornado 6.4.2\n", + "tqdm 4.67.1\n", + "traitlets 5.7.1\n", + "traittypes 0.2.1\n", + "transformers 4.53.1\n", + "treelite 4.4.1\n", + "treescope 0.1.9\n", + "triton 3.2.0\n", + "tsfresh 0.21.0\n", + "tweepy 4.15.0\n", + "typeguard 4.4.4\n", + "typer 0.16.0\n", + "types-pytz 2025.2.0.20250516\n", + "types-setuptools 80.9.0.20250529\n", + "typing_extensions 4.14.1\n", + "typing-inspection 0.4.1\n", + "tzdata 2025.2\n", + "tzlocal 5.3.1\n", + "uc-micro-py 1.0.3\n", + "ucx-py-cu12 0.42.0\n", + "ucxx-cu12 0.42.0\n", + "umap-learn 0.5.9.post2\n", + "umf 0.11.0\n", + "uritemplate 4.2.0\n", + "urllib3 2.4.0\n", + "uvicorn 0.35.0\n", + "vega-datasets 0.9.0\n", + "wadllib 1.3.6\n", + "wandb 0.21.0\n", + "wasabi 1.1.3\n", + "wcwidth 0.2.13\n", + "weasel 0.4.1\n", + "webcolors 24.11.1\n", + "webencodings 0.5.1\n", + "websocket-client 1.8.0\n", + "websockets 15.0.1\n", + "Werkzeug 3.1.3\n", + "wheel 0.45.1\n", + "widgetsnbextension 3.6.10\n", + "wordcloud 1.9.4\n", + "wrapt 1.17.2\n", + "wurlitzer 3.1.1\n", + "xarray 2025.3.1\n", + "xarray-einstats 0.9.1\n", + "xgboost 2.1.4\n", + "xlrd 2.0.2\n", + "xxhash 3.5.0\n", + "xyzservices 2025.4.0\n", + "yarl 1.20.1\n", + "ydf 0.12.0\n", + "yellowbrick 1.5\n", + "yfinance 0.2.65\n", + "zict 3.0.0\n", + "zipp 3.23.0\n", + "zstandard 0.23.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install torch-xla2\n", + "!pip install ai_edge_quantizer\n", + "!pip install ai_edge_litert #available latest 0.2.1 and 0.1.0" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "id": "wo7zRFbfEsYT", + "outputId": "1a3acc29-2dce-4bc6-f5af-6494e81bf2b9" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting torch-xla2\n", + " Downloading torch_xla2-0.0.1.dev202412041639-py3-none-any.whl.metadata (2.5 kB)\n", + "Requirement already satisfied: absl-py in /usr/local/lib/python3.11/dist-packages (from torch-xla2) (1.4.0)\n", + "Requirement already satisfied: immutabledict in /usr/local/lib/python3.11/dist-packages (from torch-xla2) (4.2.1)\n", + "Requirement already satisfied: pytest in /usr/local/lib/python3.11/dist-packages (from torch-xla2) (8.3.5)\n", + "Requirement already satisfied: torch>=2.3.0 in /usr/local/lib/python3.11/dist-packages (from torch-xla2) (2.6.0+cu124)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (3.18.0)\n", + "Requirement already satisfied: typing-extensions>=4.10.0 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (4.14.1)\n", + "Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (3.5)\n", + "Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (3.1.6)\n", + "Requirement already satisfied: fsspec in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (2025.3.2)\n", + "Collecting nvidia-cuda-nvrtc-cu12==12.4.127 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n", + "Collecting nvidia-cuda-runtime-cu12==12.4.127 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n", + "Collecting nvidia-cuda-cupti-cu12==12.4.127 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n", + "Collecting nvidia-cudnn-cu12==9.1.0.70 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n", + "Collecting nvidia-cublas-cu12==12.4.5.8 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n", + "Collecting nvidia-cufft-cu12==11.2.1.3 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n", + "Collecting nvidia-curand-cu12==10.3.5.147 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n", + "Collecting nvidia-cusolver-cu12==11.6.1.9 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n", + "Collecting nvidia-cusparse-cu12==12.3.1.170 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n", + "Requirement already satisfied: nvidia-cusparselt-cu12==0.6.2 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (0.6.2)\n", + "Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (2.21.5)\n", + "Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (12.4.127)\n", + "Collecting nvidia-nvjitlink-cu12==12.4.127 (from torch>=2.3.0->torch-xla2)\n", + " Downloading nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n", + "Requirement already satisfied: triton==3.2.0 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (3.2.0)\n", + "Requirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.11/dist-packages (from torch>=2.3.0->torch-xla2) (1.13.1)\n", + "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from sympy==1.13.1->torch>=2.3.0->torch-xla2) (1.3.0)\n", + "Requirement already satisfied: iniconfig in /usr/local/lib/python3.11/dist-packages (from pytest->torch-xla2) (2.1.0)\n", + "Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from pytest->torch-xla2) (24.2)\n", + "Requirement already satisfied: pluggy<2,>=1.5 in /usr/local/lib/python3.11/dist-packages (from pytest->torch-xla2) (1.6.0)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->torch>=2.3.0->torch-xla2) (3.0.2)\n", + "Downloading torch_xla2-0.0.1.dev202412041639-py3-none-any.whl (76 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.7/76.7 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl (363.4 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (13.8 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m73.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (24.6 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m98.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (883 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m57.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl (664.8 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m1.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl (211.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl (56.3 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m40.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl (127.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m17.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl (207.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (21.1 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m108.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: nvidia-nvjitlink-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, nvidia-cusparse-cu12, nvidia-cudnn-cu12, nvidia-cusolver-cu12, torch-xla2\n", + " Attempting uninstall: nvidia-nvjitlink-cu12\n", + " Found existing installation: nvidia-nvjitlink-cu12 12.5.82\n", + " Uninstalling nvidia-nvjitlink-cu12-12.5.82:\n", + " Successfully uninstalled nvidia-nvjitlink-cu12-12.5.82\n", + " Attempting uninstall: nvidia-curand-cu12\n", + " Found existing installation: nvidia-curand-cu12 10.3.6.82\n", + " Uninstalling nvidia-curand-cu12-10.3.6.82:\n", + " Successfully uninstalled nvidia-curand-cu12-10.3.6.82\n", + " Attempting uninstall: nvidia-cufft-cu12\n", + " Found existing installation: nvidia-cufft-cu12 11.2.3.61\n", + " Uninstalling nvidia-cufft-cu12-11.2.3.61:\n", + " Successfully uninstalled nvidia-cufft-cu12-11.2.3.61\n", + " Attempting uninstall: nvidia-cuda-runtime-cu12\n", + " Found existing installation: nvidia-cuda-runtime-cu12 12.5.82\n", + " Uninstalling nvidia-cuda-runtime-cu12-12.5.82:\n", + " Successfully uninstalled nvidia-cuda-runtime-cu12-12.5.82\n", + " Attempting uninstall: nvidia-cuda-nvrtc-cu12\n", + " Found existing installation: nvidia-cuda-nvrtc-cu12 12.5.82\n", + " Uninstalling nvidia-cuda-nvrtc-cu12-12.5.82:\n", + " Successfully uninstalled nvidia-cuda-nvrtc-cu12-12.5.82\n", + " Attempting uninstall: nvidia-cuda-cupti-cu12\n", + " Found existing installation: nvidia-cuda-cupti-cu12 12.5.82\n", + " Uninstalling nvidia-cuda-cupti-cu12-12.5.82:\n", + " Successfully uninstalled nvidia-cuda-cupti-cu12-12.5.82\n", + " Attempting uninstall: nvidia-cublas-cu12\n", + " Found existing installation: nvidia-cublas-cu12 12.5.3.2\n", + " Uninstalling nvidia-cublas-cu12-12.5.3.2:\n", + " Successfully uninstalled nvidia-cublas-cu12-12.5.3.2\n", + " Attempting uninstall: nvidia-cusparse-cu12\n", + " Found existing installation: nvidia-cusparse-cu12 12.5.1.3\n", + " Uninstalling nvidia-cusparse-cu12-12.5.1.3:\n", + " Successfully uninstalled nvidia-cusparse-cu12-12.5.1.3\n", + " Attempting uninstall: nvidia-cudnn-cu12\n", + " Found existing installation: nvidia-cudnn-cu12 9.3.0.75\n", + " Uninstalling nvidia-cudnn-cu12-9.3.0.75:\n", + " Successfully uninstalled nvidia-cudnn-cu12-9.3.0.75\n", + " Attempting uninstall: nvidia-cusolver-cu12\n", + " Found existing installation: nvidia-cusolver-cu12 11.6.3.83\n", + " Uninstalling nvidia-cusolver-cu12-11.6.3.83:\n", + " Successfully uninstalled nvidia-cusolver-cu12-11.6.3.83\n", + "Successfully installed nvidia-cublas-cu12-12.4.5.8 nvidia-cuda-cupti-cu12-12.4.127 nvidia-cuda-nvrtc-cu12-12.4.127 nvidia-cuda-runtime-cu12-12.4.127 nvidia-cudnn-cu12-9.1.0.70 nvidia-cufft-cu12-11.2.1.3 nvidia-curand-cu12-10.3.5.147 nvidia-cusolver-cu12-11.6.1.9 nvidia-cusparse-cu12-12.3.1.170 nvidia-nvjitlink-cu12-12.4.127 torch-xla2-0.0.1.dev202412041639\n", + "Collecting ai_edge_quantizer\n", + " Downloading ai_edge_quantizer-0.2.1-py3-none-any.whl.metadata (1.7 kB)\n", + "Requirement already satisfied: immutabledict in /usr/local/lib/python3.11/dist-packages (from ai_edge_quantizer) (4.2.1)\n", + "Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from ai_edge_quantizer) (2.0.2)\n", + "Collecting tf-nightly==2.20.0.dev20250515 (from ai_edge_quantizer)\n", + " Downloading tf_nightly-2.20.0.dev20250515-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.3 kB)\n", + "Collecting ai-edge-litert==1.3.0 (from ai_edge_quantizer)\n", + " Downloading ai_edge_litert-1.3.0-cp311-cp311-manylinux_2_17_x86_64.whl.metadata (1.7 kB)\n", + "Collecting backports.strenum (from ai-edge-litert==1.3.0->ai_edge_quantizer)\n", + " Downloading backports_strenum-1.2.8-py3-none-any.whl.metadata (3.6 kB)\n", + "Requirement already satisfied: flatbuffers in /usr/local/lib/python3.11/dist-packages (from ai-edge-litert==1.3.0->ai_edge_quantizer) (25.2.10)\n", + "Requirement already satisfied: tqdm in /usr/local/lib/python3.11/dist-packages (from ai-edge-litert==1.3.0->ai_edge_quantizer) (4.67.1)\n", + "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.11/dist-packages (from ai-edge-litert==1.3.0->ai_edge_quantizer) (4.14.1)\n", + "Requirement already satisfied: absl-py>=1.0.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (1.4.0)\n", + "Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (1.6.3)\n", + "Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.6.0)\n", + "Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.2.0)\n", + "Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (18.1.1)\n", + "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.4.0)\n", + "Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (24.2)\n", + "Requirement already satisfied: protobuf>=4.21.6 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (5.29.5)\n", + "Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (2.32.3)\n", + "Requirement already satisfied: setuptools in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (75.2.0)\n", + "Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (1.17.0)\n", + "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.1.0)\n", + "Requirement already satisfied: wrapt>=1.11.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (1.17.2)\n", + "Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (1.73.1)\n", + "Collecting tb-nightly~=2.19.0.a (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer)\n", + " Downloading tb_nightly-2.19.0a20250218-py3-none-any.whl.metadata (1.8 kB)\n", + "Collecting keras-nightly>=3.6.0.dev (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer)\n", + " Downloading keras_nightly-3.10.0.dev2025071003-py3-none-any.whl.metadata (6.0 kB)\n", + "Requirement already satisfied: h5py>=3.11.0 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.14.0)\n", + "Requirement already satisfied: ml-dtypes<1.0.0,>=0.5.1 in /usr/local/lib/python3.11/dist-packages (from tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.5.1)\n", + "Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.11/dist-packages (from astunparse>=1.6.0->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.45.1)\n", + "Requirement already satisfied: rich in /usr/local/lib/python3.11/dist-packages (from keras-nightly>=3.6.0.dev->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (13.9.4)\n", + "Requirement already satisfied: namex in /usr/local/lib/python3.11/dist-packages (from keras-nightly>=3.6.0.dev->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.1.0)\n", + "Requirement already satisfied: optree in /usr/local/lib/python3.11/dist-packages (from keras-nightly>=3.6.0.dev->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.16.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.4.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (2.4.0)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.21.0->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (2025.6.15)\n", + "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.11/dist-packages (from tb-nightly~=2.19.0.a->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.8.2)\n", + "Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /usr/local/lib/python3.11/dist-packages (from tb-nightly~=2.19.0.a->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.7.2)\n", + "Requirement already satisfied: werkzeug>=1.0.1 in /usr/local/lib/python3.11/dist-packages (from tb-nightly~=2.19.0.a->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.1.3)\n", + "Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.11/dist-packages (from werkzeug>=1.0.1->tb-nightly~=2.19.0.a->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.0.2)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.11/dist-packages (from rich->keras-nightly>=3.6.0.dev->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.11/dist-packages (from rich->keras-nightly>=3.6.0.dev->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (2.19.2)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.11/dist-packages (from markdown-it-py>=2.2.0->rich->keras-nightly>=3.6.0.dev->tf-nightly==2.20.0.dev20250515->ai_edge_quantizer) (0.1.2)\n", + "Downloading ai_edge_quantizer-0.2.1-py3-none-any.whl (186 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m187.0/187.0 kB\u001b[0m \u001b[31m7.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading ai_edge_litert-1.3.0-cp311-cp311-manylinux_2_17_x86_64.whl (11.2 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m11.2/11.2 MB\u001b[0m \u001b[31m133.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading tf_nightly-2.20.0.dev20250515-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (601.9 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m601.9/601.9 MB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading keras_nightly-3.10.0.dev2025071003-py3-none-any.whl (1.4 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.4/1.4 MB\u001b[0m \u001b[31m75.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading tb_nightly-2.19.0a20250218-py3-none-any.whl (5.5 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.5/5.5 MB\u001b[0m \u001b[31m77.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading backports_strenum-1.2.8-py3-none-any.whl (7.9 kB)\n", + "Installing collected packages: backports.strenum, tb-nightly, ai-edge-litert, keras-nightly, tf-nightly, ai_edge_quantizer\n", + "Successfully installed ai-edge-litert-1.3.0 ai_edge_quantizer-0.2.1 backports.strenum-1.2.8 keras-nightly-3.10.0.dev2025071003 tb-nightly-2.19.0a20250218 tf-nightly-2.20.0.dev20250515\n" + ] + }, + { + "output_type": "display_data", + "data": { + "application/vnd.colab-display-data+json": { + "pip_warning": { + "packages": [ + "backports" + ] + }, + "id": "4899a62535cf4be29758b13e1d87a167" + } + }, + "metadata": {} + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: ai_edge_litert in /usr/local/lib/python3.11/dist-packages (1.3.0)\n", + "Requirement already satisfied: backports.strenum in /usr/local/lib/python3.11/dist-packages (from ai_edge_litert) (1.2.8)\n", + "Requirement already satisfied: flatbuffers in /usr/local/lib/python3.11/dist-packages (from ai_edge_litert) (25.2.10)\n", + "Requirement already satisfied: numpy>=1.23.2 in /usr/local/lib/python3.11/dist-packages (from ai_edge_litert) (2.0.2)\n", + "Requirement already satisfied: tqdm in /usr/local/lib/python3.11/dist-packages (from ai_edge_litert) (4.67.1)\n", + "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.11/dist-packages (from ai_edge_litert) (4.14.1)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%cd ai-edge-torch" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "JaK44iZdEvXm", + "outputId": "0764cd12-d15d-4317-c3c4-e4ce8cd04b8a" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/ai-edge-torch\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!ls" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_PwAI2vrExjs", + "outputId": "55cd92c0-d024-4166-8b12-e1b47daeec89" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "ai_edge_torch CONTRIBUTING.md\t LICENSE\t run_tests.sh\n", + "bazel\t dev-requirements.txt MODULE.bazel setup.py\n", + "build_config docs\t\t README.md\t test\n", + "ci\t format.sh\t requirements.txt WORKSPACE\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install -U \"huggingface_hub[cli]\"" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "S8NOGLRqEz42", + "outputId": "1e532c95-6440-4cc0-cd66-131ee5c826a4" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: huggingface_hub[cli] in /usr/local/lib/python3.11/dist-packages (0.33.2)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (3.18.0)\n", + "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (2025.3.2)\n", + "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (24.2)\n", + "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (6.0.2)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (2.32.3)\n", + "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (4.67.1)\n", + "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (4.14.1)\n", + "Requirement already satisfied: hf-xet<2.0.0,>=1.1.2 in /usr/local/lib/python3.11/dist-packages (from huggingface_hub[cli]) (1.1.5)\n", + "Collecting InquirerPy==0.3.4 (from huggingface_hub[cli])\n", + " Downloading InquirerPy-0.3.4-py3-none-any.whl.metadata (8.1 kB)\n", + "Collecting pfzy<0.4.0,>=0.3.1 (from InquirerPy==0.3.4->huggingface_hub[cli])\n", + " Downloading pfzy-0.3.4-py3-none-any.whl.metadata (4.9 kB)\n", + "Requirement already satisfied: prompt-toolkit<4.0.0,>=3.0.1 in /usr/local/lib/python3.11/dist-packages (from InquirerPy==0.3.4->huggingface_hub[cli]) (3.0.51)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface_hub[cli]) (3.4.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface_hub[cli]) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface_hub[cli]) (2.4.0)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface_hub[cli]) (2025.6.15)\n", + "Requirement already satisfied: wcwidth in /usr/local/lib/python3.11/dist-packages (from prompt-toolkit<4.0.0,>=3.0.1->InquirerPy==0.3.4->huggingface_hub[cli]) (0.2.13)\n", + "Downloading InquirerPy-0.3.4-py3-none-any.whl (67 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.7/67.7 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading pfzy-0.3.4-py3-none-any.whl (8.5 kB)\n", + "Installing collected packages: pfzy, InquirerPy\n", + "Successfully installed InquirerPy-0.3.4 pfzy-0.3.4\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "from huggingface_hub import login\n", + "from google.colab import userdata\n", + "HF_TOKEN=userdata.get('HF_READ')\n", + "\n", + "if HF_TOKEN:\n", + " login(HF_TOKEN)\n", + " print(\"Successfully logged in to Hugging Face!\")\n", + "else:\n", + " print(\"Token is not set. Please save the token first.\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "hVUtajitF_aJ", + "outputId": "d5588d84-649a-49a7-873f-3f64bb4e4515" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Successfully logged in to Hugging Face!\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!huggingface-cli download MadeAgents/Hammer2.1-0.5b --repo-type model --local-dir ./models/MadeAgents/Hammer2.1-0.5b" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "lMKgeOA1E3a4", + "outputId": "416f50b3-b692-430a-c3dd-2e9bc0c61804" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\rFetching 13 files: 0% 0/13 [00:00 0.5b" + ], + "metadata": { + "id": "DrXtVp_K1ZDv" + } + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "ED0CDmjS41Pi" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "# For CPU inference in android, use dynamic_int8\n", + "# For GPU inference no set up is found to successful load in android GPU\n", + "NONE = 'none'\n", + "DYNAMIC_INT8 = 'dynamic_int8'\n", + "WEIGHT_ONLY_INT8 = 'weight_only_int8'\n", + "FP16 = 'fp16'\n", + "DYNAMIC_INT4_BLOCK32 = 'dynamic_int4_block32'\n", + "DYNAMIC_INT4_BLOCK128 = 'dynamic_int4_block128'\n", + "\n", + "!python -m ai_edge_torch.generative.examples.hammer.convert_to_tflite \\\n", + " --quantize=\"dynamic_int8\" \\\n", + " --checkpoint_path=/content/ai-edge-torch/models/MadeAgents/Hammer2.1-0.5b \\\n", + " --output_path=\"/content/ai-edge-torch\" \\\n", + " --prefill_seq_lens=128 \\\n", + " --kv_cache_max_len=1280 \\\n", + " --mask_as_input \\\n", + " --transpose_kv_cache \\\n", + " --model_size=0.5b \\\n", + " --undefok=model_size" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 906 + }, + "id": "iZkgWLKsHUbu", + "outputId": "f9ae1947-cb7b-4e65-b2c7-2c54348064f2" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "2025-07-10 06:50:41.687029: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n", + "2025-07-10 06:50:41.759915: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", + "To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n", + "/usr/local/lib/python3.11/dist-packages/torch/distributed/distributed_c10d.py:354: UserWarning: Device capability of jax unspecified, assuming `cpu` and `cuda`. Please specify it via the `devices` argument of `register_backend`.\n", + " warnings.warn(\n", + "I0710 06:52:12.594704 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.view\n", + "I0710 06:52:12.625253 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.embedding\n", + "I0710 06:52:12.652188 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.arange.start_step\n", + "I0710 06:52:12.657038 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.mul.Tensor\n", + "I0710 06:52:12.662169 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.pow\n", + "I0710 06:52:12.669392 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.clone.default\n", + "I0710 06:52:12.673428 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.unsqueeze.default\n", + "I0710 06:52:12.690506 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.div\n", + "I0710 06:52:12.695722 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.cos\n", + "I0710 06:52:12.700235 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.sin\n", + "I0710 06:52:12.704801 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.full\n", + "I0710 06:52:12.714902 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.mean\n", + "I0710 06:52:12.721963 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.add.Tensor\n", + "I0710 06:52:12.727718 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.rsqrt\n", + "I0710 06:52:12.752371 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.permute\n", + "I0710 06:52:12.756566 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.mm\n", + "I0710 06:52:12.794465 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.split_with_sizes\n", + "I0710 06:52:12.841455 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.sub.Tensor\n", + "I0710 06:52:12.941104 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.select\n", + "I0710 06:52:13.022526 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten._softmax\n", + "I0710 06:52:13.125936 134034596196992 _jax_lowerings.py:32] Use JAX lowering: aten.sigmoid\n", + "2025-07-10 06:52:45.497092: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.\n", + "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", + "I0000 00:00:1752130365.497227 2680 gpu_device.cc:2018] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 20961 MB memory: -> device: 0, name: NVIDIA L4, pci bus id: 0000:00:03.0, compute capability: 8.9\n", + "I0710 06:52:48.273987 134034596196992 signature_serialization.py:156] Function `inner` contains input name(s) resource with unsupported characters which will be renamed to xlacallmodule_readvariableop_192_resource in the SavedModel.\n", + "I0710 06:52:48.417292 134034596196992 signature_serialization.py:156] Function `inner` contains input name(s) resource with unsupported characters which will be renamed to xlacallmodule_readvariableop_193_resource in the SavedModel.\n", + "I0710 06:52:50.194184 134034596196992 functional_saver.py:440] Sharding callback duration: 145 microseconds\n", + "I0710 06:52:52.274698 134034596196992 functional_saver.py:440] Sharding callback duration: 129 microseconds\n", + "INFO:tensorflow:Assets written to: /tmp/tmpwltrmz55/assets\n", + "I0710 06:52:57.939098 134034596196992 builder_impl.py:836] Assets written to: /tmp/tmpwltrmz55/assets\n", + "I0710 06:52:57.947176 134034596196992 fingerprinting_utils.py:49] Writing fingerprint to /tmp/tmpwltrmz55/fingerprint.pb\n", + "W0000 00:00:1752130383.092105 2680 tf_tfl_flatbuffer_helpers.cc:364] Ignored output_format.\n", + "W0000 00:00:1752130383.092143 2680 tf_tfl_flatbuffer_helpers.cc:367] Ignored drop_control_dependency.\n", + "2025-07-10 06:53:03.093113: I tensorflow/cc/saved_model/reader.cc:83] Reading SavedModel from: /tmp/tmpwltrmz55\n", + "2025-07-10 06:53:03.102923: I tensorflow/cc/saved_model/reader.cc:52] Reading meta graph with tags { serve }\n", + "2025-07-10 06:53:03.102950: I tensorflow/cc/saved_model/reader.cc:147] Reading SavedModel debug info (if present) from: /tmp/tmpwltrmz55\n", + "I0000 00:00:1752130383.166955 2680 mlir_graph_optimization_pass.cc:437] MLIR V1 optimization pass is not enabled\n", + "2025-07-10 06:53:03.176475: I tensorflow/cc/saved_model/loader.cc:236] Restoring SavedModel bundle.\n", + "2025-07-10 06:53:04.416172: I tensorflow/cc/saved_model/loader.cc:220] Running initialization op on SavedModel bundle at path: /tmp/tmpwltrmz55\n", + "2025-07-10 06:53:04.542634: I tensorflow/cc/saved_model/loader.cc:471] SavedModel load for tags { serve }; Status: success: OK. Took 1449520 microseconds.\n", + "2025-07-10 06:53:04.654622: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.\n", + "2025-07-10 06:55:05.854247: I tensorflow/compiler/mlir/lite/flatbuffer_export.cc:4096] Estimated count of arithmetic ops: 93.485 G ops, equivalently 46.743 G MACs\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "'\\nblaze run //third_party/py/ai_edge_torch/generative/examples/hammer:convert_to_tflite -- \\n --checkpoint_path /tmp/snapshots/MadeAgents/Hammer2.1-1.5b \\n --output_path /tmp/tmps7np6qhp \\n --output_name_prefix Hammer2.1-1.5b_seq128 \\n --kv_cache_max_len 1280 \\n --mask_as_input \\n --transpose_kv_cache\\n --model_size 1.5b \\n --undefok=model_size \\n --quantize dynamic_int8 \\n --prefill_seq_lens 128\\n'" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + } + }, + "metadata": {}, + "execution_count": 6 + } + ] + }, + { + "cell_type": "code", + "source": [ + "%cd ai_edge_torch/generative/tools\n", + "\n", + "!python tokenizer_to_sentencepiece.py \\\n", + " --checkpoint=MadeAgents/Hammer2.1-0.5b \\\n", + " --output_path=/content/tokenizer.model" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "sRvr3KXIHuwO", + "outputId": "2a25018b-34cb-492b-a6f3-eff1e05d24a7" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/ai-edge-torch/ai_edge_torch/generative/tools\n", + "I0710 06:57:41.739611 137180622922368 utils.py:164] NumExpr defaulting to 12 threads.\n", + "tokenizer_config.json: 7.13kB [00:00, 23.0MB/s]\n", + "vocab.json: 2.78MB [00:00, 48.8MB/s]\n", + "merges.txt: 1.67MB [00:00, 127MB/s]\n", + "tokenizer.json: 100% 11.4M/11.4M [00:00<00:00, 128MB/s]\n", + "added_tokens.json: 100% 605/605 [00:00<00:00, 3.52MB/s]\n", + "special_tokens_map.json: 100% 613/613 [00:00<00:00, 4.64MB/s]\n", + "I0710 06:57:44.359609 137180622922368 tokenizer_to_sentencepiece.py:299] vocab_file does not exist. Try to build a new one.\n", + "I0710 06:57:53.229321 137180622922368 tokenizer_to_sentencepiece.py:183] Found pad_id: 151643, pad_piece: <|endoftext|>\n", + "I0710 06:57:53.229638 137180622922368 tokenizer_to_sentencepiece.py:179] Found eos_id: 151645, eos_piece: <|im_end|>\n", + "I0710 06:57:53.230827 137180622922368 tokenizer_to_sentencepiece.py:204] number of tokens: 151665\n", + "I0710 06:57:53.231059 137180622922368 tokenizer_to_sentencepiece.py:206] number of NORMAL: 150144\n", + "I0710 06:57:53.231109 137180622922368 tokenizer_to_sentencepiece.py:206] number of UNUSED: 1499\n", + "I0710 06:57:53.231164 137180622922368 tokenizer_to_sentencepiece.py:206] number of UNKNOWN: 1\n", + "I0710 06:57:53.231228 137180622922368 tokenizer_to_sentencepiece.py:206] number of USER_DEFINED: 21\n", + "I0710 06:57:53.352619 137180622922368 tokenizer_to_sentencepiece.py:257] String to verify: Hello, world! How are you?\n", + "I0710 06:57:53.352900 137180622922368 tokenizer_to_sentencepiece.py:258] Token IDs by the oringal tokenizer: [9707, 11, 1879, 0, 2585, 525, 498, 30]\n", + "I0710 06:57:53.352944 137180622922368 tokenizer_to_sentencepiece.py:259] Token IDs by the SentencePiece tokenizer: [9707, 11, 1879, 0, 2585, 525, 498, 30]\n", + "I0710 06:57:53.352984 137180622922368 tokenizer_to_sentencepiece.py:261] PASS\n", + "I0710 06:57:53.353320 137180622922368 tokenizer_to_sentencepiece.py:257] String to verify: Instruct: write a python program to add 2 and 3.\n", + "I0710 06:57:53.353379 137180622922368 tokenizer_to_sentencepiece.py:258] Token IDs by the oringal tokenizer: [641, 1235, 25, 3270, 264, 10135, 2025, 311, 912, 220, 17, 323, 220, 18, 13]\n", + "I0710 06:57:53.353415 137180622922368 tokenizer_to_sentencepiece.py:259] Token IDs by the SentencePiece tokenizer: [641, 1235, 25, 3270, 264, 10135, 2025, 311, 912, 220, 17, 323, 220, 18, 13]\n", + "I0710 06:57:53.353448 137180622922368 tokenizer_to_sentencepiece.py:261] PASS\n", + "I0710 06:58:04.615295 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 3/100 pairs: 3.00%, loosely 0/100 pairs: 0.00%\n", + "I0710 06:58:16.108360 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 6/200 pairs: 3.00%, loosely 0/200 pairs: 0.00%\n", + "I0710 06:58:27.580932 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 8/300 pairs: 2.67%, loosely 0/300 pairs: 0.00%\n", + "I0710 06:58:39.014399 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 13/400 pairs: 3.25%, loosely 0/400 pairs: 0.00%\n", + "I0710 06:58:50.537630 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 19/500 pairs: 3.80%, loosely 0/500 pairs: 0.00%\n", + "I0710 06:59:01.968418 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 22/600 pairs: 3.67%, loosely 0/600 pairs: 0.00%\n", + "I0710 06:59:13.855856 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 30/700 pairs: 4.29%, loosely 0/700 pairs: 0.00%\n", + "I0710 06:59:24.913957 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 35/800 pairs: 4.38%, loosely 0/800 pairs: 0.00%\n", + "I0710 06:59:35.834920 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 40/900 pairs: 4.44%, loosely 0/900 pairs: 0.00%\n", + "I0710 06:59:46.792476 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 46/1000 pairs: 4.60%, loosely 0/1000 pairs: 0.00%\n", + "I0710 06:59:46.792602 137180622922368 tokenizer_to_sentencepiece.py:225] Not matched strictly 46/1000 pairs: 4.60%, loosely 0/1000 pairs: 0.00%\n", + "I0710 06:59:46.792666 137180622922368 tokenizer_to_sentencepiece.py:307] Writing the SentencePieceModel protobuf file to: /content/tokenizer.model\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install mediapipe" + ], + "metadata": { + "id": "QiyP70vCH6bw", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "ab29eb7e-4b19-4f02-9831-42355ab1f2d1" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting mediapipe\n", + " Downloading mediapipe-0.10.21-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (9.7 kB)\n", + "Requirement already satisfied: absl-py in /usr/local/lib/python3.11/dist-packages (from mediapipe) (1.4.0)\n", + "Requirement already satisfied: attrs>=19.1.0 in /usr/local/lib/python3.11/dist-packages (from mediapipe) (25.3.0)\n", + "Requirement already satisfied: flatbuffers>=2.0 in /usr/local/lib/python3.11/dist-packages (from mediapipe) (25.2.10)\n", + "Requirement already satisfied: jax in /usr/local/lib/python3.11/dist-packages (from mediapipe) (0.5.2)\n", + "Requirement already satisfied: jaxlib in /usr/local/lib/python3.11/dist-packages (from mediapipe) (0.5.1)\n", + "Requirement already satisfied: matplotlib in /usr/local/lib/python3.11/dist-packages (from mediapipe) (3.10.0)\n", + "Collecting numpy<2 (from mediapipe)\n", + " Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.0/61.0 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: opencv-contrib-python in /usr/local/lib/python3.11/dist-packages (from mediapipe) (4.11.0.86)\n", + "Collecting protobuf<5,>=4.25.3 (from mediapipe)\n", + " Downloading protobuf-4.25.8-cp37-abi3-manylinux2014_x86_64.whl.metadata (541 bytes)\n", + "Collecting sounddevice>=0.4.4 (from mediapipe)\n", + " Downloading sounddevice-0.5.2-py3-none-any.whl.metadata (1.6 kB)\n", + "Requirement already satisfied: sentencepiece in /usr/local/lib/python3.11/dist-packages (from mediapipe) (0.2.0)\n", + "Requirement already satisfied: CFFI>=1.0 in /usr/local/lib/python3.11/dist-packages (from sounddevice>=0.4.4->mediapipe) (1.17.1)\n", + "Requirement already satisfied: ml_dtypes>=0.4.0 in /usr/local/lib/python3.11/dist-packages (from jax->mediapipe) (0.5.1)\n", + "Requirement already satisfied: opt_einsum in /usr/local/lib/python3.11/dist-packages (from jax->mediapipe) (3.4.0)\n", + "Requirement already satisfied: scipy>=1.11.1 in /usr/local/lib/python3.11/dist-packages (from jax->mediapipe) (1.15.3)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (1.3.2)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (4.58.5)\n", + "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (1.4.8)\n", + "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (24.2)\n", + "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (11.2.1)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (3.2.3)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.11/dist-packages (from matplotlib->mediapipe) (2.9.0.post0)\n", + "Requirement already satisfied: pycparser in /usr/local/lib/python3.11/dist-packages (from CFFI>=1.0->sounddevice>=0.4.4->mediapipe) (2.22)\n", + "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/dist-packages (from python-dateutil>=2.7->matplotlib->mediapipe) (1.17.0)\n", + "Downloading mediapipe-0.10.21-cp311-cp311-manylinux_2_28_x86_64.whl (35.6 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m35.6/35.6 MB\u001b[0m \u001b[31m64.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.3/18.3 MB\u001b[0m \u001b[31m112.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading protobuf-4.25.8-cp37-abi3-manylinux2014_x86_64.whl (294 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m294.9/294.9 kB\u001b[0m \u001b[31m29.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading sounddevice-0.5.2-py3-none-any.whl (32 kB)\n", + "Installing collected packages: protobuf, numpy, sounddevice, mediapipe\n", + " Attempting uninstall: protobuf\n", + " Found existing installation: protobuf 5.29.5\n", + " Uninstalling protobuf-5.29.5:\n", + " Successfully uninstalled protobuf-5.29.5\n", + " Attempting uninstall: numpy\n", + " Found existing installation: numpy 2.0.2\n", + " Uninstalling numpy-2.0.2:\n", + " Successfully uninstalled numpy-2.0.2\n", + "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", + "grpcio-status 1.71.2 requires protobuf<6.0dev,>=5.26.1, but you have protobuf 4.25.8 which is incompatible.\n", + "tf-keras 2.18.0 requires tensorflow<2.19,>=2.18, but you have tensorflow 2.19.0 which is incompatible.\n", + "tensorflow-text 2.18.1 requires tensorflow<2.19,>=2.18.0, but you have tensorflow 2.19.0 which is incompatible.\n", + "ydf 0.12.0 requires protobuf<6.0.0,>=5.29.1, but you have protobuf 4.25.8 which is incompatible.\n", + "opencv-python-headless 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= \"3.9\", but you have numpy 1.26.4 which is incompatible.\n", + "thinc 8.3.6 requires numpy<3.0.0,>=2.0.0, but you have numpy 1.26.4 which is incompatible.\n", + "tensorflow-decision-forests 1.11.0 requires tensorflow==2.18.0, but you have tensorflow 2.19.0 which is incompatible.\u001b[0m\u001b[31m\n", + "\u001b[0mSuccessfully installed mediapipe-0.10.21 numpy-1.26.4 protobuf-4.25.8 sounddevice-0.5.2\n" + ] + }, + { + "output_type": "display_data", + "data": { + "application/vnd.colab-display-data+json": { + "pip_warning": { + "packages": [ + "google", + "numpy" + ] + }, + "id": "39abba471a0d4db1a62010247933bb32" + } + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [ + "'''\n", + "# --- Hammer 2.1 0.5b Model Configuration ---\n", + "\n", + "# 1. Set the path to your converted Hammer TFLite model.\n", + "HAMMER_TFLITE_MODEL = '/content/ai-edge-torch/hammer_q8_ekv1280.tflite'\n", + "\n", + "# 2. Set the path to the Hammer tokenizer model file (e.g., 'tokenizer.model').\n", + "# This is the actual tokenizer file, not the JSON configuration file.\n", + "HAMMER_TOKENIZER_MODEL = '/content/tokenizer.model'\n", + "\n", + "# --- Define Hammer's Special Tokens and Prompt Structure ---\n", + "\n", + "START_TOKEN = \"\"\n", + "\n", + "# Stop tokens signal the end of a turn ('<|im_end|>') or the end of the entire text ('<|endoftext|>').\n", + "STOP_TOKENS = [\"<|im_end|>\", \"<|endoftext|>\"]\n", + "\n", + "# The prefix to be added before the user's input.\n", + "# Format: <|im_start|>user\\n\n", + "PROMPT_PREFIX = \"<|im_start|>user\\n\"\n", + "\n", + "# The suffix to be added after the user's input, which cues the model's response.\n", + "# Format: <|im_end|>\\n<|im_start|>assistant\\n\n", + "PROMPT_SUFFIX = \"<|im_end|>\\n<|im_start|>assistant\\n\"\n", + "\n", + "# --- Create the MediaPipe GenAI Task Bundle ---\n", + "\n", + "print(f\"Starting to bundle the Hammer 2.1 0.5b model...\")\n", + "print(f\"TFLite Model: {HAMMER_TFLITE_MODEL}\")\n", + "print(f\"Tokenizer Model: {HAMMER_TOKENIZER_MODEL}\")\n", + "\n", + "# Define the output file path for the bundled model.\n", + "output_filename = \"/content/hammer.task\"\n", + "\n", + "# Configure the bundler with Hammer's specific settings.\n", + "config = bundler.BundleConfig(\n", + " tflite_model=HAMMER_TFLITE_MODEL,\n", + " tokenizer_model=HAMMER_TOKENIZER_MODEL,\n", + " start_token=START_TOKEN,\n", + " stop_tokens=STOP_TOKENS,\n", + " prompt_prefix=PROMPT_PREFIX,\n", + " prompt_suffix=PROMPT_SUFFIX,\n", + " output_filename=output_filename,\n", + ")\n", + "\n", + "# Create the bundle.\n", + "bundler.create_bundle(config)\n", + "\n", + "print(f\"\\nSuccessfully created the model bundle at: {os.path.abspath(output_filename)}\")\n", + "'''" + ], + "metadata": { + "id": "bB4q3Cp-fjXN" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "TFLITE_MODEL = \"/content/ai-edge-torch/hammer_q8_ekv1280.tflite\"\n", + "TOKENIZER_MODEL = \"/content/tokenizer.model\"\n", + "\n", + "from mediapipe.tasks.python.genai import bundler\n", + "\n", + "config = bundler.BundleConfig(\n", + " tflite_model=TFLITE_MODEL,\n", + " tokenizer_model=TOKENIZER_MODEL,\n", + " start_token=\"<|im_start|>user\\n\", # begin user turn\n", + " stop_tokens=[\"<|im_end|>\"], # end of any turn\n", + " output_filename=\"/content/hammer2p1_05b.task\",\n", + " prompt_prefix=\"\", # prefix is handled via start_token\n", + " prompt_suffix=\"<|im_end|>\\n<|im_start|>assistant\\n\", # close user, open assistant\n", + ")\n", + "bundler.create_bundle(config)\n" + ], + "metadata": { + "id": "UrpxPv6v4JXD" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "0TBsfzyl9FSb" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file