HydraIssues

Gateway concurrency is hard-coded to 2, so the operator cannot trade speed against slots
done improvement Project: hydrabrain Parent: #659 Reporter: cederik 12 Nov 2026 00:52

Description

Owner ruling 2026-11-11: remove the hard-coding so the operator decides speed against slots.

WHERE IT IS. internal/agent/controller.go:270 builds the gateway config for a cluster-managed workload and pins MaxConcurrentRequests to the literal 2.

WHAT IS ALREADY THERE. The config layer supports this in full: internal/config/config.go has the max_concurrent_requests yaml field, defaults it to 2 when zero, and rejects a non-positive value. internal/gateway/gateway.go:53 sizes chatSlots from it. So a standalone gateway with its own config file is already configurable. ONLY the cluster-managed path overrides it.

WHY IT MATTERS. llama.cpp -np sets the parallel slots and -c the total context split across them. The arguments are operator-controlled in the desired document, but the gateway cap is not, so raising -np alone just makes requests queue at the gateway. The two must move together and today only one of them can move. This blocks any plan that fans work out to a provider.

THE CHANGE. max_concurrent_requests is workload configuration, which HydraCluster owns per the HydraBrain boundaries, so it belongs in the desired document rather than in a node-local file.

hydracluster:

  • store.HydraBrainConfig gains MaxConcurrentRequests, omitempty.
  • validateHydraBrainConfig bounds it. Zero means unset.
  • hydraBrainConfigResponse gains it and agentDesired maps it. That also puts it inside agentFingerprint, so an edit correctly counts as changesAgentState and the gateway is rebuilt. That is wanted: slots cannot change under a live gateway.

hydrabrain:

  • clusterclient.Desired gains the field.
  • controller.go uses it, falling back to 2 when it is zero or negative.

COMPATIBILITY, both directions safe:

  • Old hydrabrain, new cluster: Go ignores the unknown JSON field, so it stays at 2.
  • New hydrabrain, old cluster: the field arrives as 0 and the default gives 2.
  • BUT the PUT handler uses DisallowUnknownFields, so a desired document carrying the new field is REJECTED by an older cluster with HTTP 400 invalid JSON. Deploy hydracluster BEFORE writing the field into any document. This is the same trap as the #803 provider labels.

NOT IN SCOPE. QueueTimeout is hard-coded beside it at 30s. Left alone deliberately; raising concurrency reduces queueing rather than increasing it. Say so if it should move too.

OPERATOR NOTE for the runbook: raising this without raising -np moves the queue from the gateway into llama.cpp instead of removing it, and raising -np costs KV cache per slot, so a 24 GB card cannot have many 32K slots. Both numbers and the VRAM have to be chosen together.

Session Context

Venue
cloud-seven
Body
chunky-turnip-23

Comments (1)

api 12 Nov 2026 00:52

Shipped 2026-11-12.

  • hydracluster v2.3.0 (PR #9, squash 6223a39) carries max_concurrent_requests in the desired document, bounded 0..64, 0 or absent meaning the agent default of 2. It sits inside the agent fingerprint, so an edit rebuilds the gateway.
  • hydrabrain v0.5.0 (0497bac) replaces the hard-coded 2 at internal/agent/controller.go:270 with the desired value, clamped the same way.

It takes both halves, and the missing half is silent. With only the cluster live the PUT was accepted, the GET read the value back, and the gateway went on admitting 2. Prove it with behaviour instead: set the limit to 1 and fire two requests at once; they must serialise.

Measured on chunky-turnip-23 (A5000, Q4_K_M, -np 2 -c 65536), 250 completion tokens per stream:

gateway limit concurrent aggregate
1 2 32.2 tok/s
2 2 54.3 tok/s
4 4 53.0 tok/s

Above -np the aggregate stops moving, so raising the gateway alone moves the queue rather than removing it. chunky now runs a limit of 4 against -np 2 on purpose: a batch driver keeps both slots saturated without taking 429s.