Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/131630.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 131630
summary: Fix memory usage estimation for ELSER models
area: Machine Learning
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private AssignmentPlan computePlanForNormalPriorityModels(
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getTargetAllocations()));
return new AssignmentPlan.Deployment(
assignment.getDeploymentId(),
assignment.getModelId(),
assignment.getTaskParams().getModelBytes(),
assignment.getTaskParams().getNumberOfAllocations(),
assignment.getTaskParams().getThreadsPerAllocation(),
Expand All @@ -185,6 +186,7 @@ private AssignmentPlan computePlanForNormalPriorityModels(
planDeployments.add(
new AssignmentPlan.Deployment(
taskParams.getDeploymentId(),
taskParams.getModelId(),
taskParams.getModelBytes(),
taskParams.getNumberOfAllocations(),
taskParams.getThreadsPerAllocation(),
Expand Down Expand Up @@ -225,6 +227,7 @@ private AssignmentPlan computePlanForLowPriorityModels(Set<String> assignableNod
.map(
assignment -> new AssignmentPlan.Deployment(
assignment.getDeploymentId(),
assignment.getModelId(),
assignment.getTaskParams().getModelBytes(),
assignment.getTaskParams().getNumberOfAllocations(),
assignment.getTaskParams().getThreadsPerAllocation(),
Expand All @@ -242,6 +245,7 @@ private AssignmentPlan computePlanForLowPriorityModels(Set<String> assignableNod
planDeployments.add(
new AssignmentPlan.Deployment(
taskParams.getDeploymentId(),
taskParams.getModelId(),
taskParams.getModelBytes(),
taskParams.getNumberOfAllocations(),
taskParams.getThreadsPerAllocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Deployment modifyModelPreservingPreviousAssignments(Deployment m) {

return new Deployment(
m.deploymentId(),
m.modelId(),
m.memoryBytes(),
m.allocations() - calculatePreservedAllocations(m),
m.threadsPerAllocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class AssignmentPlan implements Comparable<AssignmentPlan> {
*/
public record Deployment(
String deploymentId,
String modelId,
long memoryBytes,
int allocations,
int threadsPerAllocation,
Expand All @@ -59,6 +60,7 @@ public record Deployment(
) {
public Deployment(
String deploymentId,
String modelId,
long modelBytes,
int allocations,
int threadsPerAllocation,
Expand All @@ -70,6 +72,7 @@ public Deployment(
) {
this(
deploymentId,
modelId,
modelBytes,
allocations,
threadsPerAllocation,
Expand All @@ -96,7 +99,7 @@ boolean hasEverBeenAllocated() {

public long estimateMemoryUsageBytes(int allocations) {
return StartTrainedModelDeploymentAction.estimateMemoryUsageBytes(
deploymentId,
modelId,
memoryBytes,
perDeploymentMemoryBytes,
perAllocationMemoryBytes,
Expand All @@ -106,24 +109,23 @@ public long estimateMemoryUsageBytes(int allocations) {

long estimateAdditionalMemoryUsageBytes(int allocationsOld, int allocationsNew) {
return StartTrainedModelDeploymentAction.estimateMemoryUsageBytes(
deploymentId,
modelId,
memoryBytes,
perDeploymentMemoryBytes,
perAllocationMemoryBytes,
allocationsNew
) - StartTrainedModelDeploymentAction.estimateMemoryUsageBytes(
deploymentId,
modelId,
memoryBytes,
perDeploymentMemoryBytes,
perAllocationMemoryBytes,
allocationsOld
);

}

long minimumMemoryRequiredBytes() {
return StartTrainedModelDeploymentAction.estimateMemoryUsageBytes(
deploymentId,
modelId,
memoryBytes,
perDeploymentMemoryBytes,
perAllocationMemoryBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ private AssignmentPlan solveAllocatingAtLeastOnceModelsThatWerePreviouslyAllocat
.map(
m -> new AssignmentPlan.Deployment(
m.deploymentId(),
m.modelId(),
m.memoryBytes(),
1,
m.threadsPerAllocation(),
Expand Down Expand Up @@ -148,6 +149,7 @@ private AssignmentPlan solveAllocatingAtLeastOnceModelsThatWerePreviouslyAllocat
: Map.of();
return new AssignmentPlan.Deployment(
m.deploymentId(),
m.modelId(),
m.memoryBytes(),
m.allocations(),
m.threadsPerAllocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ private AssignmentPlan computeZonePlan(
d -> new AssignmentPlan.Deployment(
// replace each deployment with a new deployment
d.deploymentId(),
d.modelId(),
d.memoryBytes(),
deploymentIdToTargetAllocationsPerZone.get(d.deploymentId()),
d.threadsPerAllocation(),
Expand Down Expand Up @@ -163,6 +164,7 @@ private AssignmentPlan computePlanAcrossAllNodes(List<AssignmentPlan> plans) {
.map(
d -> new AssignmentPlan.Deployment(
d.deploymentId(),
d.modelId(),
d.memoryBytes(),
d.allocations(),
d.threadsPerAllocation(),
Expand Down
Loading
Loading