mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(router): share the token-size estimate through Redis
With redis.sharedState on, each observed sample also adds to day counters of prompt bytes, prompt tokens and sample count per model. The router-learning loop reads the counters of the routers' target models and keeps one fleet ratio per model. The estimate prefers that ratio once the fleet has the same minimum sample count as the local calibrator. Dropped counter writes only blur the estimate. With the switch off, the calibrator runs its local code only and makes no store call.
This commit is contained in:
@@ -24,6 +24,11 @@ func (g *Gateway) wireSharedState(cfg *Config) {
|
||||
brk.failureThreshold, brk.openBase, brk.openMax, 2*brk.openMax))
|
||||
}
|
||||
g.shareDecisionBreakers(ids)
|
||||
if g.tokenCalib != nil && g.limiter != nil {
|
||||
g.tokenCalib.share(
|
||||
func(entries []counterIncr) { g.limiter.countAsync(entries) },
|
||||
func() time.Time { return g.limiter.now() })
|
||||
}
|
||||
}
|
||||
|
||||
// maxProviderTimeout is the longest request timeout any provider can run, which bounds how long an in-flight count stays live.
|
||||
|
||||
Reference in New Issue
Block a user