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

Commit 4269f96

Browse files
authored
[Graph] gpt-j optimization (#1088)
1 parent 2b40c87 commit 4269f96

File tree

16 files changed

+1954
-88
lines changed

16 files changed

+1954
-88
lines changed

intel_extension_for_transformers/backends/neural_engine/graph/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ include(cmake/Common.cmake)
113113

114114
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
115115
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
116+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
116117

117118
set(COMMON_HEADER_DIRS
118119
${PROJECT_SOURCE_DIR}

intel_extension_for_transformers/backends/neural_engine/graph/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@ Running LLAMA model, for details please refer to [LLaMA model documentation](./a
5252
OMP_NUM_THREADS=56 numactl -m 0 -C 0-55 ./build/bin/main_llama -m ~/llama.cpp/models/ne-model-q4_j.bin --seed 12 -c 512 -b 1024 -n 256 --keep 48 -t 56 --repeat-penalty 1.0 --color -p "She opened the door and see"
5353
```
5454

55-
Running GPT-NEOX/ MPT / FALCON model, please use `main_gptneox` / `main_mpt` / `main_falcon`.
55+
Running GPT-NEOX/ MPT / FALCON / GPT-J model, please use `main_gptneox` / `main_mpt` / `main_falcon` / `main_gptj`.
5656

5757
```bash
5858
OMP_NUM_THREADS=56 numactl -m 0 -C 0-55 ./build/bin/main_gptneox -m ${output_path}/ne-q8.bin --seed 12 -c 512 -b 1024 -n 256 -t 56 --repeat-penalty 1.0 -p "She opened the door and see"
5959
```
6060

61+
for GPT-J, you can also try python binds which is experimental currently:
62+
63+
```bash
64+
cp scripts/gptj_binding.py build
65+
cd build
66+
python gptj_binding.py
67+
```
68+
6169
### Supported model
62-
Now we supports [GPT-NeoX](https://github.com/EleutherAI/gpt-neox), [LLaMA](https://github.com/facebookresearch/llama), [MPT](https://huggingface.co/mosaicml/mpt-7b), [FALCON](https://huggingface.co/tiiuae/falcon-7b)
70+
Now we supports [GPT-NeoX](https://github.com/EleutherAI/gpt-neox), [LLaMA](https://github.com/facebookresearch/llama), [MPT](https://huggingface.co/mosaicml/mpt-7b), [FALCON](https://huggingface.co/tiiuae/falcon-7b), [GPT-J](https://huggingface.co/docs/transformers/model_doc/gptj)

intel_extension_for_transformers/backends/neural_engine/graph/application/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ add_library(${TARGET} OBJECT
1919
common.cpp
2020
)
2121

22-
if (BUILD_SHARED_LIBS)
23-
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
24-
endif()
22+
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
2523

2624
target_include_directories(${TARGET} PUBLIC .)
2725
target_compile_features(${TARGET} PUBLIC cxx_std_11)
@@ -33,3 +31,4 @@ add_subdirectory(ChatLLAMA)
3331
add_subdirectory(ChatGPTNEOX)
3432
add_subdirectory(ChatMPT)
3533
add_subdirectory(ChatFALCON)
34+
add_subdirectory(ChatGPTJ)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2023 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
set(TARGET main_gptj)
16+
add_executable_w_warning(${TARGET} main_gptj.cpp)
17+
target_link_libraries(${TARGET} PUBLIC ne_layers common ${CMAKE_THREAD_LIBS_INIT})
18+
target_compile_features(${TARGET} PRIVATE cxx_std_11)
19+
if(TARGET BUILD_INFO)
20+
add_dependencies(${TARGET} BUILD_INFO)
21+
endif()
22+
23+
set(TARGET quant_gptj)
24+
add_executable_w_warning(${TARGET} quant_gptj.cpp)
25+
target_link_libraries(${TARGET} PUBLIC ne_layers common ${CMAKE_THREAD_LIBS_INIT})
26+
target_compile_features(${TARGET} PRIVATE cxx_std_11)
27+
if(TARGET BUILD_INFO)
28+
add_dependencies(${TARGET} BUILD_INFO)
29+
endif()
30+
31+
set(TARGET GptjPyBind)
32+
add_library_w_warning(${TARGET} SHARED pybind_gptj.cpp)
33+
target_link_libraries(${TARGET} PUBLIC ne_layers common ${CMAKE_THREAD_LIBS_INIT})
34+
target_compile_features(${TARGET} PRIVATE cxx_std_11)
35+
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
36+
37+
set(TARGET pybind_gptj)
38+
add_executable_w_warning(${TARGET} pybind_gptj.cpp)
39+
target_link_libraries(${TARGET} PUBLIC ne_layers common ${CMAKE_THREAD_LIBS_INIT})
40+
target_compile_features(${TARGET} PRIVATE cxx_std_11)

0 commit comments

Comments
 (0)