Repository: unslothai/unsloth
File: unsloth/models/loader.py (Python)

Code before:
                print(
                    "Unsloth: AMD currently is not stable with 4bit bitsandbytes. Disabling for now."
                )
            load_in_4bit = False

        if load_in_fp8 and not fast_inference:
            raise ValueError(
                "Unsloth: `load_in_fp8` is only supported for `fast_inference` for now"
            )
        if load_in_fp8 and full_finetuning:
            raise ValueError(
                "Unsloth: `load_in_fp8` is not compatible with full finetuning"
            )
        if load_in_fp8 and (load_in_4bit or load_in_8bit or load_in_16bit):
            raise ValueError(
                "Unsloth: `load_in_fp8` is not compatible with `load_in_4bit`, `load_in_8bit` or `load_in_16bit`",
            )
        if load_in_fp8 and use_exact_model_name:
            raise ValueError(
                "Unsloth: `load_in_fp8` requires `use_exact_model_name=False`"
            )

        old_model_name = model_name
        if not use_exact_model_name:
            if load_in_fp8:
                model_name = _offline_quantize_to_fp8(model_name)
            else:
                model_name = get_model_name(model_name, load_in_4bit)

        # Check if pre-quantized models are allowed
        # For eg AMD GPUs need blocksize = 128, but our pre-quants are blocksize = 64
        if not ALLOW_PREQUANTIZED_MODELS and model_name.lower().endswith(
            ("-unsloth-bnb-4bit", "-bnb-4bit")
        ):
            model_name = model_name.lower().removesuffix("-unsloth-bnb-4bit")
            model_name = model_name.lower().removesuffix("-bnb-4bit")
        # Change -BF16 to all False for 4bit, 8bit etc
        if model_name.lower().endswith("-bf16"):
            load_in_4bit = False
            load_in_8bit = False
            load_in_16bit = True

        # Check modelscope
        if USE_MODELSCOPE and not os.path.exists(model_name):
            from modelscope import snapshot_download

            model_name = snapshot_download(model_name)

        # First check if it's a normal model via AutoConfig
        from huggingface_hub.utils import (
            disable_progress_bars,

Review comment (suggestion):
We should probably verify the presence of `torchao` here (on load_in_fp8=True) cuz we import it later for this processing

Code after:
                "Specifying `qat_scheme` in `FastLanguageModel.from_pretrained(...)` is only "
                "compatible with `full_finetuning=True`. If you wish to use QAT with LoRA, "
                "please pass in `qat_scheme` in `FastLanguageModel.get_peft_model(...)` instead."
            )
        # Check if 4bit is allowed specifically for AMD
        if not ALLOW_BITSANDBYTES and not use_exact_model_name:
            if load_in_4bit or load_in_8bit or model_name.lower().endswith("-bnb-4bit"):
                print(
                    "Unsloth: AMD currently is not stable with 4bit bitsandbytes. Disabling for now."
                )
            load_in_4bit = False

        if load_in_fp8:
            _check_load_in_fp8_settings(
                fast_inference,
                full_finetuning,
                load_in_4bit,
                load_in_8bit,
                load_in_16bit,
                use_exact_model_name,
            )

        old_model_name = model_name
        if not use_exact_model_name:
            if load_in_fp8:
                model_name = _offline_quantize_to_fp8(model_name)
            else:
                model_name = get_model_name(model_name, load_in_4bit)

        # Check if pre-quantized models are allowed
        # For eg AMD GPUs need blocksize = 128, but our pre-quants are blocksize = 64
        if not ALLOW_PREQUANTIZED_MODELS and model_name.lower().endswith(
            ("-unsloth-bnb-4bit", "-bnb-4bit")
        ):
            model_name = model_name.lower().removesuffix("-unsloth-bnb-4bit")
            model_name = model_name.lower().removesuffix("-bnb-4bit")
        # Change -BF16 to all False for 4bit, 8bit etc
        if model_name.lower().endswith("-bf16"):
            load_in_4bit = False
            load_in_8bit = False
            load_in_16bit = True

        # Check modelscope
        if USE_MODELSCOPE and not os.path.exists(model_name):
            from modelscope import snapshot_download

            model_name = snapshot_download(model_name)

        # First check if it's a normal model via AutoConfig
        from huggingface_hub.utils import (
            disable_progress_bars,