Skip to content

epic(610): extract Hydra server logic out of server-context.cpp (mechanical, A/B toggle) - #105

Open
ddvnguyen wants to merge 5 commits into
hydra-forkfrom
epic/610-server-hydra-extension-rebased
Open

epic(610): extract Hydra server logic out of server-context.cpp (mechanical, A/B toggle)#105
ddvnguyen wants to merge 5 commits into
hydra-forkfrom
epic/610-server-hydra-extension-rebased

Conversation

@ddvnguyen

Copy link
Copy Markdown
Owner

Summary

Mechanical, behavior-preserving extraction of Hydra-specific server logic out of upstream tools/server/server-context.cpp into a fork-owned hydra-server-context.cpp, behind a server_hydra_extension interface and an HYDRA_EXT_MODE A/B toggle (WS5 flips the default to the seam). Does not touch RPC opcodes — STATE_PUT/DECODE wire framing is unchanged. Part of the ggml-org#470 stabilization effort (see ddvnguyen/hydra_vortex epic/697-470-stabilization, decision docs/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-extension branch (10 days stale) onto current hydra-fork HEAD. 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

  1. WS1-3: server-context extension seam + task/update_slots migration
  2. WS3.5: move Hydra RPC server out of server-context.cpp
  3. WS3.5: move T1/T2/T3 config + COMBINED helper methods out
  4. WS5: flip default to seam (HYDRA_EXT_MODE no longer required)
  5. fixup: restore generic dispatch (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

  • C++ compilation of server-context.cpp + hydra-server-context.cpp: PASS
  • Linking: not verifiable standalone in this worktree (needs the fork's ggml-rpc submodule additions — ggml_backend_rpc_check_any_peer_reconnection etc. — which aren't in upstream llama.cpp's ggml). Needs a full build on the rig before merge.
  • No CI configured on this branch yet.

Test plan

  • Full build on the rig (RTX + fork ggml-rpc submodule available)
  • test-hydra-ext-ab.cpp A/B parity test
  • Live-rig smoke test against Hydra.Core before merging to hydra-fork

Hydra Engineering and others added 5 commits August 21, 2026 12:13
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant