Skip to content

Commit

Permalink
[CPP-Model] Support Falcon-7B C++ inference (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhentaoyu committed Jul 6, 2023
1 parent a944faa commit 7627232
Show file tree
Hide file tree
Showing 6 changed files with 1,096 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ python scripts/convert_gptneox.py ${input_model_name_or_path} ${output_path} 0
python scripts/convert_mpt.py ${input_model_name_or_path} ${output_path} 0

./build/bin/quant_mpt ${output_path}/ne-f32.bin ${output_path}/ne-q8.bin "q8_0"

# convert the pytorch falcon model to llama.cpp format (0 for fp32 model type)
python scripts/convert_falcon.py ${input_model_name_or_path} ${output_path} 0

./build/bin/quant_falcon ${output_path}/ne-f32.bin ${output_path}/ne-q8.bin q8_0
```

### Run Models
Expand All @@ -47,11 +52,11 @@ Running LLAMA model, for details please refer to [LLaMA model documentation](./a
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"
```

Running GPT-NEOX/ MPT model, please use main_gptneox/ main_mpt.
Running GPT-NEOX/ MPT / FALCON model, please use `main_gptneox` / `main_mpt` / `main_falcon`.

```bash
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"
```

### Supported model
Now we supports [GPT-NeoX](https://github.com/EleutherAI/gpt-neox), [LLaMA](https://github.com/facebookresearch/llama), [MPT](https://huggingface.co/mosaicml/mpt-7b).
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)
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(ChatLLAMA)
add_subdirectory(ChatGPTNEOX)
add_subdirectory(ChatMPT)
add_subdirectory(ChatFALCON)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(TARGET main_falcon)
add_executable_w_warning(${TARGET} main_falcon.cpp)
target_link_libraries(${TARGET} PUBLIC ne_layers common ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${TARGET} PRIVATE cxx_std_11)
if(TARGET BUILD_INFO)
add_dependencies(${TARGET} BUILD_INFO)
endif()

set(TARGET quant_falcon)
add_executable_w_warning(${TARGET} quant_falcon.cpp)
target_link_libraries(${TARGET} PUBLIC ne_layers common ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${TARGET} PRIVATE cxx_std_11)
if(TARGET BUILD_INFO)
add_dependencies(${TARGET} BUILD_INFO)
endif()

0 comments on commit 7627232

Please sign in to comment.