Skip to content

Commit 401013a

Browse files
authored
Remove chatglm_C Module to Eliminate LGPL Dependency (#11178)
* remove chatglm_C.**.pyd to solve ngsolve weak copyright vunl * fix style check error * remove chatglm native int4 from langchain
1 parent 50b5f44 commit 401013a

File tree

14 files changed

+19
-690
lines changed

14 files changed

+19
-690
lines changed

.github/workflows/llm-binary-build.yml

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ jobs:
7272
export http_proxy=${HTTP_PROXY}
7373
export https_proxy=${HTTPS_PROXY}
7474
yum install -y gcc-toolset-11 cmake git
75-
conda remove -n python39 --all -y
76-
conda create -n python39 python=3.9 -y
77-
conda remove -n python310 --all -y
78-
conda create -n python310 python=3.10 -y
79-
conda remove -n python311 --all -y
80-
conda create -n python311 python=3.11 -y
8175
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # actions/checkout@v3
8276
with:
8377
repository: "intel-analytics/llm.cpp"
@@ -109,42 +103,6 @@ jobs:
109103
mv build/libstarcoder-api.so release/libstarcoder-api.so
110104
mv build/quantize-starcoder release/quantize-starcoder
111105
mv build/libstarcoder.so release/libstarcoder_avxvnni.so
112-
- name: Build Chatglm
113-
shell: bash
114-
run: |
115-
source activate python39 || conda activate python39
116-
cd src/chatglm
117-
scl enable gcc-toolset-11 "cmake -B build"
118-
scl enable gcc-toolset-11 "cmake --build build --config Release -j"
119-
- name: Move Chatglm binaries
120-
shell: bash
121-
run: |
122-
mv src/chatglm/build/main release/main-chatglm_vnni
123-
mv src/chatglm/build/_C.cpython-39-x86_64-linux-gnu.so release/chatglm_C.cpython-39-x86_64-linux-gnu.so
124-
- name: Build Chatglm Py310
125-
shell: bash
126-
run: |
127-
source activate python310 || conda activate python310
128-
cd src/chatglm
129-
rm -r build
130-
scl enable gcc-toolset-11 "cmake -B build"
131-
scl enable gcc-toolset-11 "cmake --build build --config Release -j"
132-
- name: Move Chatglm binaries Py310
133-
shell: bash
134-
run: |
135-
mv src/chatglm/build/_C.cpython-310-x86_64-linux-gnu.so release/chatglm_C.cpython-310-x86_64-linux-gnu.so
136-
- name: Build Chatglm Py311
137-
shell: bash
138-
run: |
139-
source activate python311 || conda activate python311
140-
cd src/chatglm
141-
rm -r build
142-
scl enable gcc-toolset-11 "cmake -B build"
143-
scl enable gcc-toolset-11 "cmake --build build --config Release -j"
144-
- name: Move Chatglm binaries Py311
145-
shell: bash
146-
run: |
147-
mv src/chatglm/build/_C.cpython-311-x86_64-linux-gnu.so release/chatglm_C.cpython-311-x86_64-linux-gnu.so
148106
- name: Archive build files
149107
uses: actions/upload-artifact@v3
150108
with:
@@ -155,9 +113,6 @@ jobs:
155113
shell: bash
156114
run: |
157115
make clean
158-
conda remove -n python39 --all -y
159-
conda remove -n python310 --all -y
160-
conda remove -n python311 --all -y
161116
162117
check-linux-avx512-artifact:
163118
if: ${{contains(inputs.platform, 'Linux')}}
@@ -286,8 +241,6 @@ jobs:
286241
export http_proxy=${HTTP_PROXY}
287242
export https_proxy=${HTTPS_PROXY}
288243
yum install -y gcc-toolset-11 cmake git
289-
conda remove -n python39 --all -y
290-
conda create -n python39 python=3.9 -y
291244
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # actions/checkout@v3
292245
with:
293246
repository: "intel-analytics/llm.cpp"
@@ -299,11 +252,6 @@ jobs:
299252
run: |
300253
scl enable gcc-toolset-11 "cmake -DONLYAVX=OFF -DONLYAVX2=OFF -B build"
301254
scl enable gcc-toolset-11 "cmake --build build --config Release -j"
302-
# build chatglm
303-
source activate python39 || conda activate python39
304-
cd src/chatglm
305-
scl enable gcc-toolset-11 "cmake -B build"
306-
scl enable gcc-toolset-11 "cmake --build build --config Release -j"
307255
- name: Move amx release binary
308256
shell: bash
309257
run: |
@@ -316,9 +264,6 @@ jobs:
316264
mv build/libgptneox.so amx_release/libgptneox_amx.so
317265
mv build/quantize-starcoder amx_release/quantize-starcoder_amx
318266
mv build/libstarcoder.so amx_release/libstarcoder_amx.so
319-
# chatglm binary files
320-
mv src/chatglm/build/main amx_release/main-chatglm_amx
321-
# mv src/chatglm/build/_C.cpython-39-x86_64-linux-gnu.so amx_release/chatglm_C.cpython-39-x86_64-linux-gnu.so
322267
- name: Archive amx build files
323268
uses: actions/upload-artifact@v3
324269
with:
@@ -329,7 +274,6 @@ jobs:
329274
shell: bash
330275
run: |
331276
make clean
332-
conda remove -n python39 --all -y
333277
334278
check-windows-avx2-artifact:
335279
if: ${{contains(inputs.platform, 'Windows')}}
@@ -393,10 +337,6 @@ jobs:
393337
needs: check-windows-avx-vnni-artifact
394338
if: needs.check-windows-avx-vnni-artifact.outputs.if-exists == 'false'
395339
steps:
396-
- name: Set up Python
397-
uses: actions/setup-python@v4
398-
with:
399-
python-version: "3.9"
400340
- name: Set access token
401341
run: |
402342
echo "github_access_token=$env:GITHUB_ACCESS_TOKEN" >> $env:GITHUB_ENV
@@ -438,47 +378,6 @@ jobs:
438378
# mv build/Release/main-starcoder.exe release/main-starcoder_vnni.exe
439379
mv build/Release/quantize-starcoder.exe release/quantize-starcoder_vnni.exe
440380
mv build/Release/starcoder.dll release/libstarcoder_vnni.dll
441-
- name: Build Chatglm
442-
shell: powershell
443-
run: |
444-
cd src/chatglm
445-
cmake -DAVXVNNI=ON -B build
446-
cmake --build build --config Release -j
447-
- name: Move Chatglm binaries
448-
shell: powershell
449-
run: |
450-
mv src/chatglm/build/Release/main.exe release/main-chatglm_vnni.exe
451-
mv src/chatglm/build/Release/_C.cp39-win_amd64.pyd release/chatglm_C.cp39-win_amd64.pyd
452-
- name: Set up Python
453-
uses: actions/setup-python@v4
454-
with:
455-
python-version: "3.10"
456-
- name: Build Chatglm Py310
457-
shell: powershell
458-
run: |
459-
cd src/chatglm
460-
rm -r build
461-
cmake -DAVXVNNI=ON -B build
462-
cmake --build build --config Release -j
463-
- name: Move Chatglm binaries Py310
464-
shell: powershell
465-
run: |
466-
mv src/chatglm/build/Release/_C.cp310-win_amd64.pyd release/chatglm_C.cp310-win_amd64.pyd
467-
- name: Set up Python
468-
uses: actions/setup-python@v4
469-
with:
470-
python-version: "3.11"
471-
- name: Build Chatglm Py311
472-
shell: powershell
473-
run: |
474-
cd src/chatglm
475-
rm -r build
476-
cmake -DAVXVNNI=ON -B build
477-
cmake --build build --config Release -j
478-
- name: Move Chatglm binaries Py311
479-
shell: powershell
480-
run: |
481-
mv src/chatglm/build/Release/_C.cp311-win_amd64.pyd release/chatglm_C.cp311-win_amd64.pyd
482381
- name: Archive build files
483382
uses: actions/upload-artifact@v3
484383
with:

docs/readthedocs/source/doc/LLM/Overview/KeyFeatures/langchain_api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You may also convert Hugging Face *Transformers* models into native INT4 format,
3131
```eval_rst
3232
.. note::
3333
34-
* Currently only llama/bloom/gptneox/starcoder/chatglm model families are supported; for other models, you may use the Hugging Face ``transformers`` INT4 format as described `above <./langchain_api.html#using-hugging-face-transformers-int4-format>`_.
34+
* Currently only llama/bloom/gptneox/starcoder model families are supported; for other models, you may use the Hugging Face ``transformers`` INT4 format as described `above <./langchain_api.html#using-hugging-face-transformers-int4-format>`_.
3535
3636
* You may choose the corresponding API developed for specific native models to load the converted model.
3737
```
@@ -41,9 +41,9 @@ from ipex_llm.langchain.llms import LlamaLLM
4141
from ipex_llm.langchain.embeddings import LlamaEmbeddings
4242
from langchain.chains.question_answering import load_qa_chain
4343

44-
# switch to ChatGLMEmbeddings/GptneoxEmbeddings/BloomEmbeddings/StarcoderEmbeddings to load other models
44+
# switch to GptneoxEmbeddings/BloomEmbeddings/StarcoderEmbeddings to load other models
4545
embeddings = LlamaEmbeddings(model_path='/path/to/converted/model.bin')
46-
# switch to ChatGLMLLM/GptneoxLLM/BloomLLM/StarcoderLLM to load other models
46+
# switch to GptneoxLLM/BloomLLM/StarcoderLLM to load other models
4747
ipex_llm = LlamaLLM(model_path='/path/to/converted/model.bin')
4848

4949
doc_chain = load_qa_chain(ipex_llm, ...)

docs/readthedocs/source/doc/PythonAPI/LLM/langchain.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ IPEX-LLM provides ``TransformersLLM`` and ``TransformersPipelineLLM``, which imp
3131
Native Model
3232
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3333

34-
For ``llama``/``chatglm``/``bloom``/``gptneox``/``starcoder`` model families, you could also use the following LLM wrappers with the native (cpp) implementation for maximum performance.
34+
For ``llama``/``bloom``/``gptneox``/``starcoder`` model families, you could also use the following LLM wrappers with the native (cpp) implementation for maximum performance.
3535

3636
.. tabs::
3737

@@ -47,18 +47,6 @@ For ``llama``/``chatglm``/``bloom``/``gptneox``/``starcoder`` model families, yo
4747
.. automethod:: stream
4848
.. automethod:: get_num_tokens
4949

50-
.. tab:: ChatGLM
51-
52-
.. autoclass:: ipex_llm.langchain.llms.ChatGLMLLM
53-
:members:
54-
:undoc-members:
55-
:show-inheritance:
56-
:exclude-members: ggml_model, ggml_module, client, model_path, kwargs
57-
58-
.. automethod:: validate_environment
59-
.. automethod:: stream
60-
.. automethod:: get_num_tokens
61-
6250
.. tab:: Bloom
6351

6452
.. autoclass:: ipex_llm.langchain.llms.BloomLLM

python/llm/example/CPU/Native-Models/native_int4_pipeline.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ def load(model_path, model_family, n_threads):
3636
"llama": LlamaForCausalLM,
3737
"gptneox": GptneoxForCausalLM,
3838
"bloom": BloomForCausalLM,
39-
"starcoder": StarcoderForCausalLM,
40-
"chatglm": ChatGLMForCausalLM
39+
"starcoder": StarcoderForCausalLM
4140
}
4241

4342
if model_family in model_family_to_class:
@@ -55,7 +54,7 @@ def load(model_path, model_family, n_threads):
5554

5655
def inference(llm, repo_id_or_model_path, model_family, prompt):
5756

58-
if model_family in ['llama', 'gptneox', 'bloom', 'starcoder', 'chatglm']:
57+
if model_family in ['llama', 'gptneox', 'bloom', 'starcoder']:
5958
# ------ Option 1: Use IPEX-LLM based tokenizer
6059
print('-'*20, ' IPEX-LLM based tokenizer ', '-'*20)
6160
st = time.time()
@@ -109,9 +108,9 @@ def main():
109108
parser.add_argument('--thread-num', type=int, default=2, required=True,
110109
help='Number of threads to use for inference')
111110
parser.add_argument('--model-family', type=str, default='llama', required=True,
112-
choices=["llama", "llama2", "bloom", "gptneox", "starcoder", "chatglm"],
111+
choices=["llama", "llama2", "bloom", "gptneox", "starcoder"],
113112
help="The model family of the large language model (supported option: 'llama', 'llama2', "
114-
"'gptneox', 'bloom', 'starcoder', 'chatglm')")
113+
"'gptneox', 'bloom', 'starcoder')")
115114
parser.add_argument('--repo-id-or-model-path', type=str, required=True,
116115
help='The path to the huggingface checkpoint folder')
117116
parser.add_argument('--prompt', type=str, default='Once upon a time, there existed a little girl who liked to have adventures. ',

python/llm/setup.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,7 @@
8686
"quantize-llama_vnni.exe",
8787
"quantize-gptneox_vnni.exe",
8888
"quantize-bloom_vnni.exe",
89-
"quantize-starcoder_vnni.exe",
90-
91-
"main-chatglm_vnni.exe",
92-
"chatglm_C.cp39-win_amd64.pyd",
93-
"chatglm_C.cp310-win_amd64.pyd",
94-
"chatglm_C.cp311-win_amd64.pyd"
89+
"quantize-starcoder_vnni.exe"
9590
]
9691
linux_binarys = [
9792
"libllama_avx.so",
@@ -125,13 +120,7 @@
125120
"main-llama",
126121
"main-gptneox",
127122
"main-bloom",
128-
"main-starcoder",
129-
130-
"main-chatglm_vnni",
131-
"main-chatglm_amx",
132-
"chatglm_C.cpython-39-x86_64-linux-gnu.so",
133-
"chatglm_C.cpython-310-x86_64-linux-gnu.so",
134-
"chatglm_C.cpython-311-x86_64-linux-gnu.so"
123+
"main-starcoder"
135124
]
136125

137126
ext_lib_urls = [

python/llm/src/ipex_llm/ggml/convert.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ def _convert_starcoder(model_path, outfile_dir, outtype):
7676
_convert_starcoder_hf_to_ggml(model_path, outfile_dir, outtype)
7777

7878

79-
def _convert_chatglm(model_path, outfile_dir, outtype):
80-
return _convert_chatglm_hf_to_ggml(model_path, outfile_dir, outtype)
81-
82-
8379
def _convert_to_ggml(model_path: str, outfile_dir: str,
8480
model_family: str = 'llama', outtype: str="fp16"):
8581
"""

python/llm/src/ipex_llm/ggml/convert_model.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import os
1717
import time
1818
from pathlib import Path
19-
from ipex_llm.ggml.convert import _convert_to_ggml, _convert_chatglm
19+
from ipex_llm.ggml.convert import _convert_to_ggml
2020
from ipex_llm.ggml.quantize import quantize
2121
from ipex_llm.utils.common import invalidInputError
2222
import argparse
@@ -54,9 +54,9 @@ def convert_model(input_path: str,
5454
# make sure directory exists
5555
os.makedirs(output_path, exist_ok=True)
5656
# check input value
57-
invalidInputError(model_family in ['llama', 'bloom', 'gptneox', 'starcoder', 'chatglm'],
57+
invalidInputError(model_family in ['llama', 'bloom', 'gptneox', 'starcoder'],
5858
"Now we only support quantization of model \
59-
family('llama', 'bloom', 'gptneox', 'starcoder', 'chatglm')",
59+
family('llama', 'bloom', 'gptneox', 'starcoder')",
6060
"{} is not in the list.".format(model_family))
6161
invalidInputError(os.path.isdir(output_path),
6262
"The output_path {} was not a directory".format(output_path))
@@ -78,12 +78,6 @@ def convert_model(input_path: str,
7878
family('llama', 'gptneox', 'starcoder')",
7979
"{} is not in the list.".format(model_family))
8080

81-
# chatglm merges convertion and quantization into one operation.
82-
if model_family == 'chatglm':
83-
return _convert_chatglm(model_path=input_path,
84-
outfile_dir=output_path,
85-
outtype=dtype)
86-
8781
if tmp_path is not None:
8882
model_name = Path(input_path).stem
8983
tmp_ggml_file_path = os.path.join(tmp_path, f'{model_name}_{int(time.time())}')

python/llm/src/ipex_llm/ggml/model/chatglm/__init__.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)