forked from ggml-org/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 45
trace: event tracer for the RPC backend, rpc-server and llama-server #191
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
Draft
danielhanchen
wants to merge
20
commits into
feature/pipeline-groups
Choose a base branch
from
feature/rpc-trace
base: feature/pipeline-groups
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d7b1c24
trace: env gated event tracer for the RPC backend, rpc-server and lla…
danielhanchen d6693f8
trace: script for the traced layer split cells on the pair
danielhanchen 0f221c8
trace: keep the GPU timing probe per backend registry and index the m…
danielhanchen 9b7c554
cuda: map the event create, query and elapsed calls for HIP and MUSA
danielhanchen 6c4c6de
trace: flush the trace file periodically, and stop the peer rpc-serve…
danielhanchen 57d759d
trace: attribute the idle time of a step to the host phase it fell in…
danielhanchen abe16e4
Merge remote-tracking branch 'origin/feature/pipeline-groups' into fe…
danielhanchen 988e09e
trace: decompose one device's idle into scheduling and host stalls
danielhanchen 23d52c3
trace: reduce comment volume in the event tracer
danielhanchen e3bdc70
Merge the comment-reduced feature/pipeline-groups into feature/rpc-trace
danielhanchen 9debb3e
Merge the review fixes from feature/pipeline-groups into feature/rpc-…
danielhanchen e5f7c6d
Merge the parent-task cleanup fix from feature/pipeline-groups into f…
danielhanchen 6bf85af
Merge the router child_env fix from feature/pipeline-groups into feat…
danielhanchen aee4120
Merge the fit reservation and per-group thread pools from feature/pip…
danielhanchen c9f1a11
rpc: only send the trace clock sync to a peer that knows the command
danielhanchen 0405b69
cuda: keep trace state per device and stop waiting on the anchor
danielhanchen 3ab45d9
Merge the review fixes from feature/pipeline-groups into feature/rpc-…
danielhanchen 40d69fb
Merge the unified-KV context fix from feature/pipeline-groups into fe…
danielhanchen eee6abe
rpc-trace: fix six defects in trace capture and analysis
danielhanchen f98e338
rpc-trace: bound the flush window, fix the Windows startup divide, an…
danielhanchen 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
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,53 @@ | ||
| // Event tracer for the RPC backend and llama.cpp. Off unless GGML_RPC_TRACE (or rpc-server | ||
| // --trace) names a file; scripts/rpc_trace/merge.py aligns the JSON lines each process writes. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "ggml.h" | ||
| #include "ggml-backend.h" | ||
|
|
||
| #include <stdarg.h> | ||
| #include <stdint.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| // 1 while a trace file is open; read it at the call sites so a disabled tracer is one branch | ||
| GGML_API int ggml_trace_flag; | ||
|
|
||
| // `path` NULL means GGML_RPC_TRACE; the first call with a usable path wins | ||
| GGML_API int ggml_trace_open(const char * path, const char * role); | ||
| GGML_API void ggml_trace_close(void); | ||
|
|
||
| GGML_API int64_t ggml_trace_time_us(void); | ||
|
|
||
| GGML_API int ggml_trace_tid(void); | ||
|
|
||
| // tags every event this thread raises with a pipeline group, -1 means no group | ||
| GGML_API void ggml_trace_set_group(int group); | ||
| GGML_API int ggml_trace_get_group(void); | ||
|
|
||
| // names the tensor or graph the next RPC commands belong to; `name` must outlive the call | ||
| GGML_API void ggml_trace_set_subject(const char * name, uint64_t uid); | ||
|
|
||
| // t1 == t0 is an instant; `fields` may be NULL and is inlined verbatim into the JSON object | ||
| GGML_API void ggml_trace_event(const char * phase, const char * name, | ||
| int64_t t0, int64_t t1, const char * fields); | ||
|
|
||
| GGML_API void ggml_trace_eventf(const char * phase, const char * name, | ||
| int64_t t0, int64_t t1, const char * fmt, ...); | ||
|
|
||
| // t1 client sends, t2 peer receives, t3 peer replies, t4 client receives (microseconds). | ||
| GGML_API void ggml_trace_clock_offset(const char * peer, int64_t t1, int64_t t2, int64_t t3, int64_t t4); | ||
|
|
||
| // bracket a submit with compute-stream events; begin returns 0 without hooks, none ever wait | ||
| GGML_API uint64_t ggml_trace_gpu_begin(ggml_backend_t backend, const char * name); | ||
| GGML_API void ggml_trace_gpu_end (ggml_backend_t backend, uint64_t tag); | ||
| GGML_API void ggml_trace_gpu_flush(void); | ||
|
|
||
| GGML_API const char * ggml_trace_escape(char * dst, size_t dst_size, const char * src); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #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
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
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.
With
--pipeline-groups > 1sharing a CUDA device, one group can callggml_backend_sched_synchronize()and globally poll the tracer while the stream that recorded this device's anchor is still executing another group's graph. Fresh evidence after the earlier anchor fix is that this fallback still permanently setsanchor_usto that poll's wall time whencudaStreamQuery()reports the stream busy, shifting every subsequent span on the device and corrupting cross-group overlap and idle results. Leave the marks pending until the anchor stream is idle rather than freezing the approximation.Useful? React with 👍 / 👎.