From 1a2e82f079a006392a64cf46ee0d88c7a2cb5014 Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 26 Jan 2026 20:21:23 +0800 Subject: [PATCH] chore: profile config --- src/config/global.d.ts | 2 +- src/pages/benchmark/apis/index.ts | 21 ++- .../components/configure/benchmark.tsx | 64 ++++++++ .../benchmark/components/configure/index.tsx | 16 +- .../components/configure/instance.tsx | 101 +++++++++++++ .../components/environment/gpu-data.tsx | 65 ++++++--- .../components/environment/index.tsx | 9 +- .../components/environment/worker-data.tsx | 4 + .../benchmark/components/left-actions.tsx | 48 +++++- .../benchmark/components/right-actions.tsx | 12 +- .../benchmark/components/summary/basic.tsx | 26 +--- .../benchmark/components/summary/metrics.tsx | 24 +-- .../benchmark/components/summary/section.tsx | 20 ++- src/pages/benchmark/config/index.ts | 30 +++- src/pages/benchmark/config/types.ts | 13 ++ src/pages/benchmark/details.tsx | 7 +- src/pages/benchmark/forms/basic.tsx | 23 ++- src/pages/benchmark/forms/dataset.tsx | 138 +++++++++++++++--- src/pages/benchmark/forms/index.tsx | 12 +- src/pages/benchmark/forms/random-settings.tsx | 51 +++---- src/pages/benchmark/hooks/use-export-data.ts | 28 ++++ src/pages/benchmark/index.tsx | 38 +++++ .../benchmark/services/use-query-dataset.ts | 29 +++- .../benchmark/services/use-query-metrics.ts | 22 --- .../benchmark/services/use-query-profiles.ts | 57 ++++++++ .../llmodels/services/use-query-model-list.ts | 76 +++------- .../resources/services/use-query-gpus.ts | 25 ++++ 27 files changed, 730 insertions(+), 231 deletions(-) create mode 100644 src/pages/benchmark/components/configure/benchmark.tsx create mode 100644 src/pages/benchmark/components/configure/instance.tsx create mode 100644 src/pages/benchmark/hooks/use-export-data.ts delete mode 100644 src/pages/benchmark/services/use-query-metrics.ts create mode 100644 src/pages/benchmark/services/use-query-profiles.ts create mode 100644 src/pages/resources/services/use-query-gpus.ts diff --git a/src/config/global.d.ts b/src/config/global.d.ts index fa700937..5962f937 100644 --- a/src/config/global.d.ts +++ b/src/config/global.d.ts @@ -56,7 +56,7 @@ declare namespace Global { currentUser?: UserInfo; } - type SearchParams = Pagination & { search?: string }; + type SearchParams = Pagination & { search?: string; [key: string]: any }; type MessageType = 'transition' | 'warning' | 'danger' | 'success' | 'info'; diff --git a/src/pages/benchmark/apis/index.ts b/src/pages/benchmark/apis/index.ts index 2f15fcb4..c6ea7d96 100644 --- a/src/pages/benchmark/apis/index.ts +++ b/src/pages/benchmark/apis/index.ts @@ -1,10 +1,15 @@ import { request } from '@umijs/max'; import { CancelToken } from 'axios'; -import { BenchmarkMetricsFormData } from '../config/detail-types'; -import { BenchmarkListItem, DatasetListItem, FormData } from '../config/types'; +import { + BenchmarkListItem, + DatasetListItem, + FormData, + ProfileOption +} from '../config/types'; export const BENCHMARKS_API = '/benchmarks'; export const DATASETS_API = '/datasets'; +export const PROFILES_CONFIG_API = '/benchmark-profiles/default-config'; export async function queryBenchmarkList( params: Global.SearchParams, @@ -83,18 +88,18 @@ export async function queryDatasetList( }); } -export async function queryBenchmarkMetrics( +export async function queryProfiles( params: { - id: number; - data: BenchmarkMetricsFormData; + id?: number | string; }, options?: { token?: CancelToken; } ) { - return request(`${BENCHMARKS_API}/${params.id}/metrics`, { - method: 'POST', - data: params.data, + return request<{ + profiles: ProfileOption[]; + }>(`${PROFILES_CONFIG_API}`, { + method: 'get', cancelToken: options?.token }); } diff --git a/src/pages/benchmark/components/configure/benchmark.tsx b/src/pages/benchmark/components/configure/benchmark.tsx new file mode 100644 index 00000000..bf010b29 --- /dev/null +++ b/src/pages/benchmark/components/configure/benchmark.tsx @@ -0,0 +1,64 @@ +import { Descriptions, DescriptionsProps } from 'antd'; +import React from 'react'; +import { useDetailContext } from '../../config/detail-context'; +import Section from '../summary/section'; + +const Benchmark: React.FC = () => { + const { detailData } = useDetailContext(); + + const items: DescriptionsProps['items'] = [ + { + key: '1', + label: 'Profile', + children: detailData?.profile || '-' + }, + { + key: '2', + label: 'Dataset', + children: detailData?.dataset_name || '-' + }, + { + key: '3', + label: 'Token Length (In/Out)', + children: ( + + {detailData?.dataset_input_tokens || '-'} /{' '} + {detailData?.dataset_output_tokens || '-'} + + ) + }, + { + key: '5', + label: 'Seed', + children: detailData?.seed || '-' + }, + { + key: '6', + label: 'Request Rate', + children: detailData?.request_rate || '-' + }, + { + key: '7', + label: 'Total Requests', + children: detailData?.total_requests || '-' + } + ]; + + return ( +
+ +
+ ); +}; + +export default Benchmark; diff --git a/src/pages/benchmark/components/configure/index.tsx b/src/pages/benchmark/components/configure/index.tsx index 44136e49..b167b59a 100644 --- a/src/pages/benchmark/components/configure/index.tsx +++ b/src/pages/benchmark/components/configure/index.tsx @@ -1,9 +1,23 @@ import React from 'react'; +import styled from 'styled-components'; import { useDetailContext } from '../../config/detail-context'; +import Benchmark from './benchmark'; +import Instance from './instance'; + +const Container = styled.div` + display: flex; + flex-direction: column; + gap: 16px; +`; const Configure: React.FC = () => { const { detailData } = useDetailContext(); - return
Configure Content
; + return ( + + + + + ); }; export default Configure; diff --git a/src/pages/benchmark/components/configure/instance.tsx b/src/pages/benchmark/components/configure/instance.tsx new file mode 100644 index 00000000..363684df --- /dev/null +++ b/src/pages/benchmark/components/configure/instance.tsx @@ -0,0 +1,101 @@ +import StatusTag from '@/components/status-tag'; +import { InstanceStatusMapValue, status } from '@/pages/llmodels/config'; +import { convertFileSize } from '@/utils'; +import { Descriptions } from 'antd'; +import _ from 'lodash'; +import React, { useMemo } from 'react'; +import { useDetailContext } from '../../config/detail-context'; +import Section from '../summary/section'; + +const calcTotalVram = (vram: Record) => { + return _.sum(_.values(vram)); +}; + +const Instance: React.FC = () => { + const { detailData } = useDetailContext(); + + const items = useMemo(() => { + const { snapshot } = detailData; + const [instanceName, instanceData] = + Object.entries(snapshot.instances || {})[0] || []; + return [ + { + key: '1', + label: 'Instance Name', + children: ( +
+ {instanceName} + +
+ ) + }, + { + key: '2', + label: 'Worker', + children: instanceData?.worker_name || '-' + // children: + // instanceData?.ports?.length > 0 + // ? `${instanceData.worker_ip}:${instanceData.ports[0]}` + // : instanceData.worker_ip || '-' + }, + { + key: '3', + label: 'GPU Indexes', + children: + _.join( + instanceData.gpu_indexes?.sort?.((a, b) => a - b), + ',' + ) || '-' + }, + { + key: '6', + label: 'GPU Type', + children: instanceData?.gpu_type || '-' + }, + { + key: '4', + label: 'Allocated VRAM', + children: + convertFileSize( + instanceData.computed_resource_claim?.vram + ? calcTotalVram(instanceData.computed_resource_claim?.vram) + : 0, + 1 + ) || '-' + }, + { + key: '5', + label: 'Backend', + children: `${instanceData?.backend || '-'} ${ + instanceData.backend_version + ? `(${instanceData.backend_version})` + : '' + }` + } + ]; + }, [detailData]); + + return ( +
+ +
+ ); +}; + +export default Instance; diff --git a/src/pages/benchmark/components/environment/gpu-data.tsx b/src/pages/benchmark/components/environment/gpu-data.tsx index f40e5865..f7078a0b 100644 --- a/src/pages/benchmark/components/environment/gpu-data.tsx +++ b/src/pages/benchmark/components/environment/gpu-data.tsx @@ -1,16 +1,28 @@ +import AutoTooltip from '@/components/auto-tooltip'; import { convertFileSize } from '@/utils'; import { Descriptions, DescriptionsProps } from 'antd'; import React from 'react'; +import styled from 'styled-components'; import { GPUData } from '../../config/detail-types'; import Section from '../summary/section'; +const Content = styled.div` + display: flex; + flex-direction: column; + gap: 12px; + align-items: flex-start; + .name { + font-weight: 500; + } +`; + const Environment: React.FC = (props) => { const items: DescriptionsProps['items'] = [ - { - key: '4', - label: 'Name', - children: props.name - }, + // { + // key: '4', + // label: 'Name', + // children: {props.name} + // }, { key: '1', label: 'VRAM', @@ -18,12 +30,12 @@ const Environment: React.FC = (props) => { }, { key: '3', - label: 'Driver Version', + label: 'Driver', children: props.driver_version }, { key: '2', - label: 'Runtime Version', + label: 'Runtime', children: props.runtime_version }, { @@ -35,21 +47,36 @@ const Environment: React.FC = (props) => { key: '5', label: 'Vendor', children: props.vendor + }, + { + key: '7', + label: 'GPU Type', + children: props.type } ]; return ( -
- +
+ GPU {props.index} + + } + > + +
+ {props.name} +
+ +
); }; diff --git a/src/pages/benchmark/components/environment/index.tsx b/src/pages/benchmark/components/environment/index.tsx index 7b574c41..998199cd 100644 --- a/src/pages/benchmark/components/environment/index.tsx +++ b/src/pages/benchmark/components/environment/index.tsx @@ -63,7 +63,14 @@ const Environment: React.FC = () => { gpuData={mainWorker.gpuData} title={
- Sub + + Sub + {mainWorker?.workerData?.name}
} diff --git a/src/pages/benchmark/components/environment/worker-data.tsx b/src/pages/benchmark/components/environment/worker-data.tsx index 84dec986..885a7cb4 100644 --- a/src/pages/benchmark/components/environment/worker-data.tsx +++ b/src/pages/benchmark/components/environment/worker-data.tsx @@ -31,6 +31,10 @@ const Environment: React.FC<{
) => void; handleSearch: () => void; + handleQueryChange: (value: any, option?: any) => void; + modelList?: Global.BaseOption[]; + datasetList?: Global.BaseOption[]; + gpuVendorList?: Global.BaseOption[]; } const RightActions: React.FC = ({ handleInputChange, - handleSearch + handleSearch, + handleQueryChange, + modelList, + datasetList, + gpuVendorList }) => { const intl = useIntl(); @@ -29,7 +38,42 @@ const RightActions: React.FC = ({ allowClear onChange={handleInputChange} > - {/* */} + + handleQueryChange({ + model_name: value, + page: 1 + }) + } + > + + handleQueryChange({ + dataset_name: value, + page: 1 + }) + } + > + + handleQueryChange({ + gpu_summary: value, + page: 1 + }) + } + style={{ width: 180 }} + options={gpuVendorList} + >