From 3a7a4ccf30747ac7740b10954f0f125d14199018 Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 20 Oct 2025 19:10:08 +0800 Subject: [PATCH] fix: check driver command for adding worker --- .../seal-form/components/label-info.less | 5 ++ .../_components}/password-validate/index.tsx | 0 .../backends/components/backend-card.tsx | 57 ++++++++--------- src/pages/backends/config/index.ts | 12 +--- .../components/add-worker-command.tsx | 2 +- .../components/check-env-command.tsx | 7 ++- .../components/support-gpus.tsx | 43 +++++++++++++ .../llmodels/components/catalog-item.tsx | 4 +- src/pages/llmodels/forms/index.tsx | 11 ++-- src/pages/llmodels/forms/schedule-type.tsx | 13 +++- src/pages/playground/hooks/config.ts | 6 +- src/pages/resources/config/index.ts | 63 +++++++++++++++++-- 12 files changed, 162 insertions(+), 61 deletions(-) rename src/{components => pages/_components}/password-validate/index.tsx (100%) diff --git a/src/components/seal-form/components/label-info.less b/src/components/seal-form/components/label-info.less index cea6b5cd..cc823c20 100644 --- a/src/components/seal-form/components/label-info.less +++ b/src/components/seal-form/components/label-info.less @@ -5,6 +5,11 @@ color: var(--ant-color-text-tertiary); font-size: var(--font-size-base); + > span { + display: flex; + align-items: center; + } + .note-info { margin-left: 4px; } diff --git a/src/components/password-validate/index.tsx b/src/pages/_components/password-validate/index.tsx similarity index 100% rename from src/components/password-validate/index.tsx rename to src/pages/_components/password-validate/index.tsx diff --git a/src/pages/backends/components/backend-card.tsx b/src/pages/backends/components/backend-card.tsx index 619ee73e..42c814fa 100644 --- a/src/pages/backends/components/backend-card.tsx +++ b/src/pages/backends/components/backend-card.tsx @@ -1,6 +1,7 @@ import AutoTooltip from '@/components/auto-tooltip'; import DropDownActions from '@/components/drop-down-actions'; import IconFont from '@/components/icon-font'; +import TagWrapper from '@/components/tags-wrapper'; import ThemeTag from '@/components/tags-wrapper/theme-tag'; import Card from '@/components/templates/card'; import { useIntl } from '@umijs/max'; @@ -89,6 +90,7 @@ const Content = styled.div` const InfoItem = styled.div` display: grid; + width: 100%; grid-template-columns: max-content 1fr; align-items: center; gap: 8px; @@ -103,12 +105,6 @@ const InfoItem = styled.div` } `; -const BackendBox = styled.div` - display: flex; - align-items: center; - gap: 8px; -`; - interface BackendCardProps { onClick?: (data: any) => void; onSelect?: (item: any) => void; @@ -151,6 +147,25 @@ const BackendCard: React.FC = ({ data, onSelect }) => { e.stopPropagation(); }; + const renderTag = (item: any) => { + return ( + + + {item} + + + ); + }; + const renderFrameworks = () => { const frameworks = _.keys(data.framework_index_map || {}); @@ -162,31 +177,11 @@ const BackendCard: React.FC = ({ data, onSelect }) => { {intl.formatMessage({ id: 'backend.availableFrameworks' })}:{' '} - - - {_.take(frameworks, 3).map((item: string) => { - return ( -
- - - {item} - - -
- ); - })} -
+ ); }; diff --git a/src/pages/backends/config/index.ts b/src/pages/backends/config/index.ts index 44db5d50..263c2f8a 100644 --- a/src/pages/backends/config/index.ts +++ b/src/pages/backends/config/index.ts @@ -91,20 +91,14 @@ export const gpuColorMap: Record = { rocm: 'volcano', dtk: 'magenta', musa: 'cyan', - corex: 'purple' + corex: 'purple', + maca: 'geekblue' }; export const getGpuColor = (gpuType: string) => { if (!gpuType) return 'default'; - if (gpuType.includes('cann')) return gpuColorMap['cann']; - if (gpuType.includes('cuda')) return gpuColorMap['cuda']; - if (gpuType.includes('rocm')) return gpuColorMap['rocm']; - if (gpuType.includes('dtk')) return gpuColorMap['dtk']; - if (gpuType.includes('musa')) return gpuColorMap['musa']; - if (gpuType.includes('corex')) return gpuColorMap['corex']; - - return 'default'; + return gpuColorMap[gpuType] || 'default'; }; export const customIcons = [ diff --git a/src/pages/cluster-management/components/add-worker-command.tsx b/src/pages/cluster-management/components/add-worker-command.tsx index 90a5716e..9b41e5cd 100644 --- a/src/pages/cluster-management/components/add-worker-command.tsx +++ b/src/pages/cluster-management/components/add-worker-command.tsx @@ -12,7 +12,7 @@ type ViewModalProps = { const AddWorkerCommand: React.FC = ({ registrationInfo }) => { const code = React.useMemo(() => { - const commandCode = addWorkerGuide['cuda']; + const commandCode = addWorkerGuide['all']; return commandCode?.registerWorker({ server: registrationInfo.server_url || origin, tag: '', diff --git a/src/pages/cluster-management/components/check-env-command.tsx b/src/pages/cluster-management/components/check-env-command.tsx index 18376329..d1d491c9 100644 --- a/src/pages/cluster-management/components/check-env-command.tsx +++ b/src/pages/cluster-management/components/check-env-command.tsx @@ -13,9 +13,10 @@ const AddWorkerCommand: React.FC = ({ currentGPU }) => { const code = React.useMemo(() => { - const command = addWorkerGuide['cuda']; - return command.checkEnvCommand[provider || '']; - }, [provider]); + const configs = addWorkerGuide['all']; + const command = configs.checkEnvCommand(currentGPU); + return command[provider || '']; + }, [provider, currentGPU]); return ( = ({ onSelect, clickable, diff --git a/src/pages/llmodels/components/catalog-item.tsx b/src/pages/llmodels/components/catalog-item.tsx index 11db6f56..535ababd 100644 --- a/src/pages/llmodels/components/catalog-item.tsx +++ b/src/pages/llmodels/components/catalog-item.tsx @@ -30,7 +30,7 @@ const CatalogItem: React.FC = (props) => { e.target.src = fallbackImg; }; - const renderTag = (sItem: any) => { + const renderTag = useCallback((sItem: any) => { return ( = (props) => { {sItem}B ); - }; + }, []); return (
= forwardRef((props, ref) => { // voxbox is not support multi gpu const updateGPUSelector = (backend: string) => { const gpuids = form.getFieldValue(['gpu_selector', 'gpu_ids']) || []; + const gpusPerReplicas = + form.getFieldValue(['gpu_selector', 'gpus_per_replica']) || null; if (backend === backendOptionsMap.voxBox && gpuids.length > 0) { return { - gpu_selector: { gpu_ids: [gpuids[0]] } + gpusCountType: gpusCountTypeMap.Auto, + gpu_selector: { + gpu_ids: [gpuids[0]] + } }; } return { @@ -131,9 +136,7 @@ const DataForm: React.FC = forwardRef((props, ref) => { getGPUOptionList({ clusterId: value }); getBackendOptions({ cluster_id: value }); if (scheduleType === ScheduleValueMap.Manual) { - form.setFieldsValue({ - gpu_selector: { gpu_ids: [] } - }); + form.setFieldValue(['gpu_selector', 'gpu_ids'], []); } }; diff --git a/src/pages/llmodels/forms/schedule-type.tsx b/src/pages/llmodels/forms/schedule-type.tsx index 7f4b5c89..c0cb630a 100644 --- a/src/pages/llmodels/forms/schedule-type.tsx +++ b/src/pages/llmodels/forms/schedule-type.tsx @@ -52,7 +52,6 @@ const ScheduleTypeForm: React.FC = () => { const form = Form.useFormInstance(); const scheduleType = Form.useWatch('scheduleType', form); const gpusCountType = Form.useWatch('gpusCountType', form); - const gpuSelectorIds = Form.useWatch(['gpu_selector', 'gpu_ids'], form); const handleScheduleTypeChange = (value: string) => { if (value === ScheduleValueMap.Auto) { @@ -61,9 +60,10 @@ const ScheduleTypeForm: React.FC = () => { }; const handleGpusCountTypeChange = (val: string) => { - if (val === 'custom') { - form.setFieldValue(['gpu_selector', 'gpus_per_replica'], 2); + if (val === gpusCountTypeMap.Custom) { + form.setFieldValue(['gpu_selector', 'gpus_per_replica'], 1); } + onValuesChange?.({}, form.getFieldsValue()); }; @@ -91,6 +91,12 @@ const ScheduleTypeForm: React.FC = () => { onValuesChange?.({}, form.getFieldsValue()); }; + const handleOnStepReplica = (value: number | null) => { + if (value === null) { + form.setFieldValue(['gpu_selector', 'gpus_per_replica'], 1); + } + }; + return ( <> @@ -187,6 +193,7 @@ const ScheduleTypeForm: React.FC = () => { })} min={1} step={1} + onChange={handleOnStepReplica} onStep={handleOnStepReplicaStep} /> diff --git a/src/pages/playground/hooks/config.ts b/src/pages/playground/hooks/config.ts index ad002d19..e40ef339 100644 --- a/src/pages/playground/hooks/config.ts +++ b/src/pages/playground/hooks/config.ts @@ -34,9 +34,9 @@ export const llmInitialValues = { stop: null, temperature: 1, top_p: 1, - max_tokens: null, - frequency_penalty: null, - presence_penalty: null + max_tokens: 1024, + frequency_penalty: 0, + presence_penalty: 0 }; export const advancedFieldsDefaultValus = { diff --git a/src/pages/resources/config/index.ts b/src/pages/resources/config/index.ts index e4b9224e..958ea58f 100644 --- a/src/pages/resources/config/index.ts +++ b/src/pages/resources/config/index.ts @@ -34,6 +34,57 @@ export const status: any = { [WorkerStatusMap.initializing]: StatusMaps.transitioning }; +export const GPUsConfigs: Record = { + cuda: { + label: 'NVIDIA', + value: 'cuda', + runtime: 'nvidia', + driver: 'nvidia-smi' + }, + rocm: { + label: 'AMD', + value: 'rocm', + runtime: 'rocm', + driver: 'rocm-smi' + }, + npu: { + label: 'Ascend', + value: 'npu', + runtime: 'ascend', + driver: 'npu-smi' + }, + dcu: { + label: 'Hygon', + value: 'dcu', + runtime: 'dcu', // TODO: confirm runtime name + driver: 'hy-smi' + }, + musa: { + label: 'Moore Threads', + value: 'musa', + runtime: 'mthreads', + driver: 'mthreads-gmi' + }, + corex: { + label: 'Iluvatar', + value: 'corex', + runtime: 'corex', // TODO: confirm runtime name + driver: 'ixsmi' + }, + cambricon: { + label: 'Cambricon', + value: 'cambricon', + runtime: 'cambricon', + driver: 'cnmon' + }, + metax: { + label: 'MetaX', + value: 'metax', + runtime: 'metax', + driver: 'mx-smi' + } +}; + export const addWorkerGuide: Record = { mac: { getToken: 'cat /var/lib/gpustack/token', @@ -48,7 +99,7 @@ export const addWorkerGuide: Record = { return `Invoke-Expression "& { $((Invoke-WebRequest -Uri 'https://get.gpustack.ai' -UseBasicParsing).Content) } --server-url '${params.server}' --registration-token '${params.token}'"`; } }, - cuda: { + all: { getToken: 'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw', registerWorker(params: { @@ -69,10 +120,12 @@ export const addWorkerGuide: Record = { --registration-token ${params.token} \\ --worker-ip ${params.workerip}`; }, - checkEnvCommand: { - [ProviderValueMap.Docker]: `nvidia-smi >/dev/null 2>&1 && echo "NVIDIA driver OK" || (echo "NVIDIA driver issue"; exit 1) && docker info 2>/dev/null | grep -q "Default Runtime: nvidia" && echo "NVIDIA Container Toolkit OK" || (echo "NVIDIA Container Toolkit not configured"; exit 1)`, - [ProviderValueMap.Kubernetes]: - 'kubectl get runtimeclass nvidia > /dev/null 2>&1 && echo "NVIDIA runtimeclass registered" || (echo "NVIDIA runtimeclass issue"; exit 1)' + checkEnvCommand(gpu: string) { + const config = GPUsConfigs[gpu]; + return { + [ProviderValueMap.Docker]: `${config.driver} >/dev/null 2>&1 && echo "${config.label} driver OK" || (echo "${config.label} driver issue"; exit 1) && docker info 2>/dev/null | grep -q "Default Runtime: ${config.runtime}" && echo "${config.label} Container Toolkit OK" || (echo "${config.label} Container Toolkit not configured"; exit 1)`, + [ProviderValueMap.Kubernetes]: `kubectl get runtimeclass ${config.runtime} > /dev/null 2>&1 && echo "${config.label} runtimeclass registered" || (echo "${config.label} runtimeclass issue"; exit 1)` + }; } }, npu: {