Skip to content

Inconsistent results between online and offline LORA model inference #269

Closed

Description

@terraformmachine

Description:

There is an issue where the inference results obtained using the base model (unsloth/gemma-7b-it-bnb-4bit) differ depending on whether the model is loaded directly from the Hugbing Face Hub or from a local copy in an offline environment.

Steps to Reproduce - Offline (Local) Loading:

  1. Download the base model (unsloth/gemma-7b-it-bnb-4bit) from the Hugging Face Hub and save it in a folder named "unsloth/gemma-7b-it-bnb-4bit".
  2. Disconnect the network to ensure the model is loaded from the locally saved copy (optional)
  3. Load the trained PEFT model from the local folder.
  4. Generate outputs using the locally loaded model.

Steps to Reproduce - Online (Hugging Face Hub) Loading:

  1. Reconnect the network and remove the local copy of the base model (to ensure base model is loaded directly from the Hugging Face Hub)
  2. Compare the generated outputs from the locally loaded model with those obtained when loading the base model directly from the Hugging Face Hub.

Code Used:

In both cases model was loaded like this:

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "lora_model2",
    max_seq_length = max_seq_length,
    dtype = dtype,
    load_in_4bit = load_in_4bit,
)

Expected Behavior:

The results generated by the locally loaded model should closely match those obtained when loading the base model directly from the Hugging Face Hub, regardless of the environment (offline or online).

Actual Behavior:

The results obtained when loading the base model directly from the Hugging Face Hub while being online and loading the base model offline from a local folder (with the network disconnected) are significantly different. The LoRA model is local in both cases, with the only difference being where the base model is loaded from (hub vs local copy).

Additional Information:

  • It is suspected that there might be an issue with offline/local loading of the base model and applying the LoRA, causing the discrepancy in results.
  • Changing the paths of both the local model and the PEFT config adapter did not resolve the issue.

Activity

  1. danielhanchen commented on Mar 20, 2024

    @danielhanchen
    Member

    @terraformmachine That is extremely weird! Essentially your saying a downloaded online model has different generation results than an offline model?

    I'll see what I can do! I'll check if there are model weight differences - sorry on the issue!

  2. terraformmachine commented on Mar 20, 2024

    @terraformmachine
    Author

    I managed to fix the problem by re-downloading the weights, upgrading unsloth to the latest version, and updating all dependencies to their latest versions. This resolved the discrepancy in the model outputs between the offline and online settings. Although I am not sure which specific change fixed the problem, I can confirm that the issue has been resolved for now. If it reoccurs, I will reopen the issue. Thank you for checking.

  3. added a commit that references this issue on Mar 12, 2026
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

    currently fixing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions