-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Adaptive allocations improvements #126307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import org.elasticsearch.xpack.core.ml.action.CreateTrainedModelAssignmentAction; | ||
| import org.elasticsearch.xpack.core.ml.action.GetDeploymentStatsAction; | ||
| import org.elasticsearch.xpack.core.ml.action.UpdateTrainedModelDeploymentAction; | ||
| import org.elasticsearch.xpack.core.ml.inference.assignment.AssignmentState; | ||
| import org.elasticsearch.xpack.core.ml.inference.assignment.AssignmentStats; | ||
| import org.elasticsearch.xpack.core.ml.inference.assignment.RoutingState; | ||
| import org.elasticsearch.xpack.core.ml.inference.assignment.TrainedModelAssignment; | ||
|
|
@@ -390,13 +391,15 @@ private void processDeploymentStats(GetDeploymentStatsAction.Response statsRespo | |
|
|
||
| Map<String, Stats> recentStatsByDeployment = new HashMap<>(); | ||
| Map<String, Integer> numberOfAllocations = new HashMap<>(); | ||
| Map<String, AssignmentState> assignmentStates = new HashMap<>(); | ||
| // Check for recent scale ups in the deployment stats, because a different node may have | ||
| // caused a scale up when an inference request arrives and there were zero allocations. | ||
| Set<String> hasRecentObservedScaleUp = new HashSet<>(); | ||
|
|
||
| for (AssignmentStats assignmentStats : statsResponse.getStats().results()) { | ||
| String deploymentId = assignmentStats.getDeploymentId(); | ||
| numberOfAllocations.put(deploymentId, assignmentStats.getNumberOfAllocations()); | ||
| assignmentStates.put(deploymentId, assignmentStats.getState()); | ||
| Map<String, Stats> deploymentStats = lastInferenceStatsByDeploymentAndNode.computeIfAbsent( | ||
| deploymentId, | ||
| key -> new HashMap<>() | ||
|
|
@@ -449,6 +452,14 @@ private void processDeploymentStats(GetDeploymentStatsAction.Response statsRespo | |
| logger.debug("adaptive allocations scaler: skipping scaling down [{}] because of recent scaleup.", deploymentId); | ||
| continue; | ||
| } | ||
| if (assignmentStates.get(deploymentId) != AssignmentState.STARTED) { | ||
| logger.debug( | ||
| "adaptive allocations scaler: skipping scaling [{}] because it is in [{}] state.", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating a model that's not in the |
||
| deploymentId, | ||
| assignmentStates.get(deploymentId) | ||
| ); | ||
| continue; | ||
| } | ||
| if (newNumberOfAllocations > numberOfAllocations.get(deploymentId)) { | ||
| lastScaleUpTimesMillis.put(deploymentId, now); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,10 @@ public class AssignmentPlanner { | |
|
|
||
| public AssignmentPlanner(List<Node> nodes, List<AssignmentPlan.Deployment> deployments) { | ||
| this.nodes = nodes.stream().sorted(Comparator.comparing(Node::id)).toList(); | ||
| this.deployments = deployments.stream().sorted(Comparator.comparing(AssignmentPlan.Deployment::deploymentId)).toList(); | ||
| this.deployments = deployments.stream() | ||
| .filter(deployment -> deployment.allocations() > 0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these aren't filtered,
|
||
| .sorted(Comparator.comparing(AssignmentPlan.Deployment::deploymentId)) | ||
| .toList(); | ||
| } | ||
|
|
||
| public AssignmentPlan computePlan() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what this is exactly used for. It looks like only for recording, not for decision making. Definitely not used by adaptive allocations.