Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
merge nightly, resolve conflict in use-chat-model-runtime
Roland Tannous91dd7fc762e1
diff --cc studio/frontend/src/features/chat/hooks/use-chat-model-runtime.tsindex 27fc8f99e68,2167f4d91c6..303030372d9--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts@@@ -204,26 -212,59 +216,61 @@@ export function useChatModelRuntime()setLoadingModel({ id: modelId, displayName });try {async function performLoad(): Promise<void> {+ let previousWasUnloaded = false;const currentCheckpoint =useChatRuntimeStore.getState().params.checkpoint;- if (currentCheckpoint) {- await unloadModel({ model_path: currentCheckpoint });- }+ try {+ // Lightweight pre-flight validation: avoid unloading a working model+ // if the new identifier is clearly invalid (e.g. bad HF id / path).+ await validateModel({+ model_path: modelId,+ hf_token: null,+ max_seq_length: DEFAULT_MODEL_MAX_SEQ_LENGTH,+ load_in_4bit: true,+ is_lora: isLora,+ gguf_variant: ggufVariant ?? null,+ });++ if (currentCheckpoint) {+ await unloadModel({ model_path: currentCheckpoint });+ previousWasUnloaded = true;+ }- const currentParams = useChatRuntimeStore.getState().params;- const loadResponse = await loadModel({- model_path: modelId,- hf_token: null,- max_seq_length: DEFAULT_MODEL_MAX_SEQ_LENGTH,- load_in_4bit: true,- is_lora: isLora,- gguf_variant: ggufVariant ?? null,- trust_remote_code: currentParams.trustRemoteCode ?? false,- });-- const paramsAfterLoad = useChatRuntimeStore.getState().params;- setParams(mergeRecommendedInference(paramsAfterLoad, loadResponse, modelId));- await refresh();++ const paramsBeforeLoad = useChatRuntimeStore.getState().params;+ const loadResponse = await loadModel({+ model_path: modelId,+ hf_token: null,+ max_seq_length: DEFAULT_MODEL_MAX_SEQ_LENGTH,+ load_in_4bit: true,+ is_lora: isLora,+ gguf_variant: ggufVariant ?? null,++ trust_remote_code: paramsBeforeLoad.trustRemoteCode ?? false,+ });++ const currentParams = useChatRuntimeStore.getState().params;+ setParams(+ mergeRecommendedInference(currentParams, loadResponse, modelId),+ );+ await refresh();+ } catch (error) {+ // If we unloaded a previous model and the new load failed, attempt a rollback.+ if (previousWasUnloaded && previousCheckpoint) {+ try {+ await loadModel({+ model_path: previousCheckpoint,+ hf_token: null,+ max_seq_length: DEFAULT_MODEL_MAX_SEQ_LENGTH,+ load_in_4bit: true,+ is_lora: previousIsLora,+ gguf_variant: previousVariant,+ });+ await refresh();+ } catch {+ // If rollback also fails, surface the original error.+ }+ }+ throw error;+ }}const loadPromise = performLoad().finally(() => {diff --cc studio/frontend/src/features/chat/types/api.tsindex 08bdc204359,090ffc93dfc..602574f00a5--- a/studio/frontend/src/features/chat/types/api.ts+++ b/studio/frontend/src/features/chat/types/api.ts@@@ -34,10 -34,18 +34,20 @@@ export interface LoadModelRequestload_in_4bit: boolean;is_lora: boolean;gguf_variant?: string | null;+ /** Allow loading models with custom code (e.g. NVIDIA Nemotron). Only enable for repos you trust. */+ trust_remote_code?: boolean;}+ export interface ValidateModelResponse {+ valid: boolean;+ message: string;+ identifier?: string | null;+ display_name?: string | null;+ is_gguf?: boolean;+ is_lora?: boolean;+ is_vision?: boolean;+ }+export interface GgufVariantDetail {filename: string;quant: string;diff --cc studio/frontend/src/features/training/api/mappers.tsindex 2a8b302d34a,b89bdcbd466..1b3207ea9ed--- a/studio/frontend/src/features/training/api/mappers.ts+++ b/studio/frontend/src/features/training/api/mappers.ts@@@ -30,9 -34,8 +34,9 @@@ export function buildTrainingStartPaylomodel_name: config.selectedModel ?? "",training_type: toBackendTrainingType(config.trainingMethod),hf_token: config.hfToken.trim() || null,- load_in_4bit: adapterMethod ? isQlorMethod : false,+ load_in_4bit: adapterMethod ? isQloraMethod : false,max_seq_length: config.contextLength,+ trust_remote_code: config.trustRemoteCode ?? false,hf_dataset: hfDataset,subset: hfDataset ? config.datasetSubset : null,train_split: hfDataset ? config.datasetSplit : null,