Sd-mecha

Latest version: v0.0.29

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 4

0.1.0rc3

- add ema keys to sd1-ldm config
- add merge method `exchange_ema` that exchanges ema keys with non-ema keys
- add merge method `omit_component` that prunes all keys belonging to a specified model component

Many thanks to Saftle for supporting the development of the library!

0.1.0rc2

- store all yaml configs directly in the repo
- now merge methods can receive state dicts that are already loaded
- rename `merge_and_save` to `merge`. Now the function returns a state dict by default, and will save to a file if the `output` keyword parameter is passed
- move module `sd_mecha.merge_methods` to `sd_mecha.extensions.builtin.merge_methods`
- add new merge method `sd_mecha.pick_component(a, component)` that rejects all keys not in the specified component. For example, `pick_component(model, "diffuser")` will only keep the keys in the unet of SDXL
- rename `RecipeMerger` to `Defaults`. It is now a stand-alone utility class that simplifies merging multiple recipes in a row by specifying common values a single time
- fix some merge methods that rely on `torch.linalg` and that were not playing well with threads in some environments
- add a bunch of docstrings for public facing functions
- function `convert` now can also accept a recipe node as a second parameter, removing the need to have the input dicts explicitly loaded for config auto detection or to have the configs to be specified explicitly
- fix varargs, they were actually not working at all anymore
- fix `extensions.model_configs.serialize` not handling `extensions.model_configs.ModelComponent` correctly
- change default value of `clip_to_ab` of `add_difference` to `False` to prevent surprising behavior

0.1.0rc1

- new merge method API (`merge_method`, `Parameter(...)`, `Return(...)`)
- new model config API (get rid of blocks embedded in configs in favor of additional blocks configs + conversion)
- replace block-wise merging with key-wise merging
- it is now possible to implement all lycoris types (but be aware that only kohya lora is currently implemented)
- new merge method `sd_mecha.fallback(a, b)` (delegate keys that are missing in `a` to `b`)
- new merge method `sd_mecha.cast(a, *, device, dtype)` that replaces the old `device` and `dtype` kwargs that were automatically added
- unification of args and kwargs of merge methods: there is now no special meaning attributed to how a parameter is passed
- remove "hyper"s
- introduction of `param` merge space, which corresponds to the old notion of "hyper". (merge method parameters with a default value are automatically in `param` merge space)
- introduction of the `StateDict[...]` parameter type, which allows to load arbitrary keys from an input parameter for each output key to be merged (it also allows to not load a key if it is not needed (i.e. weighted_sum with alpha=1.0 doesn't need to load model A into memory at all))
- bump serialization format version (it is not backwards compatible with the old format version but can easily be converted)
- `None`, `Tensor`, `bool`, `int`, `float`, `str`, a `TypeVar` with constraints that are a subset of these types, and `StateDict[Tensor, bool, int, float, str or a TypeVar]` are all valid merge method parameter types now (and will also be serialized and deserialized properly)
- a cache mechanism is now built into each merge method and can be enabled or disabled at will
- automatic config conversion using `sd_mecha.convert`
- automatic model config detection (no need to specify "sdxl" in `sd_mecha.model` now)
- rename "sd1" model config to "sd1-ldm", and "sdxl" to "sdxl-sgm"
- many other things, see docs or hop in the [Discord](https://discord.com/invite/2EPaw6fxxm) for more info

Note: the yaml configs listed under here are necessary for the code to work. They are pre-included in the pypi release. To install from source using `pip install -e .`, they must be placed under `sd_mecha/extensions/builtin/model_configs`. This is a temporary measure, until configs are a part of a public web API that is under construction.

0.0.29

- forward sdxl v_pred and ztsnr keys, which used to be automatically discarded

0.0.27

- add SD 3.5 config

0.0.26

- allow to merge in delta space by passing `strict_weight_space=False` in `RecipeMerger.merge_and_save()`
- handle unexpected float types when expecting an integer in some merge methods
- replace the parameter `no_rescale` of the method `ties_sum_with_dropout` with `rescale` and use a differentiable implementation
- use `torch.Generator` instead of `torch.manual_seed`
- revert the use of `torch.svd_lowrank` in rotate when alignment is fractional, otherwise it results in nans during inference

Page 1 of 4

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.