Planner Examples

Examples for custom load predictors and the VirtualConnector for non-Kubernetes scaling environments.

以 Markdown 格式查看

Planner-specific examples for advanced configuration and non-Kubernetes integrations. For DGDR manifests, see DGDR Examples. For the full configuration reference, see the Planner Guide.

Custom Load Predictors

Warm-starting with Trace Data

Pre-load predictors with historical request patterns before live traffic:

1# In planner arguments
2args:
3 - --load-predictor arima
4 - --load-predictor-warmup-trace /data/trace.jsonl
5 - --load-predictor-log1p

The trace file should be in mooncake-style JSONL format with request-count, ISL, and OSL samples.

Kalman Filter Tuning

For workloads with rapid changes, tune the Kalman filter:

1args:
2 - --load-predictor kalman
3 - --kalman-q-level 2.0 # Higher = more responsive to level changes
4 - --kalman-q-trend 0.5 # Higher = trend changes faster
5 - --kalman-r 5.0 # Lower = trusts new measurements more
6 - --kalman-min-points 3 # Fewer points before forecasting starts
7 - --load-predictor-log1p # Often helps with request-rate series

Prophet for Seasonal Workloads

For workloads with daily/weekly patterns:

1args:
2 - --load-predictor prophet
3 - --prophet-window-size 100 # Larger window for seasonal detection
4 - --load-predictor-log1p

Virtual Connector

For non-Kubernetes environments, use the VirtualConnector to communicate scaling decisions:

1from dynamo._core import DistributedRuntime, VirtualConnectorClient
2
3# Initialize client
4client = VirtualConnectorClient(distributed_runtime, namespace)
5
6# Main loop: watch for planner decisions and execute them
7while True:
8 # Block until the planner makes a new scaling decision
9 await client.wait()
10
11 # Read the decision
12 decision = await client.get()
13 print(f"Scale to: prefill={decision.num_prefill_workers}, "
14 f"decode={decision.num_decode_workers}, "
15 f"id={decision.decision_id}")
16
17 # Execute scaling in your environment
18 scale_prefill_workers(decision.num_prefill_workers)
19 scale_decode_workers(decision.num_decode_workers)
20
21 # Report completion
22 await client.complete(decision)

See components/planner/test/test_virtual_connector.py for a full working example.