From 49b844184326bc5a895f92f0dab03d393e9b08fa Mon Sep 17 00:00:00 2001 From: ivy-lv11 Date: Mon, 20 May 2024 17:00:35 +0800 Subject: [PATCH 1/2] modify example --- .../examples/more_data_type.py | 10 +++++++++ .../llama-index-llms-ipex-llm/pyproject.toml | 21 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/llama-index-integrations/llms/llama-index-llms-ipex-llm/examples/more_data_type.py b/llama-index-integrations/llms/llama-index-llms-ipex-llm/examples/more_data_type.py index 83ce5beed8281..74145b87e0a6a 100644 --- a/llama-index-integrations/llms/llama-index-llms-ipex-llm/examples/more_data_type.py +++ b/llama-index-integrations/llms/llama-index-llms-ipex-llm/examples/more_data_type.py @@ -33,11 +33,20 @@ def completion_to_prompt(completion): choices=["sym_int4", "asym_int4", "sym_int5", "asym_int5", "sym_int8"], help="The quantization type the model will convert to.", ) + parser.add_argument( + "--device", + "-d", + type=str, + default="xpu", + choices=["cpu", "xpu", "auto"], + help="The device the model will run on.", + ) args = parser.parse_args() model_name = args.model_name tokenizer_name = args.tokenizer_name low_bit = args.low_bit + device = args.device # load the model using low-bit format specified llm = IpexLLM.from_model_id( @@ -48,6 +57,7 @@ def completion_to_prompt(completion): load_in_low_bit=low_bit, completion_to_prompt=completion_to_prompt, generate_kwargs={"do_sample": False}, + device_map=device, ) print( diff --git a/llama-index-integrations/llms/llama-index-llms-ipex-llm/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-ipex-llm/pyproject.toml index 6dbb77a1d5d04..88a8f029a3ab7 100644 --- a/llama-index-integrations/llms/llama-index-llms-ipex-llm/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-ipex-llm/pyproject.toml @@ -35,8 +35,15 @@ version = "0.1.2" [tool.poetry.dependencies] python = ">=3.9,<4.0" llama-index-core = "^0.10.0" -torch = "<2.2.0" -ipex-llm = {allow-prereleases = true, extras = ["all"], version = "*"} +ipex-llm = {allow-prereleases = true, extras = ["llama-index"], version = ">=2.1.0b20240514"} +torch = {optional = true, source = "ipex-xpu-src-us", version = "2.1.0a0"} +torchvision = {optional = true, source = "ipex-xpu-src-us", version = "0.16.0a0"} +intel_extension_for_pytorch = {optional = true, source = "ipex-xpu-src-us", version = "2.1.10+xpu"} +bigdl-core-xe-21 = {optional = true, version = "*"} +bigdl-core-xe-esimd-21 = {optional = true, version = "*"} + +[tool.poetry.extras] +xpu = ["bigdl-core-xe-21", "bigdl-core-xe-esimd-21", "intel_extension_for_pytorch", "torch", "torchvision"] [tool.poetry.group.dev.dependencies] black = {extras = ["jupyter"], version = "<=23.9.1,>=23.7.0"} @@ -56,3 +63,13 @@ types-protobuf = "^4.24.0.4" types-redis = "4.5.5.0" types-requests = "2.28.11.8" # TODO: unpin when mypy>0.991 types-setuptools = "67.1.0.0" + +[[tool.poetry.source]] +name = "ipex-xpu-src-us" +priority = "explicit" +url = "https://pytorch-extension.intel.com/release-whl/stable/xpu/us/" + +[[tool.poetry.source]] +name = "ipex-xpu-src-cn" +priority = "supplemental" +url = "https://pytorch-extension.intel.com/release-whl/stable/xpu/cn/" From f2150dc68687e85f3a73d92a5d88cb6d0b1f1096 Mon Sep 17 00:00:00 2001 From: ivy-lv11 Date: Mon, 20 May 2024 17:24:32 +0800 Subject: [PATCH 2/2] workflow --- .github/workflows/publish_sub_package.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish_sub_package.yml b/.github/workflows/publish_sub_package.yml index 3dd6ae4bc18cb..79ad5f5d48dd4 100644 --- a/.github/workflows/publish_sub_package.yml +++ b/.github/workflows/publish_sub_package.yml @@ -4,6 +4,10 @@ on: push: branches: - main + pull_request: + branches: [main] + paths: + - "llama-index-integrations/**" env: POETRY_VERSION: "1.6.1" @@ -11,7 +15,7 @@ env: jobs: publish_subpackage_if_needed: - if: github.repository == 'run-llama/llama_index' + # if: github.repository == 'run-llama/llama_index' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -30,14 +34,11 @@ jobs: run: | echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -v llama-index-core | grep llama-index | grep pyproject | xargs)" >> $GITHUB_OUTPUT - name: Publish changed packages - env: - PYPI_TOKEN: ${{ secrets.LLAMA_INDEX_PYPI_TOKEN }} run: | - for file in ${{ steps.changed-files.outputs.changed_files }}; do + for file in llama-index-integrations/llms/llama-index-llms-ipex-llm/pyproject.toml; do cd `echo $file | sed 's/\/pyproject.toml//g'` poetry lock pip install -e . - poetry config pypi-token.pypi $PYPI_TOKEN - poetry publish --build + poetry publish --build --dry-run cd - done