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

rpc : backend refactoring #9912

Merged
merged 2 commits into from
Oct 18, 2024
Merged

Conversation

rgerganov
Copy link
Collaborator

Introduce structs for each request/response and separate the code which deals with serialization/deserialization.

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Oct 16, 2024
Comment on lines 322 to 324
// output serialization format: | ptr (8 bytes) | size (8 bytes) |
memcpy(&response.ptr, output.data(), sizeof(response.ptr));
memcpy(&response.size, output.data() + sizeof(response.ptr), sizeof(response.size));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is much better than the previous version. The idea would be to read directly into the struct from the network.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for looking into this, I get what you mean. Could you take another look and let me know if you agree?

I also noticed that all commands have a known output size, maybe we can skip sending output size from the server?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, that's exactly what I meant.

I also noticed that all commands have a known output size, maybe we can skip sending output size from the server?

I don't have a strong opinion about this either way. Some commands may have variable output size in the future, for example get_description in the device interface, and having the output size may help simplify the code a bit in that case, but it is probably not very important either way.

ggml/src/ggml-rpc.cpp Outdated Show resolved Hide resolved
Use structs for RPC request/response messages
@rgerganov rgerganov marked this pull request as ready for review October 18, 2024 07:25
@rgerganov rgerganov merged commit afd9909 into ggerganov:master Oct 18, 2024
53 checks passed
#pragma pack(1)
struct rpc_msg_alloc_buffer_req {
uint64_t size;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not really how pack(1) works. every struct after a single pack(1) will be affected, only after another pack() (empty), it will be the value from before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch, I have posted #9959 to fix this

drollings pushed a commit to drollings/llama.cpp that referenced this pull request Oct 18, 2024
* rpc : refactor backend

Use structs for RPC request/response messages

* rpc : refactor server
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull request Oct 29, 2024
* rpc : refactor backend

Use structs for RPC request/response messages

* rpc : refactor server
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
* rpc : refactor backend

Use structs for RPC request/response messages

* rpc : refactor server
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 2024
* rpc : refactor backend

Use structs for RPC request/response messages

* rpc : refactor server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants