Skip to content

Studio: add "Compare with base" action to fine-tuned models - #6761

Closed
NilayYadav wants to merge 7 commits into
unslothai:mainfrom
NilayYadav:studio-compare-base-vs-finetuned
Closed

NilayYadav wants to merge 7 commits into
unslothai:mainfrom
NilayYadav:studio-compare-base-vs-finetuned

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Adds a "Compare with base" button to each fine-tuned Lora adapter row in the chat model selector. Clicking it loads the adapter and opens the base-vs-fine-tuned compare view. The base-vs-fine-tuned compare was only reachable right after training (via the "Compare in chat" button on the training progress screen). For any previously trained model there was no obvious way to get back to it you'd have to load the LoRA.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to compare a LoRA adapter model with its base model. It adds a "Compare with base model" action in the model selector, propagates the comparison callback through the picker components, and includes a "Compare in Chat" button in the training progress section for completed LoRA runs. Additionally, the training compare handoff mechanism is updated to support resolving the model via loraPath. A critical bug was identified in normalizeLoraPath where calling .replace() on value?.trim() will throw a TypeError if value is null or undefined.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfbf8fc7b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85618577b0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 05518865a9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Imagineer99

Copy link
Copy Markdown
Member

Ran a focused check here: https://github.com/Imagineer99/unsloth/actions/runs/29423258458

Looks good, the compare-with-base wiring passes and the Studio frontend typecheck is green.

@Imagineer99

Imagineer99 commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

@NilayYadav From initial manual testing, functionality seems good! I think directionally this is also useful.

One thing we should adjust in terms of UX: When using this flow for compare, the user loses access to model/LoRa selection, and can't readily tell which model/LoRa combination they are using if the user forgets.

Additionally while this may be an existing on inherited style, perhaps we should increase the top margin of the green Base Model / Fine-tuned text so that it aligns more cleanly with the adjacent svg's, or at least has some breathing room.

image

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@NilayYadav From initial manual testing, functionality seems good! I think directionally this is also useful.

One thing we should adjust in terms of UX: When using this flow for compare, the user loses access to model/LoRa selection, and can't readily tell which model/LoRa combination they are using if the user forgets.

Additionally while this may be an existing on inherited style, perhaps we should increase the top margin of the green Base Model / Fine-tuned text so that it aligns more cleanly with the adjacent svg's, or at least has some breathing room.

image

fair point added

Screenshot 2026-07-16 at 4 04 58 AM

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02ca83f2e5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

} catch {
return;
}
enterCompare();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enter compare only after the adapter loads

When this action is used while another chat is running and the user declines the stop-running confirmation, selectModel returns normally without switching checkpoints, but this code still calls enterCompare(). The same direct selectModel call also bypasses the normal stageOrLoad path that applies remembered per-model settings, so the compare view can open for the previous checkpoint or run the adapter under stale settings; gate enterCompare on a confirmed loaded adapter and use the same load path as a normal row selection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 236dd7a: compare goes through stageOrLoad, so the remembered per-model settings apply, and it only enters once the adapter is the live checkpoint, so a declined stop-running-chats confirm or a rival in-flight load no longer opens the split view on the old model.

Comment on lines +812 to +814
models={models}
loraModels={loraModels}
externalModels={externalModels}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Keep the LoRA compare selector adapter-only

In the LoRA compare view this fine-tuned-pane selector is given the full model catalog, so if the user picks a non-LoRA row such as a merged/GGUF/external model, useIsLoraCompare flips to the general compare view and GeneralCompareContent initializes model1 from that global checkpoint while leaving model2 empty. The model chosen from the right pane therefore lands in the left pane and compare is blocked until another model is selected; restrict this selector to adapter LoRAs or route non-LoRA choices into the second pane.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector is the only one visible in compare mode (the topbar selector is hidden there); restricting it to adapters would strand non-adapter switches behind an exit. A non-LoRA pick lands in the left pane with correct attribution and the composer explains the empty pane.

}

function normalizeLoraPath(value: string | null | undefined): string {
return value?.trim().replace(/[/\\]+$/, "").toLowerCase() ?? "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Preserve case when matching LoRA paths

On case-sensitive filesystems, lowercasing the explicit adapter path can make a handoff for /outputs/Foo match /outputs/foo when both runs exist, so Compare with base may load whichever case-colliding adapter the scanner returns first even though the requested path is present. Path equality should only normalize separators/trailing slashes, or apply case folding only on platforms where paths are actually case-insensitive.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both sides are backend-produced paths and the backend refuses casefold-colliding stems on any host, so the only realistic divergence is casing drift, which the fold absorbs; dropping it would turn that into a spurious not-found toast. Case-folded identity is also the repo convention for model refs.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 236dd7a8ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants