Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local safetensors file #10

Closed
6DammK9 opened this issue Feb 5, 2024 · 1 comment
Closed

Support local safetensors file #10

6DammK9 opened this issue Feb 5, 2024 · 1 comment

Comments

@6DammK9
Copy link

6DammK9 commented Feb 5, 2024

I may add PR but I have no time to code.
As an A1111 / ComfyUI user, I find that it doesn't support local safetensors file out of the box.
Instead of pip install segmoe (I encountered dependency hell even I am using conda already), I suggest uninstall segmoe and then directly using the cloned files (put to ./segmoe which is same directory of a sample usage code python train.py) and start modifying the script.
But I attempted to load model with diffusers, and I got no idea how to do it.
Hope that there will be solution and let me not needed to rely on CivitAI models (or using a dummy http host to host the models)

For HTTP host, npm install -g http-server will save your day.

edit: wget is not present in Windows, install it first.
edit2: Got it working. Required Code changes. Mainly StableDiffusionXLPipeline.from_single_file and modify URL to in main.py.

API_MODEL_URL_CIVITAI = "https://civitai.com/api/download/models/"
API_MODEL_URL = "http://localhost:8080/models/"

Config file x17-AstolfoMoE_a3p6.yaml:

base_model: http://localhost:8080/models/x17-AstolfoMix-x13te0x14te1.safetensors
num_experts: 2
moe_layers: all
num_experts_per_tok: 1
experts:
  - source_model: http://localhost:8080/models/_x14-ponyDiffusionV6XL_v6.safetensors
    positive_prompt: "xxx"
    negative_prompt: "xxx"
  - source_model: http://localhost:8080/models/_x08-animagineXLV3_v30.safetensors
    positive_prompt: "xxx"
    negative_prompt: "xxx"

And finally python not_train.py:

from segmoe import SegMoEPipeline
import torch

# OOM with RTX 3090, need 48GB+ VRAM! 

pipeline = SegMoEPipeline("x17-AstolfoMoE_a3p6.yaml", device="cpu", torch_dtype=torch.float, variant="fp32")

pipeline.save_pretrained("segmoe_v0")

Finally spent 26 minutes and around 80GB of RAM to "train" on a i9-7960X CPU.
"eval" (Generate image) can use cuda, which is as fast as usual.

@Warlord-K
Copy link
Contributor

Added in Support, Thanks for the suggestion!

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

No branches or pull requests

2 participants