Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into hengguo/h2o
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ck-guo authored Jul 2, 2024
2 parents 523ca76 + 816f475 commit 2618e6f
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/script/install_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source /intel-extension-for-transformers/.github/workflows/script/change_color.s
cd /intel-extension-for-transformers
export CMAKE_ARGS="-DNE_DNNL_CACHE_DIR=/cache"
pip install -U pip
pip install -r requirements.txt
$BOLD_YELLOW && echo "---------------- git submodule update --init --recursive -------------" && $RESET
git config --global --add safe.directory "*"
git submodule update --init --recursive
Expand Down
5 changes: 2 additions & 3 deletions examples/huggingface/neural_speed/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
intel_extension_for_transformers
neural-speed
lm-eval
lm-eval==0.4.2
sentencepiece
gguf
--extra-index-url https://download.pytorch.org/whl/cpu
torch==2.3.0+cpu
transformers
intel_extension_for_pytorch==2.3.0
tiktoken
transformers_stream_generator
zipfile38
zipfile38
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def preprocess_function(examples):

# Get the metric function
if data_args.task_name is not None:
metric = load_metric("glue", data_args.task_name)
metric = load_metric("glue", data_args.task_name,trust_remote_code=True)
else:
metric = load_metric("accuracy")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
neural-compressor
intel-extension-for-transformers==1.4.2
neural-compressor==2.6
transformers
accelerate
datasets >= 1.8.0
Expand Down
5 changes: 3 additions & 2 deletions intel_extension_for_transformers/qbits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
# limitations under the License.

import torch
if not torch.xpu._is_compiled():
from intel_extension_for_transformers.qbits_py import * # pylint: disable=E0401, E0611
import intel_extension_for_transformers
if "gpu" not in intel_extension_for_transformers.__version__:
from intel_extension_for_transformers.qbits_py import * # pylint: disable=E0401, E0611
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,12 @@ def forward(self, input: torch.Tensor) -> tuple[torch.Tensor, None]:
or device_map == torch.device("cpu")
) and model.config.model_type == "chatglm":
model = model.float()
if (
not torch.cuda.is_available()
or device_map == "cpu"
or device_map == torch.device("cpu")
) and model.config.model_type == "mpt":
model.config.architectures = ["MptForCausalLM"]
model.eval()
model_type = model.config.model_type.replace("_", "-")

Expand Down Expand Up @@ -1077,6 +1083,7 @@ def calib_func(model):
recipes=quantization_config.recipes,
example_inputs=example_inputs,
)

model = quantization.fit(
model,
conf,
Expand Down
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
from pathlib import Path
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
from setuptools_scm import get_version

result = subprocess.Popen("pip install -r requirements.txt", shell=True)
result.wait()


def is_intel_gpu_available():
import torch
import intel_extension_for_pytorch as ipex
Expand Down Expand Up @@ -286,6 +288,9 @@ def check_submodules():
"intel_extension_for_transformers/transformers/runtime/"),
])
cmdclass = {'build_ext': CMakeBuild}
itrex_version = get_version()
if IS_INTEL_GPU:
itrex_version = itrex_version + "-gpu"

setup(
name="intel-extension-for-transformers",
Expand Down Expand Up @@ -324,4 +329,5 @@ def check_submodules():
],
setup_requires=['setuptools_scm'],
use_scm_version=True,
version=itrex_version
)

0 comments on commit 2618e6f

Please sign in to comment.