-
Notifications
You must be signed in to change notification settings - Fork 250
Add support for tiktoken and refactored runner structure #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ab90ffd
Add support for tiktoken and refactored runner structure
larryliu0820 2f3ed1a
Fix CI
larryliu0820 123a13d
Fix more CI
larryliu0820 aa2e182
Further fix CI
larryliu0820 9428d15
Lint`
larryliu0820 16dc690
Update build_android.sh
larryliu0820 b475e6d
Rebase
larryliu0820 a975f2b
Fix cmake commands in CI job
larryliu0820 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "tokenizer/third-party/abseil-cpp"] | ||
path = tokenizer/third-party/abseil-cpp | ||
url = https://github.com/abseil/abseil-cpp.git | ||
[submodule "tokenizer/third-party/re2"] | ||
path = tokenizer/third-party/re2 | ||
url = https://github.com/google/re2.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
set(CMAKE_CXX_STANDARD 17) | ||
IF(DEFINED ENV{TORCHCHAT_ROOT}) | ||
set(TORCHCHAT_ROOT $ENV{TORCHCHAT_ROOT}) | ||
ELSE() | ||
set(TORCHCHAT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
ENDIF() | ||
|
||
project(Torchchat) | ||
|
||
# include tokenizer | ||
add_subdirectory(tokenizer) | ||
|
||
# include et_run executable | ||
include(runner/et.cmake) | ||
if(TARGET et_run) | ||
target_link_libraries(et_run PUBLIC tokenizer) | ||
endif() | ||
|
||
# include aoti_run executable | ||
include(runner/aoti.cmake) | ||
if(TARGET aoti_run) | ||
target_link_libraries(aoti_run tokenizer) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
set(CMAKE_CXX_STANDARD 17) | ||
IF(DEFINED ENV{TORCHCHAT_ROOT}) | ||
set(TORCHCHAT_ROOT $ENV{TORCHCHAT_ROOT}) | ||
ELSE() | ||
set(TORCHCHAT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
ENDIF() | ||
|
||
find_package(CUDA) | ||
|
||
find_package(Torch) | ||
if(Torch_FOUND) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${TORCH_CXX_FLAGS} -fpermissive") | ||
|
||
add_executable(aoti_run runner/run.cpp) | ||
|
||
target_compile_options(aoti_run PUBLIC -D__AOTI_MODEL__) | ||
target_include_directories(aoti_run PRIVATE ${TORCHCHAT_ROOT}/runner) | ||
target_link_libraries(aoti_run "${TORCH_LIBRARIES}" m) | ||
set_property(TARGET aoti_run PROPERTY CXX_STANDARD 17) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
IF(DEFINED ENV{ET_BUILD_DIR}) | ||
set(ET_BUILD_DIR $ENV{ET_BUILD_DIR}) | ||
ELSE() | ||
set(ET_BUILD_DIR "et-build") | ||
ENDIF() | ||
|
||
MESSAGE(STATUS "Using ET BUILD DIR: --[${ET_BUILD_DIR}]--") | ||
|
||
IF(DEFINED ENV{CMAKE_OUT_DIR}) | ||
set(CMAKE_OUT_DIR $ENV{CMAKE_OUT_DIR}) | ||
ELSE() | ||
set(CMAKE_OUT_DIR "cmake-out") | ||
ENDIF() | ||
|
||
MESSAGE(STATUS "Using ET BUILD DIR: --[${ET_BUILD_DIR}]--") | ||
|
||
IF(DEFINED ENV{TORCHCHAT_ROOT}) | ||
set(TORCHCHAT_ROOT $ENV{TORCHCHAT_ROOT}) | ||
ELSE() | ||
set(TORCHCHAT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
ENDIF() | ||
|
||
project(Torchchat) | ||
|
||
include(CMakePrintHelpers) | ||
include(runner/Utils.cmake) | ||
|
||
cmake_print_variables(TORCHCHAT_ROOT) | ||
|
||
MESSAGE(STATUS "Looking for excutorch in ${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/install/lib/cmake/ExecuTorch") | ||
set(executorch_DIR ${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/install/lib/cmake/ExecuTorch) | ||
find_package(executorch CONFIG PATHS ${executorch_DIR}) | ||
if(executorch_FOUND) | ||
set(_common_include_directories ${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/src) | ||
|
||
cmake_print_variables(_common_include_directories) | ||
|
||
target_include_directories(executorch INTERFACE ${_common_include_directories}) # Ideally ExecuTorch installation process would do this | ||
add_executable(et_run runner/run.cpp) | ||
|
||
target_compile_options(et_run PUBLIC -D__ET__MODEL -D_GLIBCXX_USE_CXX11_ABI=1) | ||
|
||
# Link ET runtime + extensions | ||
target_link_libraries( | ||
et_run PRIVATE | ||
executorch | ||
extension_module | ||
${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/src/executorch/${CMAKE_OUT_DIR}/extension/data_loader/libextension_data_loader.a # This one does not get installed by ExecuTorch | ||
optimized_kernels | ||
quantized_kernels | ||
portable_kernels | ||
cpublas | ||
eigen_blas | ||
# The libraries below need to be whole-archived linked | ||
optimized_native_cpu_ops_lib | ||
quantized_ops_lib | ||
xnnpack_backend | ||
XNNPACK | ||
pthreadpool | ||
cpuinfo | ||
) | ||
target_link_options_shared_lib(optimized_native_cpu_ops_lib) | ||
target_link_options_shared_lib(quantized_ops_lib) | ||
target_link_options_shared_lib(xnnpack_backend) | ||
# Not clear why linking executorch as whole-archive outside android/apple is leading | ||
# to double registration. Most likely because of linkage issues. | ||
# Will figure this out later. Until then use this. | ||
if(ANDROID OR APPLE) | ||
target_link_options_shared_lib(executorch) | ||
endif() | ||
|
||
target_link_libraries(et_run PRIVATE | ||
"$<LINK_LIBRARY:WHOLE_ARCHIVE,${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/src/executorch/${CMAKE_OUT_DIR}/examples/models/llama2/custom_ops/libcustom_ops.a>") | ||
|
||
# This one is needed for cpuinfo where it uses android specific log lib | ||
if(ANDROID) | ||
target_link_libraries(et_run PRIVATE log) | ||
endif() | ||
|
||
# Adding target_link_options_shared_lib as commented out below leads to this: | ||
# | ||
# CMake Error at Utils.cmake:22 (target_link_options): | ||
# Cannot specify link options for target | ||
# "/Users/scroy/etorch/torchchat/et-build/src/executorch/${CMAKE_OUT_DIR}/examples/models/llama2/custom_ops/libcustom_ops_lib.a" | ||
# which is not built by this project. | ||
# Call Stack (most recent call first): | ||
# Utils.cmake:30 (macos_kernel_link_options) | ||
# CMakeLists.txt:41 (target_link_options_shared_lib) | ||
# | ||
#target_link_options_shared_lib("${TORCHCHAT_ROOT}/et-build/src/executorch/${CMAKE_OUT_DIR}/examples/models/llama2/custom_ops/libcustom_ops_lib.a") # This one does not get installed by ExecuTorch | ||
|
||
# This works on mac, but appears to run into issues on linux | ||
# It is needed to solve: | ||
# E 00:00:00.055965 executorch:method.cpp:536] Missing operator: [8] llama::sdpa_with_kv_cache.out | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update instructions to do git clone recursive, git submodule updates?
This is what PyTorch tells users:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah where should I update the doc?