From d3435efc8a2f926f1d7a5f2a11ac161b798c355a Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 9 Jan 2026 12:16:40 +0200 Subject: [PATCH 1/2] scripts : pr2wt.sh reset to remote head (#18695) * scripts : pr2wt.sh reset to remote head * cont : cleaner * cont : restore --set-upstream-to --- scripts/pr2wt.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/pr2wt.sh b/scripts/pr2wt.sh index 7970bec371..8e5d89462c 100755 --- a/scripts/pr2wt.sh +++ b/scripts/pr2wt.sh @@ -4,12 +4,13 @@ # # - creates a new remote using the fork's clone URL # - creates a local branch tracking the remote branch -# - creates a new worktree in a parent folder, suffixed with "-pr-${PR}" +# - creates a new worktree in a parent folder, suffixed with "-pr-$PR" # # sample usage: # ./scripts/pr2wt.sh 12345 # ./scripts/pr2wt.sh 12345 opencode # ./scripts/pr2wt.sh 12345 "cmake -B build && cmake --build build" +# ./scripts/pr2wt.sh 12345 "bash -l" function usage() { echo "usage: $0 [cmd]" @@ -39,7 +40,7 @@ org_repo=${org_repo%.git} echo "org/repo: $org_repo" -meta=$(curl -sSf -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${org_repo}/pulls/${PR}") +meta=$(curl -sSf -H "Accept: application/vnd.github+json" "https://api.github.com/repos/$org_repo/pulls/$PR") url_remote=$(echo "$meta" | jq -r '.head.repo.clone_url') head_ref=$(echo "$meta" | jq -r '.head.ref') @@ -47,21 +48,32 @@ head_ref=$(echo "$meta" | jq -r '.head.ref') echo "url: $url_remote" echo "head_ref: $head_ref" -git remote rm pr/${PR} 2> /dev/null -git remote add pr/${PR} $url_remote -git fetch pr/${PR} $head_ref +url_remote_cur=$(git config --get "remote.pr/$PR.url" 2>/dev/null || true) + +if [[ "$url_remote_cur" != "$url_remote" ]]; then + git remote rm pr/$PR 2> /dev/null + git remote add pr/$PR "$url_remote" +fi + +git fetch "pr/$PR" "$head_ref" dir=$(basename $(pwd)) git branch -D pr/$PR 2> /dev/null -git worktree add -b pr/$PR ../$dir-pr-$PR pr/$PR/${head_ref} 2> /dev/null +git worktree add -b pr/$PR ../$dir-pr-$PR pr/$PR/$head_ref 2> /dev/null wt_path=$(cd ../$dir-pr-$PR && pwd) echo "git worktree created in $wt_path" -# if a command was provided, execute it +cd $wt_path +git branch --set-upstream-to=pr/$PR/$head_ref +git pull --ff-only || { + echo "error: failed to pull pr/$PR" + exit 1 +} + if [[ $# -eq 2 ]]; then - cd ../$dir-pr-$PR + echo "executing: $2" eval "$2" fi From 53eb9435da3affa12a38a8b0fb29081698a8d1cc Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 9 Jan 2026 12:59:50 +0200 Subject: [PATCH 2/2] server : fix timing of prompt/generation (#18713) --- tools/server/server-context.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/server/server-context.cpp b/tools/server/server-context.cpp index e1f65dfcce..324c3af30c 100644 --- a/tools/server/server-context.cpp +++ b/tools/server/server-context.cpp @@ -2615,10 +2615,6 @@ private: // on successful decode, restore the original batch size n_batch = llama_n_batch(ctx); - // technically, measuring the time here excludes the sampling time for the last batch - // but on the other hand, we don't want to do too many system calls to measure the time, so it's ok - const int64_t t_current = ggml_time_us(); - for (auto & slot : slots) { // may need to copy state to other slots if (slot.state == SLOT_STATE_DONE_PROMPT && slot.is_parent()) { @@ -2685,6 +2681,9 @@ private: common_sampler_accept(slot.smpl.get(), id, true); + // here we have synchronized the llama_context (due to the sampling above), so we can do time measurement + const int64_t t_current = ggml_time_us(); + slot.n_decoded += 1; if (slot.n_decoded == 1) { @@ -2728,6 +2727,8 @@ private: slot.i_batch_dft.clear(); slot.drafted.clear(); + const int64_t t_current = ggml_time_us(); + slot.n_decoded += ids.size(); slot.t_token_generation = std::max(1, t_current - slot.t_start_generation) / 1e3;