Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions nb/GLM_Flash_A100(80GB).ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"id": "A8YXB3_Q3J-H"
},
Expand All @@ -66,14 +66,20 @@
"%%capture\n",
"import os, importlib.util\n",
"!pip install --upgrade -qqq uv\n",
"if importlib.util.find_spec(\"torch\") is None or \"COLAB_\" in \"\".join(os.environ.keys()):\n",
"if importlib.util.find_spec(\"torch\") is None or \"COLAB_\" in \"\".join(os.environ.keys()): \n",
" try: import numpy, PIL; get_numpy = f\"numpy=={numpy.__version__}\"; get_pil = f\"pillow=={PIL.__version__}\"\n",
" except: get_numpy = \"numpy\"; get_pil = \"pillow\"\n",
" !uv pip install -qqq \\\n",
" \"torch==2.7.1\" \"triton>=3.3.0\" {get_numpy} {get_pil} torchvision bitsandbytes\n",
"# Install unsloth and transformers from source for this new model\n",
"!uv pip install git+https://github.com/unslothai/unsloth@nightly git+https://github.com/unslothai/unsloth-zoo --no-deps\n",
"!uv pip install --upgrade --no-deps git+https://github.com/huggingface/transformers tokenizers trl==0.25.0 datasets==4.3.0 huggingface_hub"
" \"torch>=2.8.0\" \"triton>=3.4.0\" {get_numpy} {get_pil} torchvision bitsandbytes \\\n",
" git+https://github.com/unslothai/unsloth-zoo \\\n",
" \"git+https://github.com/Datta0/unsloth.git@moe_kernels\" \\\n",
" git+https://github.com/triton-lang/triton.git@0add68262ab0a2e33b84524346cb27cbb2787356#subdirectory=python/triton_kernels\n",
"elif importlib.util.find_spec(\"unsloth\") is None:\n",
" !uv pip install -qqq unsloth\n",
"!uv pip install --upgrade --no-deps tokenizers trl==0.25.0 datasets==4.3.0 huggingface_hub\n",
"!uv pip install git+https://github.com/datta0/unsloth@moe_kernels --no-deps\n",
"!uv pip install git+https://github.com/datta0/unsloth-zoo@glm47_moe_kernels --no-deps\n",
"!uv pip install transformers==5.0.0"
Comment on lines +69 to +82
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The installation logic in this cell is a bit convoluted and contains redundant or conflicting steps. For example:

  • unsloth is installed from a fork in the if block, and then again unconditionally at the end.
  • unsloth-zoo is installed from the main repo, and then overridden by an installation from a fork.
  • The elif block installs unsloth from PyPI, which is immediately overridden by the fork version.

To simplify and clarify the installation process, I suggest refactoring this to first handle the torch installation if needed, and then unconditionally install all the other required packages from their correct sources.

if importlib.util.find_spec("torch") is None or "COLAB_" in "".join(os.environ.keys()):    
    try: import numpy, PIL; get_numpy = f"numpy=={numpy.__version__}"; get_pil = f"pillow=={PIL.__version__}"
    except: get_numpy = "numpy"; get_pil = "pillow"
    !uv pip install -qqq \
        "torch>=2.8.0" "triton>=3.4.0" {get_numpy} {get_pil} torchvision bitsandbytes \
        git+https://github.com/triton-lang/triton.git@0add68262ab0a2e33b84524346cb27cbb2787356#subdirectory=python/triton_kernels

!uv pip install --upgrade --no-deps tokenizers trl==0.25.0 datasets==4.3.0 huggingface_hub
!uv pip install git+https://github.com/datta0/unsloth@moe_kernels --no-deps
!uv pip install git+https://github.com/datta0/unsloth-zoo@glm47_moe_kernels --no-deps
!uv pip install transformers==5.0.0

]
},
{
Expand Down
Loading