importlib_version
This commit is contained in:
parent
71ae760aa0
commit
2003da34f8
4 changed files with 9 additions and 14 deletions
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import warnings, importlib, sys
|
||||
from packaging.version import Version
|
||||
import os, re, subprocess, inspect
|
||||
import os, re, subprocess, inspect, functools
|
||||
import numpy as np
|
||||
|
||||
# Fix some issues before importing other packages
|
||||
|
|
@ -69,9 +69,12 @@ except Exception as exception:
|
|||
raise exception
|
||||
pass
|
||||
|
||||
@functools.cache
|
||||
def is_hip():
|
||||
return bool(getattr(getattr(torch, "version", None), "hip", None))
|
||||
pass
|
||||
|
||||
@functools.cache
|
||||
def get_device_type():
|
||||
if hasattr(torch, "cuda") and torch.cuda.is_available():
|
||||
if is_hip():
|
||||
|
|
@ -83,6 +86,7 @@ def get_device_type():
|
|||
pass
|
||||
DEVICE_TYPE : str = get_device_type()
|
||||
|
||||
@functools.cache
|
||||
def get_device_count():
|
||||
if DEVICE_TYPE in ("cuda", "hip"):
|
||||
return torch.cuda.device_count()
|
||||
|
|
@ -137,7 +141,6 @@ pass
|
|||
import importlib.util
|
||||
from pathlib import Path
|
||||
from importlib.metadata import version as importlib_version
|
||||
from packaging.version import Version
|
||||
from .import_fixes import fix_xformers_performance_issue
|
||||
fix_xformers_performance_issue(); del fix_xformers_performance_issue;
|
||||
from .import_fixes import fix_vllm_aimv2_issue
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ __all__ = [
|
|||
"xformers_attention",
|
||||
"xformers_version",
|
||||
"__version__",
|
||||
"importlib_version",
|
||||
"HAS_FLASH_ATTENTION",
|
||||
"HAS_FLASH_ATTENTION_SOFTCAPPING",
|
||||
"USE_MODELSCOPE",
|
||||
|
|
@ -81,6 +82,7 @@ import re
|
|||
import functools
|
||||
import warnings, subprocess, re, inspect, psutil, os, math
|
||||
from unsloth_zoo.utils import Version
|
||||
from importlib.metadata import version as importlib_version
|
||||
from unsloth import DEVICE_TYPE, DEVICE_COUNT
|
||||
|
||||
from unsloth_zoo.tokenizer_utils import (
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import functools
|
|||
from typing import Any, Dict, Optional, Tuple, List, Union
|
||||
from ._utils import *
|
||||
from ._utils import patch_unsloth_smart_gradient_checkpointing
|
||||
from ._utils import __version__
|
||||
from ._utils import __version__, importlib_version
|
||||
from ._utils import move_to_device
|
||||
from ._utils import _prepare_model_for_qat
|
||||
from torch.nn.functional import scaled_dot_product_attention
|
||||
|
|
@ -1867,23 +1867,18 @@ class FastLlamaModel:
|
|||
gpu_stats = torch.cuda.get_device_properties(0)
|
||||
gpu_version = torch.version.cuda
|
||||
gpu_stats_snippet = f"CUDA: {gpu_stats.major}.{gpu_stats.minor}. CUDA Toolkit: {gpu_version}."
|
||||
|
||||
from importlib.metadata import version as importlib_version
|
||||
try: vllm_version = f" vLLM: {importlib_version('vllm')}."
|
||||
except: vllm_version = ""
|
||||
elif DEVICE_TYPE == "hip":
|
||||
gpu_stats = torch.cuda.get_device_properties(0)
|
||||
gpu_version = torch.version.hip
|
||||
gpu_stats_snippet = f"ROCm Toolkit: {gpu_version}."
|
||||
|
||||
from importlib.metadata import version as importlib_version
|
||||
try: vllm_version = f" vLLM: {importlib_version('vllm')}."
|
||||
except: vllm_version = ""
|
||||
elif DEVICE_TYPE == "xpu":
|
||||
gpu_stats = torch.xpu.get_device_properties(0)
|
||||
gpu_version = torch.version.xpu
|
||||
gpu_stats_snippet = f"Intel Toolkit: {gpu_version}."
|
||||
|
||||
try: vllm_version = f" vLLM: {importlib_version('vllm')}."
|
||||
except: vllm_version = ""
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pass
|
|||
from ..kernels import (
|
||||
post_patch_loss_function,
|
||||
)
|
||||
from ._utils import __version__
|
||||
from ._utils import __version__, importlib_version
|
||||
from ._utils import *
|
||||
from ..save import patch_saving_functions
|
||||
from peft import LoraConfig, TaskType, get_peft_model as _get_peft_model
|
||||
|
|
@ -277,23 +277,18 @@ class FastBaseModel:
|
|||
gpu_stats = torch.cuda.get_device_properties(0)
|
||||
gpu_version = torch.version.cuda
|
||||
gpu_stats_snippet = f"CUDA: {gpu_stats.major}.{gpu_stats.minor}. CUDA Toolkit: {gpu_version}."
|
||||
|
||||
from importlib.metadata import version as importlib_version
|
||||
try: vllm_version = f" vLLM: {importlib_version('vllm')}."
|
||||
except: vllm_version = ""
|
||||
elif DEVICE_TYPE == "hip":
|
||||
gpu_stats = torch.cuda.get_device_properties(0)
|
||||
gpu_version = torch.version.hip
|
||||
gpu_stats_snippet = f"ROCm Toolkit: {gpu_version}."
|
||||
|
||||
from importlib.metadata import version as importlib_version
|
||||
try: vllm_version = f" vLLM: {importlib_version('vllm')}."
|
||||
except: vllm_version = ""
|
||||
elif DEVICE_TYPE == "xpu":
|
||||
gpu_stats = torch.xpu.get_device_properties(0)
|
||||
gpu_version = torch.version.xpu
|
||||
gpu_stats_snippet = f"Intel Toolkit: {gpu_version}."
|
||||
|
||||
# TODO: After adding vLLM support for XPU, changed this
|
||||
vllm_version = ""
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue