Skip to content

Commit

Permalink
Merge pull request #71 from sammysun0711/fix-causal-lm-for-llama
Browse files Browse the repository at this point in the history
Fix causal_lm cpp demo for llama architecture
  • Loading branch information
ilya-lavrenov authored Dec 14, 2023
2 parents 27cdc2c + 3475e00 commit 424c46c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: casual_lm_cpp
name: causal_lm_cpp
on:
pull_request:
paths:
- text_generation/casual_lm/cpp/**
- '!text_generation/casual_lm/cpp/README.md'
- text_generation/causal_lm/cpp/**
- '!text_generation/causal_lm/cpp/README.md'
- thirdparty/openvino_contrib
- .github/workflows/casual_lm_cpp.yml
- .github/workflows/causal_lm_cpp.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
casual_lm_cpp:
causal_lm_cpp:
runs-on: ubuntu-20.04-8-cores
steps:
- uses: actions/checkout@v4
Expand All @@ -19,4 +19,4 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.8
- run: ./text_generation/casual_lm/cpp/set_up_and_run.sh
- run: ./text_generation/causal_lm/cpp/set_up_and_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.15)
project(casual_lm)
project(causal_lm)

# Build user_ov_extensions
list(APPEND CUSTOM_OPERATIONS tokenizer)
add_subdirectory(../../../thirdparty/openvino_contrib/modules/custom_operations/ "${CMAKE_CURRENT_BINARY_DIR}/custom_operations/")

add_executable(casual_lm casual_lm.cpp)
target_compile_definitions(casual_lm PRIVATE USER_OV_EXTENSIONS_PATH=\"$<TARGET_FILE:user_ov_extensions>\")
add_executable(causal_lm causal_lm.cpp)
target_compile_definitions(causal_lm PRIVATE USER_OV_EXTENSIONS_PATH=\"$<TARGET_FILE:user_ov_extensions>\")
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
target_link_libraries(casual_lm PRIVATE openvino::runtime user_ov_extensions)
set_target_properties(casual_lm PROPERTIES CXX_STANDARD 17)
set_target_properties(casual_lm PROPERTIES CXX_STANDARD_REQUIRED ON)
target_link_libraries(causal_lm PRIVATE openvino::runtime user_ov_extensions)
set_target_properties(causal_lm PROPERTIES CXX_STANDARD 17)
set_target_properties(causal_lm PROPERTIES CXX_STANDARD_REQUIRED ON)
if(MSVC)
target_compile_options(
casual_lm PRIVATE
causal_lm PRIVATE
/Wall # Display all warnings
/wd4710 /wd4711 # Disable the inline warnings
/EHsc # Enable standard C++ stack unwinding, assume functions with extern "C" never throw
)
else()
target_compile_options(casual_lm PRIVATE -Wall) # Display all warnings
target_compile_options(causal_lm PRIVATE -Wall) # Display all warnings
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ python ./convert_tokenizers.py ./Llama-2-7b-hf/

## Run

Usage: `casual_lm <openvino_model.xml> <tokenizer.xml> <detokenizer.xml> "<prompt>"`
Usage: `causal_lm <openvino_model.xml> <tokenizer.xml> <detokenizer.xml> "<prompt>"`

Example: `./build/casual_lm ./Llama-2-7b-hf/openvino_model.xml ./tokenizer.xml ./detokenizer.xml "Why is the Sun yellow?"`
Example: `./build/causal_lm ./Llama-2-7b-hf/openvino_model.xml ./tokenizer.xml ./detokenizer.xml "Why is the Sun yellow?"`

To enable Unicode characters for Windows cmd open `Region` settings from `Control panel`. `Administrative`->`Change system locale`->`Beta: Use Unicode UTF-8 for worldwide language support`->`OK`. Reboot.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function abs_path() {
cd "`abs_path`"

mkdir ./ov/
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_ubuntu20_2023.1.0.12185.47b736f63ed_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.2/linux/l_openvino_toolkit_ubuntu20_2023.2.0.13089.cfd42bd2cb0_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
sudo ./ov/install_dependencies/install_openvino_dependencies.sh

source ./ov/setupvars.sh
Expand All @@ -23,4 +23,4 @@ cmake --build ./build/ --config Release -j
wait

python ./convert_tokenizers.py ./open_llama_3b_v2/
./build/casual_lm ./open_llama_3b_v2/openvino_model.xml ./tokenizer.xml ./detokenizer.xml "return 0"
./build/causal_lm ./open_llama_3b_v2/openvino_model.xml ./tokenizer.xml ./detokenizer.xml "return 0"

0 comments on commit 424c46c

Please sign in to comment.