[ML] Trained Models: Hide Adaptive Allocations Toggle in Serverless (#224097)

Resolves https://github.com/elastic/kibana/issues/221894
Removes the adaptive allocations toggle in serverless (always enabled).
Adjusts the `min_allocations` param:
* Observability - min: 0
* Search - min: 0
* Security - min: 1
This commit is contained in:
Robert Jaszczurek 2025-06-18 15:52:15 +02:00 committed by GitHub
parent c38269744b
commit f79b68d84e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 60 additions and 21 deletions

View file

@ -85,18 +85,18 @@ xpack.ml.dfa.enabled: false
xpack.ml.nlp: xpack.ml.nlp:
enabled: true enabled: true
modelDeployment: modelDeployment:
allowStaticAllocations: true allowStaticAllocations: false
vCPURange: vCPURange:
low: low:
min: 0 min: 0
max: 2 max: 2
static: 2 static: 2
medium: medium:
min: 1 min: 0
max: 32 max: 32
static: 32 static: 32
high: high:
min: 1 min: 0
max: 512 max: 512
static: 512 static: 512
xpack.ml.compatibleModuleType: 'search' xpack.ml.compatibleModuleType: 'search'

View file

@ -119,10 +119,10 @@ xpack.ml.nlp:
min: 0 min: 0
max: 2 max: 2
medium: medium:
min: 1 min: 0
max: 32 max: 32
high: high:
min: 1 min: 0
max: 128 max: 128
xpack.ml.compatibleModuleType: 'observability' xpack.ml.compatibleModuleType: 'observability'

View file

@ -48,12 +48,12 @@ describe('DeploymentParamsMapper', () => {
static: 16, static: 16,
}); });
expect(mapper.getVCURange('medium')).toEqual({ expect(mapper.getVCURange('medium')).toEqual({
min: 8, min: 0,
max: 256, max: 256,
static: 256, static: 256,
}); });
expect(mapper.getVCURange('high')).toEqual({ expect(mapper.getVCURange('high')).toEqual({
min: 8, min: 0,
max: 4096, max: 4096,
static: 4096, static: 4096,
}); });
@ -93,6 +93,48 @@ describe('DeploymentParamsMapper', () => {
number_of_allocations: 2, number_of_allocations: 2,
}, },
}); });
expect(
mapper.mapUiToApiDeploymentParams(modelId, {
deploymentId: 'test-deployment',
optimized: 'optimizedForSearch',
adaptiveResources: true,
vCPUUsage: 'medium',
})
).toEqual({
modelId: 'test-model',
deploymentParams: {
deployment_id: 'test-deployment',
priority: 'normal',
threads_per_allocation: 16,
},
adaptiveAllocationsParams: {
enabled: true,
max_number_of_allocations: 2,
min_number_of_allocations: 0,
},
});
expect(
mapper.mapUiToApiDeploymentParams(modelId, {
deploymentId: 'test-deployment',
optimized: 'optimizedForIngest',
adaptiveResources: true,
vCPUUsage: 'high',
})
).toEqual({
modelId: 'test-model',
deploymentParams: {
deployment_id: 'test-deployment',
priority: 'normal',
threads_per_allocation: 1,
},
adaptiveAllocationsParams: {
enabled: true,
max_number_of_allocations: 512,
min_number_of_allocations: 0,
},
});
}); });
it('overrides vCPUs levels and enforces adaptive allocations if static support is not configured', () => { it('overrides vCPUs levels and enforces adaptive allocations if static support is not configured', () => {

View file

@ -56,8 +56,8 @@ export class DeploymentParamsMapper {
*/ */
private readonly serverlessVCPUBreakpoints: VCPUBreakpoints = { private readonly serverlessVCPUBreakpoints: VCPUBreakpoints = {
low: { min: this.minAllowedNumberOfAllocation, max: 2, static: 2 }, low: { min: this.minAllowedNumberOfAllocation, max: 2, static: 2 },
medium: { min: 1, max: 32, static: 32 }, medium: { min: 0, max: 32, static: 32 },
high: { min: 1, max: 512, static: 512 }, high: { min: 0, max: 512, static: 512 },
}; };
/** /**
@ -152,8 +152,11 @@ export class DeploymentParamsMapper {
number_of_allocations: maxValue, number_of_allocations: maxValue,
min_number_of_allocations: min_number_of_allocations:
Math.floor(levelValues.min / threadsPerAllocation) || Math.floor(levelValues.min / threadsPerAllocation) ||
// in any env, allow scale down to 0 only for "low" vCPU usage // For serverless env, always allow scale down to 0
(params.vCPUUsage === 'low' ? this.minAllowedNumberOfAllocation : 1), // For other envs, allow scale down to 0 only for "low" vCPU usage
(this.showNodeInfo === false || params.vCPUUsage === 'low'
? this.minAllowedNumberOfAllocation
: 1),
max_number_of_allocations: maxValue, max_number_of_allocations: maxValue,
}; };
} }

View file

@ -818,7 +818,7 @@ export const StartUpdateDeploymentModal: FC<StartDeploymentModalProps> = ({
errors={errors} errors={errors}
isUpdate={isUpdate} isUpdate={isUpdate}
disableAdaptiveResourcesControl={ disableAdaptiveResourcesControl={
showNodeInfo ? false : !nlpSettings.modelDeployment.allowStaticAllocations !showNodeInfo || !nlpSettings.modelDeployment.allowStaticAllocations
} }
deploymentsParams={ deploymentsParams={
isModelNotDownloaded || !isNLPModelItem(model) isModelNotDownloaded || !isNLPModelItem(model)

View file

@ -60,15 +60,9 @@ export default function ({ getService, getPageObjects, getPageObject }: FtrProvi
'Your model will scale up to a maximum of 4,096 VCUs per hour based on your search or ingest load. It will automatically scale down when demand decreases, and you only pay for the resources you use.' 'Your model will scale up to a maximum of 4,096 VCUs per hour based on your search or ingest load. It will automatically scale down when demand decreases, and you only pay for the resources you use.'
); );
// Adaptive resources switch should be checked by default // Adaptive resources switch should be hidden
await ml.trainedModelsTable.assertAdaptiveResourcesSwitchChecked(true); // always use adaptive resources for serverless projects
await ml.trainedModelsTable.assertAdaptiveResourcesSwitchExists(false);
// Static allocations should be allowed for search projects
await ml.trainedModelsTable.toggleAdaptiveResourcesSwitch(false);
await ml.trainedModelsTable.assertVCPUHelperText(
'Your model will consume 4,096 VCUs, even when not in use.'
);
}); });
}); });
}); });