Skip to content
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

[WASI-NN] neural_speed: add backend structure #3303

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

grorge123
Copy link

No description provided.

Copy link
Member

juntao commented Mar 25, 2024

Hello, I am a code review bot on flows.network. Here are my reviews of code commits in this PR.


@github-actions github-actions bot added c-Plugin An issue related to WasmEdge Plugin c-WASI-NN c-CMake labels Mar 25, 2024
@grorge123 grorge123 force-pushed the neural_speed branch 4 times, most recently from f916aeb to af7d519 Compare March 25, 2024 11:53
@grorge123 grorge123 requested a review from q82419 as a code owner March 25, 2024 11:53
@github-actions github-actions bot added the c-Test An issue/PR to enhance the test suite label Mar 25, 2024
@github-actions github-actions bot removed the c-Test An issue/PR to enhance the test suite label Mar 25, 2024
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.84%. Comparing base (5a65509) to head (107c232).
Report is 3 commits behind head on master.

Current head 107c232 differs from pull request most recent head c4b523c

Please upload reports for the commit c4b523c to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3303   +/-   ##
=======================================
  Coverage   79.83%   79.84%           
=======================================
  Files         253      253           
  Lines       34948    34948           
  Branches     6138     6122   -16     
=======================================
+ Hits        27902    27905    +3     
+ Misses       5625     5623    -2     
+ Partials     1421     1420    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@grorge123 grorge123 marked this pull request as draft March 25, 2024 12:55
@grorge123 grorge123 marked this pull request as ready for review March 29, 2024 06:22
@grorge123 grorge123 changed the title [WIP] [WASI-NN] neural_speed: add backend struct [WASI-NN] neural_speed: add backend structure Mar 29, 2024
@grorge123 grorge123 requested a review from hydai as a code owner April 8, 2024 06:35
@github-actions github-actions bot added the c-Test An issue/PR to enhance the test suite label Apr 8, 2024
@github-actions github-actions bot added c-CLI An issue related to WasmEdge CLI tools c-Installer c-CI labels Apr 25, 2024
@github-actions github-actions bot removed c-CLI An issue related to WasmEdge CLI tools c-Installer c-CI labels Apr 25, 2024
@grorge123 grorge123 force-pushed the neural_speed branch 3 times, most recently from a60159f to 984d13a Compare April 25, 2024 04:06
@grorge123 grorge123 force-pushed the neural_speed branch 5 times, most recently from ef72299 to 065fc95 Compare May 13, 2024 07:19
@hydai hydai added the v-0.14.1 label May 22, 2024
@@ -149,6 +149,64 @@ if(BACKEND STREQUAL "ggml")
endif()
endif()

if(BACKEND STREQUAL "neuralspeed")
find_package(simdjson QUIET)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We changed the way to find the simdjson package, please use the new way like this pr: #3426

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

#endif
void printImformation(Graph &GraphRef, Context &CxtRef) {
spdlog::info(
"[WASI-NN][Info] Neural speed backend: Number of input tokens: {}"sv,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to add [Info] here, because the spdlog::info will do this for you.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

"[WASI-NN][Debug] Neural speed: Model path not found in nn-preload, "
"write model into a tmpfile."sv);
}
// TODO: pass the model directly to ggml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to know the details of this TODO item.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It refers to ggml backend. Although current implementation is enough. Should I remove it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

auto &CxtRef = Env.NNContext[ContextId].get<Context>();
auto &GraphRef = Env.NNGraph[CxtRef.GraphId].get<Graph>();
if (!Py_IsInitialized()) {
spdlog::info(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use spdlog::error here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

Expect<WASINN::ErrNo> compute(WasiNNEnvironment &Env,
uint32_t ContextId) noexcept {
if (!Py_IsInitialized()) {
spdlog::info(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use spdlog::error here. This is a fatal error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

"[WASI-NN] neural speed backend: Input transfer tensor failed."sv);
return WASINN::ErrNo::InvalidArgument;
}
// PyObject *GenerateArgs = PyTuple_Pack(1, LongTensor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this line comment out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

}
}
Py_DECREF(Result);
// Py_DECREF(GenerateArgs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

elseif(BACKEND STREQUAL "neuralspeed")
message( STATUS "Download ML artifacts to ${CMAKE_CURRENT_BINARY_DIR}/wasinn_neural_speed_fixtures")
download(
https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q4_0.gguf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to download this huge file if we would like to do the test?
Is it possible to have a small one instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

uint32_t BuilderPtr = UINT32_C(0);
uint32_t LoadEntryPtr = UINT32_C(0);
uint32_t SetInputEntryPtr = UINT32_C(0);
uint32_t OutBoundPtr = UINT32_C(61000 * 65536);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use UINT32_C(61000) * UINT32_C(65536)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed. Please check, thank you.

Copy link
Member

@hydai hydai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I think we should also add the workflow to build and upload the assets.

return ErrNo::InvalidEncoding;
}
if (Doc.at_key("model_type").error() == simdjson::SUCCESS) {
std::string_view model_type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelType.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it.

@github-actions github-actions bot added the c-CI label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-CI c-CMake c-Plugin An issue related to WasmEdge Plugin c-Test An issue/PR to enhance the test suite c-WASI-NN v-0.14.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants