Configure AutoScaling
Let TensorFusion adjust the TFLOPS and VRAM requests and limits of a running workload from usage history, a schedule, or your own scaler
TensorFusion autoscaling is vertical: it changes the TFLOPS and VRAM requests and limits of each vGPU while the Pod keeps running. It does not change the number of replicas; use HPA or KEDA for that.
The quickest way to turn it on is one annotation. For percentiles, schedules or an external scaler, use a WorkloadProfile.
Prerequisites
- A workload that already runs on TensorFusion. See Create Workload.
- The controller runs with the
-enable-auto-scaleflag and can reach the metrics database. Both are on in the default Helm installation. - State the workload's compute in TFLOPS (
tflops-request,tflops-limit) rather than in percent. The autoscaler writes its results as TFLOPS and VRAM values.
Step 1. Enable autoscaling with annotations
Add these annotations to the Pod template, next to the resource annotations:
metadata:
annotations:
tensor-fusion.ai/autoscale: "true"
# compute | vram | all. Defaults to all when omitted.
tensor-fusion.ai/autoscale-target: "all"autoscale-target | What is adjusted |
|---|---|
compute | TFLOPS request and limit |
vram | VRAM request and limit |
all | Both |
With only these annotations, TensorFusion uses the default percentile settings from the table in step 2.
Step 2. Tune it with a WorkloadProfile
Put detailed settings in spec.autoScalingConfig of a WorkloadProfile and reference the profile from the Pod with tensor-fusion.ai/workload-profile.
apiVersion: tensor-fusion.ai/v1
kind: WorkloadProfile
metadata:
name: autoscale-inference
spec:
autoScalingConfig:
autoSetResources:
enable: true
targetResource: all
historyDataPeriod: 6h
initialDelayPeriod: 30m
marginFraction: "0.2"autoSetResources.enable: true is the switch for the whole autoscaler. Cron rules and the external scaler described below are ignored without it.
If enable is true but targetResource is empty, TensorFusion only writes the recommendation to the workload status and changes nothing. Use this to preview what autoscaling would do. The tensor-fusion.ai/autoscale: "true" annotation always sets a target, so it always applies changes.
Usage-based settings
All values are strings in YAML, so quote the numbers.
| Field | Default | Meaning |
|---|---|---|
enable | false | Turns the autoscaler on for this workload. |
targetResource | empty | compute, vram or all. Empty means recommend only. |
targetComputePercentile | 0.95 | Usage percentile used as the compute target. |
lowerBoundComputePercentile | 0.5 | Usage percentile used as the compute lower bound. |
upperBoundComputePercentile | 0.99 | Usage percentile used as the compute upper bound. |
targetVRAMPercentile | 0.98 | Usage percentile used as the VRAM target. |
lowerBoundVRAMPercentile | 0.5 | Usage percentile used as the VRAM lower bound. |
upperBoundVRAMPercentile | 0.99 | Usage percentile used as the VRAM upper bound. |
marginFraction | 0.15 | Safety margin added on top of each percentile. |
updateThreshold | 0.1 | A request changes only when the new value differs from the current one by more than this fraction. Keep it below marginFraction. |
historyDataPeriod | 2h | How far back usage is read. Capped at 30 days. |
initialDelayPeriod | 30m | How long after the workload is created before scaling starts. |
interval | global interval | How often the workload is evaluated. The global value is dynamicConfig.autoScalingInterval in the Helm values, 30s if unset. |
minComputeResourcesRatio | 0.1 | Lowest compute request, as a ratio of the original request. |
maxComputeResourcesRatio | 10.0 | Highest compute request and limit, as a ratio of the original values. |
minVRAMResourcesRatio | 0.2 | Lowest VRAM request and limit, as a ratio of the original values. |
maxVRAMResourcesRatio | 5.0 | Highest VRAM request and limit, as a ratio of the original values. |
How a recommendation is built from these numbers:
- The limit becomes the upper bound.
- The request depends on QoS: the lower bound for
lowandmedium, the target forhigh, the upper bound forcritical. - The result is clamped to the min and max ratios and never drops below 1 TFLOPS or 1Gi.
- The compute limit never drops below the original limit, so a workload that was idle for a while is not throttled when load returns.
- A scale-up never exceeds what is free on the GPUs the workload already uses.
Scale on a schedule
Cron rules set fixed resources during a time window. Outside every window, the workload returns to the resources it was created with.
spec:
autoScalingConfig:
autoSetResources:
enable: true
targetResource: all
cronScalingRules:
- name: business-hours
enable: true
start: "0 9 * * 1-5"
end: "0 19 * * 1-5"
desiredResources:
requests:
tflops: "40"
vram: 8Gi
limits:
tflops: "80"
vram: 10Gistartandendare standard five-field cron expressions (minute, hour, day of month, month, day of week) and must differ. They are evaluated in the controller's time zone.- A rule without
name,startorend, or withenable: false, is skipped. - While a rule is active, usage-based scaling cannot go below the rule's requests.
Use an external scaler
To make the decision in your own service, point TensorFusion at an HTTP endpoint:
spec:
autoScalingConfig:
autoSetResources:
enable: true
targetResource: all
externalScaler:
enable: true
url: http://my-scaler.default.svc:8080/recommend
apiKeySecretRef:
name: my-scaler-key
namespace: defaultOn each evaluation TensorFusion sends a POST with a JSON body and expects HTTP 200 with a JSON response. If apiKeySecretRef is set, TensorFusion reads the key from the Secret's apiKey, token or key field and sends it as Authorization: Bearer <key>.
Request body:
{
"workloadName": "pytorch-vgpu",
"namespace": "default",
"currentResources": {
"requests": { "tflops": "10", "vram": "4Gi" },
"limits": { "tflops": "20", "vram": "4Gi" }
}
}Response body:
{
"needScaleUp": true,
"needScaleDown": false,
"reason": "QueueTooLong",
"recommendedResources": {
"requests": { "tflops": "20", "vram": "4Gi" },
"limits": { "tflops": "40", "vram": "4Gi" }
}
}When both needScaleUp and needScaleDown are false, nothing changes. A non-empty reason is recorded on the workload status. externalScaler.initialDelayPeriod defaults to 30m.
Apply one rule to many workloads
Pool administrators can attach autoscaling settings to every Pod that matches a label selector, without touching the workloads. Add verticalScalingRules to the SchedulingConfigTemplate the pool uses:
kubectl get gpupool <pool-name> -o jsonpath='{.spec.schedulingConfigTemplate}{"\n"}'
kubectl edit schedulingconfigtemplate <template-name>spec:
verticalScalingRules:
- name: autoscale-inference
selector:
matchLabels:
workload-type: inference
autoScaling:
autoSetResources:
enable: true
targetResource: allThe webhook merges the first rule whose selector matches the Pod's labels into the workload when the Pod is created.
Step 3. Check what the autoscaler did
Every workload has a TensorFusionWorkload object named after its Deployment, StatefulSet or Job. Its status shows the current state:
kubectl get tensorfusionworkload <workload-name> -o yaml
kubectl get events --field-selector involvedObject.kind=TensorFusionWorkloadstatus:
conditions:
- type: ResourceUpdate
status: "True"
reason: Updated
message: "Compute scaled: request 10 -> 6, limit 20 -> 20"
# Latest recommendation
recommendation:
requests:
tflops: "6"
vram: 3Gi
limits:
tflops: "20"
vram: 4Gi
# Number of Pods the recommendation has been applied to
appliedRecommendedReplicas: 3
# Present only while a cron rule is active
activeCronScalingRule:
name: business-hours| Condition | Reason | Meaning |
|---|---|---|
ResourceUpdate | LowConfidence | The workload is younger than initialDelayPeriod. Nothing is changed yet. |
ResourceUpdate | InsideUpdateThreshold | The change is smaller than updateThreshold. Nothing is changed. |
ResourceUpdate | Updated | Resources were changed. The message has the old and new values. |
ResourceUpdate | NoScalingNeeded | The external scaler asked for no change. |
RecommendationProvided | RuleActive, RuleInactive | A cron rule started or ended. |
Each change also emits a ResourceScaledUp or ResourceScaledDown event on the TensorFusionWorkload.
A recommendation reaches Pods in two ways. Running Pods get their tflops-* and vram-* annotations updated in place; they are not restarted. Pods created later start with the recommended values.
Limitations
- Replica count is not scaled.
- Pods with
tensor-fusion.ai/dedicated-gpu: "true"are skipped, because they already own whole GPUs. - Nothing happens during the first
initialDelayPeriodafter a workload is created. This also delays cron rules and the external scaler.
TensorFusion Docs