Skip to content

feat: refactor save machinery#110

Merged
p-e-w merged 1 commit intop-e-w:masterfrom
anrp:anrp/saveallchoicenoall
Jan 20, 2026
Merged

feat: refactor save machinery#110
p-e-w merged 1 commit intop-e-w:masterfrom
anrp:anrp/saveallchoicenoall

Conversation

@anrp
Copy link
Contributor

@anrp anrp commented Jan 16, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @anrp, 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 enhances the model saving capabilities by introducing a configurable save_method setting and a new "save all" feature. It centralizes the model saving logic into a dedicated function, improving code organization and allowing users to specify their preferred saving strategy upfront or save multiple models efficiently.

Highlights

  • New SaveMethod Enum: Introduced a SaveMethod enum (ASK, ADAPTER, MODEL) in src/heretic/config.py to define how models can be saved.
  • Configurable Save Method: Added a save_method field to the Settings class in src/heretic/config.py, allowing users to pre-configure the default save behavior.
  • Automated Merge Strategy Selection: The obtain_merge_strategy function in src/heretic/main.py now respects the save_method setting, automatically returning 'adapter' or 'model' if configured, bypassing the interactive prompt.
  • Centralized Model Saving Logic: A new save_model function was created in src/heretic/main.py to encapsulate the logic for saving models, either as adapters or merged full models, and saving the tokenizer.
  • "Save All" Option: A new interactive option "Save all visible models" has been added to the objective_wrapper in src/heretic/main.py, enabling users to save multiple models in a batch.
  • Refactored Saving Calls: Existing model saving calls within objective_wrapper have been updated to utilize the new save_model function, improving code reusability and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

Copy link
Contributor

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

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 'save all' feature and refactors the model saving logic into a dedicated save_model function. The changes are generally good, centralizing the saving mechanism and adding useful functionality.

However, there are a few critical issues with how the new save_model function is called, which will lead to runtime errors due to incorrect arguments. I've pointed these out with suggestions for fixes. Additionally, there are a couple of minor issues related to code consistency and adherence to the repository's style guide regarding type annotations. Addressing these points will improve the robustness and maintainability of the code.

@anrp anrp force-pushed the anrp/saveallchoicenoall branch 5 times, most recently from 05a29ea to 661388e Compare January 16, 2026 13:37
@p-e-w
Copy link
Owner

p-e-w commented Jan 17, 2026

What problem is this PR intended to solve?

I don't think asking the user a single question is so much of a hassle that there needs to be a pre-made setting to skip it, and setting save_method to adapter or merge can lead to the user robbing themselves of the choice when they might want to make it.

While I can see that in very specific situations, the user might indeed want to save several (though not necessarily all) trials from the Pareto front, this is an absolutely massive footgun that can write Terabytes to the disk. The risk/benefit calculus doesn't work out here IMO. The Pareto front is usually on the order of 10 entries, and in those rare cases where it is desired, the user can manually save all of those in a matter of minutes.

@anrp
Copy link
Contributor Author

anrp commented Jan 17, 2026

I don't mind deleting the "save-all" capability here, but I would like to preserve the LoRA-for-anything, because it can be used with vllm to serve multiple heretic results with minimal overhead vs merged models all around. It's also something I wrote prior to #106 because prior to having something like that, once you exit all the data is lost, but if we have that PR then there's not much value.

@p-e-w
Copy link
Owner

p-e-w commented Jan 17, 2026

The option to save as LoRA makes sense, but I still don't like that being a setting, because I think the user should always make that choice in-context.

@anrp anrp force-pushed the anrp/saveallchoicenoall branch from 661388e to 5d57ea0 Compare January 17, 2026 16:50
@anrp anrp changed the title feat: Add a "save all" option, refactor save machinery feat: refactor save machinery Jan 17, 2026
@anrp
Copy link
Contributor Author

anrp commented Jan 17, 2026

Removed save all machinery. PTAL?

return merge_choice


def save_model(
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this a separate function? Seems a bit ad-hoc to rip all the context out into parameters. Where can this be reused?

The trial parameter appears to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly it's just the level of indentation, it's quite deep. Removed trial.

@anrp anrp force-pushed the anrp/saveallchoicenoall branch from 5d57ea0 to f565b9b Compare January 19, 2026 13:11
@p-e-w p-e-w merged commit c86f490 into p-e-w:master Jan 20, 2026
4 checks passed
@p-e-w
Copy link
Owner

p-e-w commented Jan 20, 2026

Merged, thanks!

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.

2 participants