Skip to content

[Bug] Offline environment variables ignored - model downloads despite HF_HUB_OFFLINE=1 #5316

Closed

Description

@jadoont

1. Did you update? pip install --upgrade unsloth unsloth_zoo
Yes - pip install --upgrade unsloth unsloth_zoo

2.. Colab or Kaggle or local / cloud
Colab

3. Number GPUs used, use nvidia-smi
1 GPU (Tesla T4), nvidia-smi: CUDA 12.8

4. Which notebook? Please link!
No notebook - minimal reproduction script below

5. Which Unsloth version, TRL version, transformers version, PyTorch version?
Unsloth 2026.5.2, Transformers 5.5.0, PyTorch 2.10.0+cu128

6. Which trainer? SFTTrainer, GRPOTrainer etc
No trainer used - issue is at model loading stage

import shutil, os

# Clear local cache entirely
shutil.rmtree(os.path.expanduser("~/.cache/huggingface/hub"), 
              ignore_errors=True)

# Set all three offline flags before any import
os.environ["TRANSFORMERS_OFFLINE"] = "1"
os.environ["HF_DATASETS_OFFLINE"] = "1"
os.environ["HF_HUB_OFFLINE"] = "1"

from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
    "unsloth/tinyllama",
    max_seq_length=512,
    load_in_4bit=True,
)

Expected: It should load from cache or raise a clear offline error.
Actual: Unsloth downloads the full 762MB model anyway, ignoring all three offline flags. Appears to be because
hf_transfer bypasses standard HuggingFace offline checks.

Investigated and reproduced by: @jadoont, @ZachLeibman, @VPhung1901, @AzizMuminov
(Dickinson College, COMP 492, Spring 2026)

Image

Activity

  1. Erland366 commented on May 7, 2026

    @Erland366
    Collaborator

    Hello,

    We tried to reproduce it by making sure that the environment variable was set before importing anything (mainly unsloth) and as we expected, we cannot run the model like the screenshot below.

    Image

    Confirmed as well by @LeoBorcherding

    So you cannot set your environment variable before importing the libraries.

    Hope that clarify your issue.

  2. LeoBorcherding commented on May 7, 2026

    @LeoBorcherding
    Collaborator

    I can confirm, same results as @Erland366. When pip installing unsloth in the same cell as setting the os.environ vars, the issue goes away and it returns an actual error:

    Image Image
  3. added a commit that references this issue on May 19, 2026
    94026fc
  4. added a commit that references this issue on Jun 3, 2026
    055eb13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions