Skip to content

[Feature] compare for 2 diff models#4356

Merged
rolandtannous merged 6 commits into
mainfrom
feature/compare-two-diff-models
Mar 17, 2026
Merged

[Feature] compare for 2 diff models#4356
rolandtannous merged 6 commits into
mainfrom
feature/compare-two-diff-models

Conversation

@Manan17

@Manan17 Manan17 commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

Added generalized model comparison that lets users compare any two models side-by-side, while preserving the existing fast LoRA compare (simultaneous, adapter toggle) as an auto-detected fast path. When a LoRA is loaded, compare works exactly as before; otherwise, a new general compare mode renders per-side model pickers and orchestrates sequential load → generate → load → generate with progress toasts, an "already loaded" backend optimization to skip redundant reloads, immediate user message display on both sides, and a locked send button until both sides complete. Supports GGUF, LoRA, and standard models.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the model comparison capabilities by introducing a flexible, generalized system. Users can now select and compare any two models, including GGUF, LoRA, and standard models, side-by-side. The system intelligently detects if a LoRA is loaded, defaulting to the existing fast comparison method, while providing a new, robust sequential loading and generation process for general comparisons, complete with user feedback and optimizations. This broadens the utility of the comparison feature beyond just LoRA models, making it a more versatile tool for model evaluation.

Highlights

  • Generalized Model Comparison: Introduced a new feature allowing users to compare any two models side-by-side, expanding beyond the previous LoRA-only comparison.
  • Optimized Model Loading: Implemented an 'already loaded' check in the backend to prevent redundant model reloads during comparison, improving efficiency.
  • Enhanced User Experience: Added progress toasts and immediate user message display for the new general compare mode, providing clear feedback during sequential model loading and generation.
  • Flexible Model Support: The comparison now supports GGUF, LoRA, and standard models, with the existing fast LoRA compare path automatically detected and preserved.
Changelog
  • studio/backend/routes/inference.py
    • Added an optimization to skip model reloading if the requested model (GGUF or Unsloth) is already active in the backend.
  • studio/frontend/src/features/chat/api/chat-adapter.ts
    • Updated resolveUseAdapter to disable the adapter toggle for the new model1 and model2 comparison threads.
  • studio/frontend/src/features/chat/chat-page.tsx
    • Defined a new CompareModelSelection type for model comparison.
    • Implemented useIsLoraCompare to determine if the current comparison is a LoRA-specific one.
    • Refactored the CompareContent component to dynamically render either LoraCompareContent (for LoRA comparisons) or GeneralCompareContent (for generalized comparisons).
    • Introduced GeneralCompareContent to manage the UI and logic for comparing any two models, including model selectors and state management for two distinct models.
    • Modified the canCompare logic to enable comparison for any loaded checkpoint, not just LoRAs.
    • Passed model lists (models, loraModels) to the CompareContent component.
  • studio/frontend/src/features/chat/shared-composer.tsx
    • Imported toast for user notifications and loadModel for dynamic model loading.
    • Extended the CompareHandle interface with new methods (appendMessage, startRun, waitForRunEnd) to support sequential generation.
    • Implemented these new CompareHandle methods in RegisterCompareHandle.
    • Updated SharedComposer to accept model1 and model2 props for generalized comparison.
    • Implemented the core logic for generalized comparison within the send function, orchestrating sequential model loading, message display, generation, and progress toasts.
    • Adjusted the canSend and stop button logic to reflect the new comparing state.
  • studio/frontend/src/features/chat/thread-sidebar.tsx
    • Adjusted the thread grouping logic to correctly categorize single threads that are not part of a comparison pair.
  • studio/frontend/src/features/chat/tour/steps.tsx
    • Updated the description for the "Compare mode" tour step to reflect the new generalized comparison capabilities.
  • studio/frontend/src/features/chat/types.ts
    • Expanded the ModelType enum to include model1 and model2 for generalized comparison threads.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Manan17 Manan17 changed the title compare for 2 diff models [Feature] compare for 2 diff models Mar 17, 2026

@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 a generalized model comparison feature, allowing side-by-side comparison of any two models, which is a significant enhancement. The implementation correctly preserves the existing LoRA fast-path compare and adds a new sequential load-and-generate flow for the general case. The backend is optimized to avoid redundant model reloads, and the frontend provides good user feedback with progress toasts. My review includes a few suggestions for improving code clarity and robustness, such as removing an unused variable, refining exception handling, and simplifying a redundant expression.

Comment thread studio/backend/routes/inference.py
Comment thread studio/backend/routes/inference.py
Comment thread studio/frontend/src/features/chat/shared-composer.tsx Outdated
@rolandtannous

Copy link
Copy Markdown

great work!

@rolandtannous rolandtannous merged commit 93ab09d into main Mar 17, 2026
5 checks passed
@rolandtannous rolandtannous deleted the feature/compare-two-diff-models branch March 17, 2026 18:58
shibizhao pushed a commit to shibizhao/unsloth-npu that referenced this pull request Apr 7, 2026
* compare for 2 diff models

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* resolving gemini comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(studio): refine model-load toast stop action and compare selector sizing (unslothai#4369)

Co-authored-by: imagineer99 <samleejackson0@gmail.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: imagineer99 <samleejackson0@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants