fix: kv cache support in builtin backend
This commit is contained in:
@@ -101,7 +101,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
|
||||
const renderHeader = () => {
|
||||
return (
|
||||
<Header>
|
||||
<span className="title">YAML Editor</span>
|
||||
<span className="title">YAML</span>
|
||||
<Upload
|
||||
name="file"
|
||||
multiple={false}
|
||||
@@ -110,7 +110,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
|
||||
accept=".yaml,.yml,text/yaml,application/x-yaml"
|
||||
>
|
||||
<Button icon={<ImportOutlined />} type="text" size="small">
|
||||
Import
|
||||
{intl.formatMessage({ id: 'common.button.import' })}
|
||||
</Button>
|
||||
</Upload>
|
||||
</Header>
|
||||
|
||||
@@ -2,6 +2,7 @@ import MindIELogo from '@/assets/logo/ascend.png';
|
||||
import SGLangLogo from '@/assets/logo/sglang.png';
|
||||
import vLLMLogo from '@/assets/logo/vllm.png';
|
||||
import icons from '@/components/icon-font/icons';
|
||||
import { backendOptionsMap } from '@/pages/llmodels/config/backend-parameters';
|
||||
import jsYaml from 'js-yaml';
|
||||
import { trim } from 'lodash';
|
||||
|
||||
@@ -16,18 +17,11 @@ const SealYamlType = new jsYaml.Type('!seal', {
|
||||
|
||||
const SEAL_SCHEMA = jsYaml.DEFAULT_SCHEMA.extend([SealYamlType]);
|
||||
|
||||
export const builtInBackends = {
|
||||
SGLang: 'SGLang',
|
||||
vLLM: 'vLLM',
|
||||
MindIE: 'MindIE',
|
||||
VoxBox: 'voxbox'
|
||||
};
|
||||
|
||||
export const builtInBackendLogos: Record<string, string> = {
|
||||
[builtInBackends.SGLang]: SGLangLogo,
|
||||
[builtInBackends.vLLM]: vLLMLogo,
|
||||
[builtInBackends.MindIE]: MindIELogo,
|
||||
[builtInBackends.VoxBox]: ''
|
||||
[backendOptionsMap.SGLang]: SGLangLogo,
|
||||
[backendOptionsMap.vllm]: vLLMLogo,
|
||||
[backendOptionsMap.ascendMindie]: MindIELogo,
|
||||
[backendOptionsMap.voxBox]: ''
|
||||
};
|
||||
|
||||
export const backendActions = [
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version_configs": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[a-zA-Z0-9._-]+-custom$": {
|
||||
"^[a-zA-Z0-9._-]+$": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"image_name": {
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "multiple backend versions ending with -custom"
|
||||
"description": "multiple backend versions"
|
||||
}
|
||||
},
|
||||
"required": ["version_configs"],
|
||||
|
||||
@@ -7,7 +7,8 @@ export const backendOptionsMap = {
|
||||
vllm: 'vLLM',
|
||||
voxBox: 'VoxBox',
|
||||
ascendMindie: 'MindIE',
|
||||
custom: 'Custom'
|
||||
custom: 'Custom',
|
||||
SGLang: 'SGLang'
|
||||
};
|
||||
|
||||
export interface BackendParameter {
|
||||
@@ -36,5 +37,6 @@ export default {
|
||||
[backendOptionsMap.vllm]: generateBackendParameters(vllmParameters),
|
||||
[backendOptionsMap.ascendMindie]: generateBackendParameters(mindieParameters),
|
||||
[backendOptionsMap.voxBox]: [],
|
||||
[backendOptionsMap.custom]: []
|
||||
[backendOptionsMap.custom]: [],
|
||||
[backendOptionsMap.SGLang]: []
|
||||
};
|
||||
|
||||
@@ -260,6 +260,7 @@ export interface BackendOption {
|
||||
label: string;
|
||||
default_backend_param: string[];
|
||||
default_version: string;
|
||||
isBuiltIn: boolean;
|
||||
versions: { label: string; value: string }[];
|
||||
}
|
||||
|
||||
@@ -273,6 +274,7 @@ export interface BackendItem {
|
||||
from_config: boolean;
|
||||
default_version: string;
|
||||
default_backend_param: string[];
|
||||
is_built_in: boolean;
|
||||
versions: {
|
||||
version: string;
|
||||
is_deprecated: boolean;
|
||||
|
||||
@@ -184,11 +184,26 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
||||
};
|
||||
};
|
||||
|
||||
const updateKVCacheConfig = (backend: string, option: BackendOption) => {
|
||||
if (
|
||||
!option.isBuiltIn &&
|
||||
[backendOptionsMap.SGLang, backendOptionsMap.vllm].includes(backend)
|
||||
) {
|
||||
return {
|
||||
extended_kv_cache: {
|
||||
enabled: false
|
||||
}
|
||||
};
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
||||
const handleBackendChange = async (val: string, option: BackendOption) => {
|
||||
form.setFieldsValue({
|
||||
env: null,
|
||||
backend_version: option.default_version || '',
|
||||
backend_parameters: option.default_backend_param || [],
|
||||
...updateKVCacheConfig(val, option),
|
||||
...updateGPUSelector(val)
|
||||
});
|
||||
onBackendChange?.(val);
|
||||
|
||||
@@ -3,14 +3,17 @@ import SealInputNumber from '@/components/seal-form/input-number';
|
||||
import SealInput from '@/components/seal-form/seal-input';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import { useMemo } from 'react';
|
||||
import { backendOptionsMap } from '../config/backend-parameters';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
|
||||
const KVCacheForm = () => {
|
||||
const intl = useIntl();
|
||||
const form = Form.useFormInstance();
|
||||
const { onValuesChange } = useFormContext();
|
||||
const { onValuesChange, backendOptions } = useFormContext();
|
||||
const kvCacheEnabled = Form.useWatch(['extended_kv_cache', 'enabled'], form);
|
||||
const backend = Form.useWatch('backend', form);
|
||||
|
||||
const handleOnChange = async (e: any) => {
|
||||
if (e.target.checked) {
|
||||
@@ -29,6 +32,19 @@ const KVCacheForm = () => {
|
||||
onValuesChange?.({}, form.getFieldsValue());
|
||||
};
|
||||
|
||||
const builtInBackend = useMemo(() => {
|
||||
const currentBackend = backendOptions.find(
|
||||
(item) => item.value === backend
|
||||
);
|
||||
|
||||
return (
|
||||
currentBackend?.isBuiltIn &&
|
||||
[backendOptionsMap.SGLang, backendOptionsMap.vllm].includes(
|
||||
backend as string
|
||||
)
|
||||
);
|
||||
}, [backend, backendOptions]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ paddingBottom: 22 }}>
|
||||
@@ -37,8 +53,21 @@ const KVCacheForm = () => {
|
||||
name={['extended_kv_cache', 'enabled']}
|
||||
valuePropName="checked"
|
||||
style={{ padding: '0 10px', marginBottom: 0 }}
|
||||
extra={
|
||||
!builtInBackend && (
|
||||
<span
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: intl.formatMessage({ id: 'models.form.kvCache.tips' })
|
||||
}}
|
||||
></span>
|
||||
)
|
||||
}
|
||||
>
|
||||
<CheckboxField
|
||||
description={intl.formatMessage({
|
||||
id: 'models.form.kvCache.tips2'
|
||||
})}
|
||||
disabled={!builtInBackend}
|
||||
onChange={handleOnChange}
|
||||
label={intl.formatMessage({ id: 'models.form.extendedkvcache' })}
|
||||
></CheckboxField>
|
||||
@@ -65,6 +94,15 @@ const KVCacheForm = () => {
|
||||
</Form.Item>
|
||||
<Form.Item<FormData> name={['extended_kv_cache', 'remote_url']}>
|
||||
<SealInput.Input
|
||||
description={
|
||||
<span
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: intl.formatMessage({
|
||||
id: 'models.form.remoteURL.tips'
|
||||
})
|
||||
}}
|
||||
></span>
|
||||
}
|
||||
label={intl.formatMessage({ id: 'models.form.remoteURL' })}
|
||||
min={0}
|
||||
step={1}
|
||||
|
||||
@@ -14,6 +14,7 @@ export default function useQueryBackends() {
|
||||
label: item.backend_name,
|
||||
default_backend_param: item.default_backend_param || [],
|
||||
default_version: item.default_version,
|
||||
isBuiltIn: item.is_built_in,
|
||||
versions: (item.versions || []).map((vItem) => ({
|
||||
label: vItem.version,
|
||||
value: vItem.version
|
||||
|
||||
Reference in New Issue
Block a user