Skip to content

Commit 950a0e0

Browse files
authored
[ML] Remove irrelevant useNewMemoryFields parameter (#129298)
1 parent d51d643 commit 950a0e0

File tree

5 files changed

+38
-82
lines changed

5 files changed

+38
-82
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/assignment/TrainedModelAssignment.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import org.elasticsearch.ResourceAlreadyExistsException;
1111
import org.elasticsearch.ResourceNotFoundException;
12-
import org.elasticsearch.TransportVersion;
1312
import org.elasticsearch.TransportVersions;
1413
import org.elasticsearch.cluster.SimpleDiffable;
1514
import org.elasticsearch.common.Randomness;
@@ -107,10 +106,6 @@ public final class TrainedModelAssignment implements SimpleDiffable<TrainedModel
107106
private final int maxAssignedAllocations;
108107
private final AdaptiveAllocationsSettings adaptiveAllocationsSettings;
109108

110-
public static boolean useNewMemoryFields(TransportVersion minClusterVersion) {
111-
return minClusterVersion.onOrAfter(TransportVersions.V_8_11_X);
112-
}
113-
114109
public static TrainedModelAssignment fromXContent(XContentParser parser) throws IOException {
115110
return PARSER.apply(parser, null);
116111
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetTrainedModelsStatsAction.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@
5050
import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig;
5151
import org.elasticsearch.xpack.core.ml.inference.TrainedModelType;
5252
import org.elasticsearch.xpack.core.ml.inference.assignment.AssignmentStats;
53-
import org.elasticsearch.xpack.core.ml.inference.assignment.TrainedModelAssignment;
5453
import org.elasticsearch.xpack.core.ml.inference.assignment.TrainedModelAssignmentMetadata;
5554
import org.elasticsearch.xpack.core.ml.inference.persistence.InferenceIndexConstants;
5655
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.InferenceStats;
5756
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TrainedModelSizeStats;
58-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
5957
import org.elasticsearch.xpack.ml.MachineLearning;
6058
import org.elasticsearch.xpack.ml.inference.persistence.TrainedModelDefinitionDoc;
6159
import org.elasticsearch.xpack.ml.inference.persistence.TrainedModelProvider;
@@ -328,15 +326,12 @@ private void modelSizeStats(
328326
long totalDefinitionLength = pytorchTotalDefinitionLengthsByModelId.getOrDefault(model.getModelId(), 0L);
329327
// We ensure that in the mixed cluster state trained model stats uses the same values for memory estimation
330328
// as the rebalancer.
331-
boolean useNewMemoryFields = TrainedModelAssignment.useNewMemoryFields(
332-
TransportVersionUtils.getMinTransportVersion(clusterService.state())
333-
);
334329
long estimatedMemoryUsageBytes = totalDefinitionLength > 0L
335330
? StartTrainedModelDeploymentAction.estimateMemoryUsageBytes(
336331
model.getModelId(),
337332
totalDefinitionLength,
338-
useNewMemoryFields ? model.getPerDeploymentMemoryBytes() : 0,
339-
useNewMemoryFields ? model.getPerAllocationMemoryBytes() : 0,
333+
model.getPerDeploymentMemoryBytes(),
334+
model.getPerAllocationMemoryBytes(),
340335
numberOfAllocations
341336
)
342337
: 0L;

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/assignment/TrainedModelAssignmentClusterService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import org.elasticsearch.xpack.core.ml.job.messages.Messages;
5353
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
5454
import org.elasticsearch.xpack.core.ml.utils.MlPlatformArchitecturesUtil;
55-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
5655
import org.elasticsearch.xpack.ml.MachineLearning;
5756
import org.elasticsearch.xpack.ml.autoscaling.NodeAvailabilityZoneMapper;
5857
import org.elasticsearch.xpack.ml.inference.assignment.planning.AllocationReducer;
@@ -651,14 +650,12 @@ private TrainedModelAssignmentMetadata.Builder rebalanceAssignments(
651650
Map<DiscoveryNode, NodeLoad> nodeLoads = detectNodeLoads(nodes, currentState);
652651
TrainedModelAssignmentMetadata currentMetadata = TrainedModelAssignmentMetadata.fromState(currentState);
653652

654-
boolean useNewMemoryFields = TrainedModelAssignment.useNewMemoryFields(TransportVersionUtils.getMinTransportVersion(currentState));
655653
TrainedModelAssignmentRebalancer rebalancer = new TrainedModelAssignmentRebalancer(
656654
currentMetadata,
657655
nodeLoads,
658656
nodeAvailabilityZoneMapper.buildMlNodesByAvailabilityZone(currentState),
659657
createAssignmentRequest,
660-
allocatedProcessorsScale,
661-
useNewMemoryFields
658+
allocatedProcessorsScale
662659
);
663660

664661
Set<String> shuttingDownNodeIds = currentState.metadata().nodeShutdowns().getAllNodeIds();

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/assignment/TrainedModelAssignmentRebalancer.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,18 @@ class TrainedModelAssignmentRebalancer {
5454
private final Optional<CreateTrainedModelAssignmentAction.Request> createAssignmentRequest;
5555
private final int allocatedProcessorsScale;
5656

57-
private final boolean useNewMemoryFields;
58-
5957
TrainedModelAssignmentRebalancer(
6058
TrainedModelAssignmentMetadata currentMetadata,
6159
Map<DiscoveryNode, NodeLoad> nodeLoads,
6260
Map<List<String>, Collection<DiscoveryNode>> mlNodesByZone,
6361
Optional<CreateTrainedModelAssignmentAction.Request> createAssignmentRequest,
64-
int allocatedProcessorsScale,
65-
boolean useNewMemoryFields
62+
int allocatedProcessorsScale
6663
) {
6764
this.currentMetadata = Objects.requireNonNull(currentMetadata);
6865
this.nodeLoads = Objects.requireNonNull(nodeLoads);
6966
this.mlNodesByZone = Objects.requireNonNull(mlNodesByZone);
7067
this.createAssignmentRequest = Objects.requireNonNull(createAssignmentRequest);
7168
this.allocatedProcessorsScale = allocatedProcessorsScale;
72-
this.useNewMemoryFields = useNewMemoryFields;
7369
}
7470

7571
TrainedModelAssignmentMetadata.Builder rebalance() {
@@ -179,9 +175,8 @@ private AssignmentPlan computePlanForNormalPriorityModels(
179175
currentAssignments,
180176
assignment.getMaxAssignedAllocations(),
181177
assignment.getAdaptiveAllocationsSettings(),
182-
// in the mixed cluster state use old memory fields to avoid unstable assignment plans
183-
useNewMemoryFields ? assignment.getTaskParams().getPerDeploymentMemoryBytes() : 0,
184-
useNewMemoryFields ? assignment.getTaskParams().getPerAllocationMemoryBytes() : 0
178+
assignment.getTaskParams().getPerDeploymentMemoryBytes(),
179+
assignment.getTaskParams().getPerAllocationMemoryBytes()
185180
);
186181
})
187182
.forEach(planDeployments::add);
@@ -197,8 +192,8 @@ private AssignmentPlan computePlanForNormalPriorityModels(
197192
0,
198193
createAssignmentRequest.get().getAdaptiveAllocationsSettings(),
199194
// in the mixed cluster state use old memory fields to avoid unstable assignment plans
200-
useNewMemoryFields ? taskParams.getPerDeploymentMemoryBytes() : 0,
201-
useNewMemoryFields ? taskParams.getPerAllocationMemoryBytes() : 0
195+
taskParams.getPerDeploymentMemoryBytes(),
196+
taskParams.getPerAllocationMemoryBytes()
202197
)
203198
);
204199
}
@@ -237,8 +232,8 @@ private AssignmentPlan computePlanForLowPriorityModels(Set<String> assignableNod
237232
assignment.getMaxAssignedAllocations(),
238233
assignment.getAdaptiveAllocationsSettings(),
239234
Priority.LOW,
240-
(useNewMemoryFields == false) ? assignment.getTaskParams().getPerDeploymentMemoryBytes() : 0,
241-
(useNewMemoryFields == false) ? assignment.getTaskParams().getPerAllocationMemoryBytes() : 0
235+
0,
236+
0
242237
)
243238
)
244239
.forEach(planDeployments::add);
@@ -254,8 +249,8 @@ private AssignmentPlan computePlanForLowPriorityModels(Set<String> assignableNod
254249
0,
255250
createAssignmentRequest.get().getAdaptiveAllocationsSettings(),
256251
Priority.LOW,
257-
(useNewMemoryFields == false) ? taskParams.getPerDeploymentMemoryBytes() : 0,
258-
(useNewMemoryFields == false) ? taskParams.getPerAllocationMemoryBytes() : 0
252+
0,
253+
0
259254
)
260255
);
261256
}

0 commit comments

Comments
 (0)