diff --git a/frontend/src/components/ResetConfigsButton.tsx b/frontend/src/components/ResetConfigsButton.tsx index 748c934..a9414d5 100644 --- a/frontend/src/components/ResetConfigsButton.tsx +++ b/frontend/src/components/ResetConfigsButton.tsx @@ -3,14 +3,15 @@ import { DialogButton } from './DialogButton'; import { useTranslation } from 'react-i18next'; import { ArrowReset20Regular } from '@fluentui/react-icons'; import commonStore from '../stores/commonStore'; -import { defaultModelConfigs } from '../pages/Configs'; + +import { defaultModelConfigs, defaultModelConfigsMac } from '../pages/defaultModelConfigs'; export const ResetConfigsButton: FC<{ afterConfirm?: () => void }> = ({ afterConfirm }) => { const { t } = useTranslation(); return } tooltip={t('Reset All Configs')} title={t('Reset All Configs')} contentText={t('Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.')} onConfirm={() => { - commonStore.setModelConfigs(defaultModelConfigs, false); + commonStore.setModelConfigs(commonStore.platform != 'darwin' ? defaultModelConfigs : defaultModelConfigsMac, false); commonStore.setCurrentConfigIndex(0, true); afterConfirm?.(); }} />; diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index 168e339..610b5c3 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -30,7 +30,7 @@ export type ApiParameters = { frequencyPenalty: number; } -export type Device = 'CPU' | 'CUDA' | 'Custom'; +export type Device = 'CPU' | 'CUDA' | 'MPS' | 'Custom'; export type Precision = 'fp16' | 'int8' | 'fp32'; export type ModelParameters = { @@ -52,564 +52,6 @@ export type ModelConfig = { modelParameters: ModelParameters } -export const defaultModelConfigs: ModelConfig[] = [ - { - name: 'GPU-2G-1B5-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 4, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-4G-1B5-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-4G-3B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 24, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-4G-3B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 24, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-4G-7B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 8, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-4G-7B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 8, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-6G-1B5-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CUDA', - precision: 'fp16', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-6G-3B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-6G-3B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-6G-7B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 18, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-6G-7B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 18, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: true, - useCustomCuda: true - } - }, - { - name: 'GPU-8G-3B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CUDA', - precision: 'fp16', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-8G-3B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth', - device: 'CUDA', - precision: 'fp16', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-8G-7B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 27, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-8G-7B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 27, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-10G-7B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-10G-7B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-12G-14B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 24, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-16G-7B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth', - device: 'CUDA', - precision: 'fp16', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-16G-7B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth', - device: 'CUDA', - precision: 'fp16', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-16G-14B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 37, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-18G-14B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth', - device: 'CUDA', - precision: 'int8', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'GPU-32G-14B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-14B-v12-Eng98%-Other2%-20230523-ctx8192.pth', - device: 'CUDA', - precision: 'fp16', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false, - useCustomCuda: true - } - }, - { - name: 'CPU-6G-1B5-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-1B5-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CPU', - precision: 'fp32', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false - } - }, - { - name: 'CPU-12G-3B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng98%-Other2%-20230520-ctx4096.pth', - device: 'CPU', - precision: 'fp32', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false - } - }, - { - name: 'CPU-12G-3B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-3B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230527-ctx4096.pth', - device: 'CPU', - precision: 'fp32', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false - } - }, - { - name: 'CPU-28G-7B-EN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng98%-Other2%-20230521-ctx8192.pth', - device: 'CPU', - precision: 'fp32', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false - } - }, - { - name: 'CPU-28G-7B-CN', - apiParameters: { - apiPort: 8000, - maxResponseToken: 4100, - temperature: 1.2, - topP: 0.5, - presencePenalty: 0.4, - frequencyPenalty: 0.4 - }, - modelParameters: { - modelName: 'RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth', - device: 'CPU', - precision: 'fp32', - storedLayers: 41, - maxStoredLayers: 41, - enableHighPrecisionForLastLayer: false - } - } -]; - export const Configs: FC = observer(() => { const { t } = useTranslation(); const [selectedIndex, setSelectedIndex] = React.useState(commonStore.currentModelConfigIndex); @@ -836,6 +278,7 @@ export const Configs: FC = observer(() => { } }}> + {commonStore.platform === 'darwin' && } @@ -903,7 +346,8 @@ export const Configs: FC = observer(() => { onMouseEnter={() => setDisplayStrategyImg(true)} onMouseLeave={() => setDisplayStrategyImg(false)} content={ - cuda:1 fp16' : 'mps fp32'} value={selectedConfig.modelParameters.customStrategy} onChange={(e, data) => { setSelectedConfigModelParams({ @@ -914,7 +358,7 @@ export const Configs: FC = observer(() => { } {selectedConfig.modelParameters.device == 'Custom' &&
} { - selectedConfig.modelParameters.device != 'CPU' && + selectedConfig.modelParameters.device != 'CPU' && selectedConfig.modelParameters.device != 'MPS' && = 0 && configData.currentModelConfigIndex < configData.modelConfigs.length) commonStore.setCurrentConfigIndex(configData.currentModelConfigIndex, false); }).catch(() => { - commonStore.setModelConfigs(defaultModelConfigs, true); + commonStore.setModelConfigs(commonStore.platform != 'darwin' ? defaultModelConfigs : defaultModelConfigsMac, true); }); } diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index 9a0b88f..2d20684 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -2,7 +2,7 @@ import { makeAutoObservable } from 'mobx'; import { getUserLanguage, isSystemLightMode, saveConfigs } from '../utils'; import { WindowSetDarkTheme, WindowSetLightTheme } from '../../wailsjs/runtime'; import manifest from '../../../manifest.json'; -import { defaultModelConfigs, ModelConfig } from '../pages/Configs'; +import { ModelConfig } from '../pages/Configs'; import { Conversations } from '../pages/Chat'; import { ModelSourceItem } from '../pages/Models'; import { DownloadStatus } from '../pages/Downloads'; @@ -11,6 +11,8 @@ import { IntroductionContent } from '../pages/Home'; import { AboutContent } from '../pages/About'; import i18n from 'i18next'; import { CompletionPreset } from '../pages/Completion'; +import { defaultModelConfigs, defaultModelConfigsMac } from '../pages/defaultModelConfigs'; +import commonStore from './commonStore'; export enum ModelStatus { Offline, @@ -98,7 +100,8 @@ class CommonStore { createModelConfig = (config: ModelConfig = defaultModelConfigs[0], saveConfig: boolean = true) => { if (config.name === defaultModelConfigs[0].name) { - config = JSON.parse(JSON.stringify(config)); // deep copy + // deep copy + config = JSON.parse(JSON.stringify(commonStore.platform != 'darwin' ? defaultModelConfigs[0] : defaultModelConfigsMac[0])); config.name = new Date().toLocaleString(); } this.modelConfigs.push(config); diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index c2498b1..5554982 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -141,6 +141,10 @@ export const getStrategy = (modelConfig: ModelConfig | undefined = undefined) => if (params.enableHighPrecisionForLastLayer) strategy += ' -> cpu fp32 *1'; break; + case 'MPS': + strategy += 'mps '; + strategy += params.precision === 'fp16' ? 'fp16' : params.precision === 'int8' ? 'fp16i8' : 'fp32'; + break; case 'Custom': strategy = params.customStrategy || ''; break;