epic(610): extract Hydra server logic out of server-context.cpp (mechanical, A/B toggle) - #105
Open
ddvnguyen wants to merge 5 commits into
Open
epic(610): extract Hydra server logic out of server-context.cpp (mechanical, A/B toggle)#105ddvnguyen wants to merge 5 commits into
ddvnguyen wants to merge 5 commits into
Conversation
…gration - server-hydra-extension.h: A/B seam interface (HYDRA_EXT_MODE=legacy|seam) - hydra-server-context.cpp: hydra_process_task() + extension impl (same TU) - server-context.cpp: friend + hydra_ext member + 3 hook sites; HYDRA task dispatch and update_slots clusters routed through the seam - test-hydra-ext-ab.cpp: hermetic A/B parity test Both modes call identical hydra_process_task/pre_loop/on_empty_batch, so behavior parity is by construction; toggle proves the seam plumbing.
The ~1117-line Hydra RPC server (hydra_rpc_ctx, static state handlers, server_context::start_rpc_server, hydra_rpc_bridge, #if !WIN32 guards) moved to hydra-server-context.cpp (same TU via bottom #include). This was the single largest rebase conflict source: upstream added handle_count_tokens etc. exactly where the fork appended the RPC server.
Moved hydra_classify_config_key, hydra_tier_label, hydra_apply_t1_config, hydra_apply_t3_mutators, hydra_parse_cache_type, hydra_register_rpc_servers, hydra_teardown_combined_before_reload, hydra_reattach_combined_after_reload, hydra_repad_tensor_buft_overrides, apply_pending_hydra_config, apply_t2_rebuild, apply_t3_rebuild to hydra-server-context.cpp (same TU). server-context.cpp keeps only in-class declarations. ~770 lines out of the upstream file.
HYDRA_EXT_MODE now defaults to the extension (seam) implementation; only an explicit HYDRA_EXT_MODE=legacy opts into the inline Hydra code for A/B. Inverts the pre-WS5 default (legacy). Verified: all 9 hermetic tests pass in default/legacy/seam; live-server /props + /health identical across modes. Inline-path deletion in update_slots stays gated on WS4 (live-GPU parity) so the A/B baseline remains available until real decode/COMBINED is proven.
…xtraction The regex-based conflict resolution during the hydra-fork rebase over-deleted two things it shouldn't have: - process_single_task() in server-context.cpp: this is upstream's generic task dispatch (COMPLETION/CANCEL/CONTROL/etc.), not Hydra-specific. Only the Hydra task-type case belongs extracted (now hydra_process_task(), defined in hydra-server-context.cpp, called from the generic switch's fall-through). Restored the generic function; verified no duplicate definition exists between the two files (grep-checked call sites match forward declarations 1:1). - hydra_apply_config() in hydra-server-context.cpp: the T1/T2/T3/T4 config tiering logic that process_single_task's hydra_config_json path and CONFIGURE both call — was referenced but never defined post-extraction, which would fail to link. Restored from hydra-fork upstream with the server_context_impl:: qualification the extraction requires. Reviewed line-by-line against hydra-fork's originals and the call sites in both files; C++ compiles clean (link still needs the fork's ggml-rpc submodule, not available standalone in this worktree — matches the prior build report). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Mechanical, behavior-preserving extraction of Hydra-specific server logic out of upstream
tools/server/server-context.cppinto a fork-ownedhydra-server-context.cpp, behind aserver_hydra_extensioninterface and anHYDRA_EXT_MODEA/B toggle (WS5 flips the default to the seam). Does not touch RPC opcodes —STATE_PUT/DECODEwire framing is unchanged. Part of the ggml-org#470 stabilization effort (seeddvnguyen/hydra_vortexepic/697-470-stabilization, decisiondocs/decisions/001-freeze-470-rewrite-internals.md) — the Hydra↔fork API/streaming contract is frozen, this is an internal-only rewrite for long-term maintainability against upstream churn.Rebased from the original
epic/610-server-hydra-extensionbranch (10 days stale) onto currenthydra-forkHEAD. This is a new branch (epic/610-server-hydra-extension-rebased) rather than a force-push over the original, to avoid rewriting shared history.Commits
HYDRA_EXT_MODEno longer required)process_single_task) +hydra_apply_config, which the rebase's regex-based conflict resolution over-deleted (both are non-Hydra-specific or a definition the extraction needs — reviewed line-by-line, no duplication between the two files)Verification
server-context.cpp+hydra-server-context.cpp: PASSggml_backend_rpc_check_any_peer_reconnectionetc. — which aren't in upstream llama.cpp's ggml). Needs a full build on the rig before merge.Test plan
test-hydra-ext-ab.cppA/B parity testhydra-fork