Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -626,7 +626,7 @@ with gr.Blocks() as demo:
|
|
| 626 |
gr.Markdown("# 🧰Training-Free CPU-run Model Creation Toolkit")
|
| 627 |
|
| 628 |
with gr.Tabs():
|
| 629 |
-
# --- TAB 1
|
| 630 |
with gr.Tab("Merge to Base Model + Reshard Output"):
|
| 631 |
t1_token = gr.Textbox(label="Token", type="password")
|
| 632 |
t1_base = gr.Textbox(label="Base Repo", value="name/repo")
|
|
@@ -639,18 +639,22 @@ with gr.Blocks() as demo:
|
|
| 639 |
t1_out = gr.Textbox(label="Output Repo")
|
| 640 |
t1_struct = gr.Textbox(label="Extras Source (copies configs/components/etc)", value="name/repo")
|
| 641 |
t1_priv = gr.Checkbox(label="Private", value=True)
|
| 642 |
-
gr.Button("Merge")
|
|
|
|
|
|
|
| 643 |
|
| 644 |
-
# --- TAB 2
|
| 645 |
with gr.Tab("Extract Adapter"):
|
| 646 |
t2_token = gr.Textbox(label="Token", type="password")
|
| 647 |
t2_org = gr.Textbox(label="Original Model")
|
| 648 |
t2_tun = gr.Textbox(label="Tuned or Homologous Model")
|
| 649 |
t2_rank = gr.Number(label="Extract At Rank", value=32, minimum=1, maximum=1024, step=1)
|
| 650 |
t2_out = gr.Textbox(label="Output Repo")
|
| 651 |
-
gr.Button("Extract")
|
|
|
|
|
|
|
| 652 |
|
| 653 |
-
# --- TAB 3
|
| 654 |
with gr.Tab("Merge Adapters"):
|
| 655 |
gr.Markdown("### Batch Adapter Merging")
|
| 656 |
t3_token = gr.Textbox(label="Token", type="password")
|
|
@@ -664,9 +668,11 @@ with gr.Blocks() as demo:
|
|
| 664 |
t3_sigma = gr.Slider(label="Sigma Rel – for linear/post-hoc EMA", value=0.21, minimum=0.01, maximum=1.00)
|
| 665 |
t3_out = gr.Textbox(label="Output Repo")
|
| 666 |
t3_priv = gr.Checkbox(label="Private Output", value=True)
|
| 667 |
-
gr.Button("Merge")
|
|
|
|
|
|
|
| 668 |
|
| 669 |
-
# --- TAB 4
|
| 670 |
with gr.Tab("Resize Adapter"):
|
| 671 |
t4_token = gr.Textbox(label="Token", type="password")
|
| 672 |
t4_in = gr.Textbox(label="LoRA")
|
|
@@ -676,7 +682,9 @@ with gr.Blocks() as demo:
|
|
| 676 |
t4_param = gr.Number(label="Dynamic Param", value=0.9)
|
| 677 |
gr.Markdown("### 📉 Dynamic Resizing Guide\nThese methods intelligently determine the best rank per layer.\n- **sv_ratio (Relative Strength):** Keeps features that are at least `1/Param` as strong as the main feature. **Param must be >= 2**.\n- **sv_fro (Visual Information Density):** Preserves `Param%` of total information content. **Param between 0.0 and 1.0**.\n- **sv_cumulative (Cumulative Sum):** Preserves weights that sum up to `Param%` of total strength. **Param between 0.0 and 1.0**.\n- **⚠️ Safety Ceiling:** The **'To Rank'** slider acts as a hard limit.")
|
| 678 |
t4_out = gr.Textbox(label="Output")
|
| 679 |
-
gr.Button("Resize")
|
|
|
|
|
|
|
| 680 |
|
| 681 |
# --- TAB 5 ---
|
| 682 |
with gr.Tab("Amphinterpolative"):
|
|
@@ -699,7 +707,9 @@ with gr.Blocks() as demo:
|
|
| 699 |
with gr.Accordion("More", open=False):
|
| 700 |
m3, w3 = gr.Textbox(label="Model 3"), gr.Textbox(label="Weight 3", value="1.0"); m4, w4 = gr.Textbox(label="Model 4"), gr.Textbox(label="Weight 4", value="1.0"); m5, w5 = gr.Textbox(label="Model 5"), gr.Textbox(label="Weight 5", value="1.0")
|
| 701 |
t5_out = gr.Textbox(label="Output Repo"); t5_priv = gr.Checkbox(label="Private", value=True)
|
| 702 |
-
gr.Button("Execute")
|
|
|
|
|
|
|
| 703 |
|
| 704 |
# --- TAB 6 ---
|
| 705 |
with gr.Tab("Stir/Tie Bases"):
|
|
@@ -714,12 +724,13 @@ with gr.Blocks() as demo:
|
|
| 714 |
m1_6, w1_6 = gr.Textbox(label="Model 1"), gr.Textbox(label="Weight 1", value="1.0"); d1_6, g1_6, e1_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 715 |
with gr.Accordion("More", open=False):
|
| 716 |
m2_6, w2_6 = gr.Textbox(label="Model 2"), gr.Textbox(label="Weight 2", value="1.0"); d2_6, g2_6, e2_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 717 |
-
#
|
| 718 |
m3_6, w3_6 = gr.Textbox(label="Model 3"), gr.Textbox(label="Weight 3", value="1.0"); d3_6, g3_6, e3_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 719 |
m4_6, w4_6 = gr.Textbox(label="Model 4"), gr.Textbox(label="Weight 4", value="1.0"); d4_6, g4_6, e4_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 720 |
t6_out = gr.Textbox(label="Output Repo"); t6_priv = gr.Checkbox(label="Private", value=True)
|
| 721 |
-
|
| 722 |
-
|
|
|
|
| 723 |
|
| 724 |
# --- TAB 7 ---
|
| 725 |
with gr.Tab("Specious"):
|
|
@@ -736,7 +747,9 @@ with gr.Blocks() as demo:
|
|
| 736 |
with gr.Accordion("More", open=False):
|
| 737 |
m3_7, w3_7 = gr.Textbox(label="Model 3"), gr.Textbox(label="Weight 3", value="1.0"); m4_7, w4_7 = gr.Textbox(label="Model 4"), gr.Textbox(label="Weight 4", value="1.0"); m5_7, w5_7 = gr.Textbox(label="Model 5"), gr.Textbox(label="Weight 5", value="1.0")
|
| 738 |
t7_out = gr.Textbox(label="Output Repo"); t7_priv = gr.Checkbox(label="Private", value=True)
|
| 739 |
-
gr.Button("Execute")
|
|
|
|
|
|
|
| 740 |
|
| 741 |
# --- TAB 8 (MoEr) ---
|
| 742 |
with gr.Tab("MoEr"):
|
|
@@ -746,7 +759,9 @@ with gr.Blocks() as demo:
|
|
| 746 |
t8_shard = gr.Slider(label="Max Shard Size (GB)", value=5.0, minimum=1.0, maximum=20.0); t8_prec = gr.Dropdown(["float16", "bfloat16", "float32"], value="bfloat16", label="Output Precision"); t8_tok = gr.Dropdown(["base", "union", "model:path"], value="base", label="Tokenizer Source"); t8_chat = gr.Textbox(label="Chat Template", placeholder="auto")
|
| 747 |
t8_base = gr.Textbox(label="Base Model"); t8_experts = gr.TextArea(label="Experts List"); t8_gate = gr.Dropdown(["cheap_embed", "random", "hidden"], value="cheap_embed", label="Gate Mode"); t8_dtype = gr.Dropdown(["float16", "bfloat16"], value="bfloat16", label="Internal Dtype")
|
| 748 |
t8_out = gr.Textbox(label="Output Repo"); t8_priv = gr.Checkbox(label="Private", value=True)
|
| 749 |
-
gr.Button("Build MoE")
|
|
|
|
|
|
|
| 750 |
|
| 751 |
# --- TAB 9 (Rawer) ---
|
| 752 |
with gr.Tab("Rawer"):
|
|
@@ -756,7 +771,9 @@ with gr.Blocks() as demo:
|
|
| 756 |
t9_shard = gr.Slider(label="Max Shard Size (GB)", value=5.0, minimum=1.0, maximum=20.0); t9_prec = gr.Dropdown(["float16", "bfloat16", "float32"], value="bfloat16", label="Output Precision"); t9_tok = gr.Dropdown(["base", "union", "model:path"], value="base", label="Tokenizer Source"); t9_chat = gr.Textbox(label="Chat Template", placeholder="auto")
|
| 757 |
t9_method = gr.Dropdown(["linear", "passthrough"], value="linear", label="Method"); t9_dtype = gr.Dropdown(["float32", "float16", "bfloat16"], value="float32", label="Config Dtype")
|
| 758 |
t9_out = gr.Textbox(label="Output Repo"); t9_priv = gr.Checkbox(label="Private", value=True)
|
| 759 |
-
gr.Button("Merge Raw")
|
|
|
|
|
|
|
| 760 |
|
| 761 |
# --- TAB 10 ---
|
| 762 |
with gr.Tab("Mario,DARE!"):
|
|
@@ -766,7 +783,9 @@ with gr.Blocks() as demo:
|
|
| 766 |
with gr.Row():
|
| 767 |
t10_ratio = gr.Slider(0, 5, 1.0, label="Ratio"); t10_mask = gr.Slider(0, 0.99, 0.5, label="Mask Rate")
|
| 768 |
t10_out = gr.Textbox(label="Output Repo"); t10_priv = gr.Checkbox(label="Private", value=True)
|
| 769 |
-
gr.Button("Run")
|
|
|
|
|
|
|
| 770 |
|
| 771 |
if __name__ == "__main__":
|
| 772 |
demo.queue().launch(css=css, ssr_mode=False)
|
|
|
|
| 626 |
gr.Markdown("# 🧰Training-Free CPU-run Model Creation Toolkit")
|
| 627 |
|
| 628 |
with gr.Tabs():
|
| 629 |
+
# --- TAB 1 ---
|
| 630 |
with gr.Tab("Merge to Base Model + Reshard Output"):
|
| 631 |
t1_token = gr.Textbox(label="Token", type="password")
|
| 632 |
t1_base = gr.Textbox(label="Base Repo", value="name/repo")
|
|
|
|
| 639 |
t1_out = gr.Textbox(label="Output Repo")
|
| 640 |
t1_struct = gr.Textbox(label="Extras Source (copies configs/components/etc)", value="name/repo")
|
| 641 |
t1_priv = gr.Checkbox(label="Private", value=True)
|
| 642 |
+
t1_btn = gr.Button("Merge")
|
| 643 |
+
t1_res = gr.Textbox(label="Result")
|
| 644 |
+
t1_btn.click(task_merge_legacy, [t1_token, t1_base, t1_sub, t1_lora, t1_scale, t1_prec, t1_shard, t1_out, t1_struct, t1_priv], t1_res)
|
| 645 |
|
| 646 |
+
# --- TAB 2 ---
|
| 647 |
with gr.Tab("Extract Adapter"):
|
| 648 |
t2_token = gr.Textbox(label="Token", type="password")
|
| 649 |
t2_org = gr.Textbox(label="Original Model")
|
| 650 |
t2_tun = gr.Textbox(label="Tuned or Homologous Model")
|
| 651 |
t2_rank = gr.Number(label="Extract At Rank", value=32, minimum=1, maximum=1024, step=1)
|
| 652 |
t2_out = gr.Textbox(label="Output Repo")
|
| 653 |
+
t2_btn = gr.Button("Extract")
|
| 654 |
+
t2_res = gr.Textbox(label="Result")
|
| 655 |
+
t2_btn.click(task_extract, [t2_token, t2_org, t2_tun, t2_rank, t2_out], t2_res)
|
| 656 |
|
| 657 |
+
# --- TAB 3 ---
|
| 658 |
with gr.Tab("Merge Adapters"):
|
| 659 |
gr.Markdown("### Batch Adapter Merging")
|
| 660 |
t3_token = gr.Textbox(label="Token", type="password")
|
|
|
|
| 668 |
t3_sigma = gr.Slider(label="Sigma Rel – for linear/post-hoc EMA", value=0.21, minimum=0.01, maximum=1.00)
|
| 669 |
t3_out = gr.Textbox(label="Output Repo")
|
| 670 |
t3_priv = gr.Checkbox(label="Private Output", value=True)
|
| 671 |
+
t3_btn = gr.Button("Merge")
|
| 672 |
+
t3_res = gr.Textbox(label="Result")
|
| 673 |
+
t3_btn.click(task_merge_adapters_advanced, [t3_token, t3_urls, t3_method, t3_weights, t3_beta, t3_sigma, t3_rank, t3_out, t3_priv], t3_res)
|
| 674 |
|
| 675 |
+
# --- TAB 4 ---
|
| 676 |
with gr.Tab("Resize Adapter"):
|
| 677 |
t4_token = gr.Textbox(label="Token", type="password")
|
| 678 |
t4_in = gr.Textbox(label="LoRA")
|
|
|
|
| 682 |
t4_param = gr.Number(label="Dynamic Param", value=0.9)
|
| 683 |
gr.Markdown("### 📉 Dynamic Resizing Guide\nThese methods intelligently determine the best rank per layer.\n- **sv_ratio (Relative Strength):** Keeps features that are at least `1/Param` as strong as the main feature. **Param must be >= 2**.\n- **sv_fro (Visual Information Density):** Preserves `Param%` of total information content. **Param between 0.0 and 1.0**.\n- **sv_cumulative (Cumulative Sum):** Preserves weights that sum up to `Param%` of total strength. **Param between 0.0 and 1.0**.\n- **⚠️ Safety Ceiling:** The **'To Rank'** slider acts as a hard limit.")
|
| 684 |
t4_out = gr.Textbox(label="Output")
|
| 685 |
+
t4_btn = gr.Button("Resize")
|
| 686 |
+
t4_res = gr.Textbox(label="Result")
|
| 687 |
+
t4_btn.click(task_resize, [t4_token, t4_in, t4_rank, t4_method, t4_param, t4_out], t4_res)
|
| 688 |
|
| 689 |
# --- TAB 5 ---
|
| 690 |
with gr.Tab("Amphinterpolative"):
|
|
|
|
| 707 |
with gr.Accordion("More", open=False):
|
| 708 |
m3, w3 = gr.Textbox(label="Model 3"), gr.Textbox(label="Weight 3", value="1.0"); m4, w4 = gr.Textbox(label="Model 4"), gr.Textbox(label="Weight 4", value="1.0"); m5, w5 = gr.Textbox(label="Model 5"), gr.Textbox(label="Weight 5", value="1.0")
|
| 709 |
t5_out = gr.Textbox(label="Output Repo"); t5_priv = gr.Checkbox(label="Private", value=True)
|
| 710 |
+
t5_btn = gr.Button("Execute")
|
| 711 |
+
t5_logs = LogsView()
|
| 712 |
+
t5_btn.click(wrapper_amphinterpolative, [t5_token, t5_method, t5_base, t5_t, t5_norm, t5_i8, t5_flat, t5_row, t5_eps, t5_iter, t5_tol, m1, w1, m2, w2, m3, w3, m4, w4, m5, w5, t5_out, t5_priv, t5_shard, t5_prec, t5_tok, t5_chat], t5_logs)
|
| 713 |
|
| 714 |
# --- TAB 6 ---
|
| 715 |
with gr.Tab("Stir/Tie Bases"):
|
|
|
|
| 724 |
m1_6, w1_6 = gr.Textbox(label="Model 1"), gr.Textbox(label="Weight 1", value="1.0"); d1_6, g1_6, e1_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 725 |
with gr.Accordion("More", open=False):
|
| 726 |
m2_6, w2_6 = gr.Textbox(label="Model 2"), gr.Textbox(label="Weight 2", value="1.0"); d2_6, g2_6, e2_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 727 |
+
# Corrected Argument List to match wrapper_stirtie signature
|
| 728 |
m3_6, w3_6 = gr.Textbox(label="Model 3"), gr.Textbox(label="Weight 3", value="1.0"); d3_6, g3_6, e3_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 729 |
m4_6, w4_6 = gr.Textbox(label="Model 4"), gr.Textbox(label="Weight 4", value="1.0"); d4_6, g4_6, e4_6 = gr.Textbox(label="Density", value="1.0"), gr.Number(label="Gamma", value=0.01), gr.Number(label="Epsilon", value=0.15)
|
| 730 |
t6_out = gr.Textbox(label="Output Repo"); t6_priv = gr.Checkbox(label="Private", value=True)
|
| 731 |
+
t6_btn = gr.Button("Execute")
|
| 732 |
+
t6_logs = LogsView()
|
| 733 |
+
t6_btn.click(wrapper_stirtie, [t6_token, t6_method, t6_base, t6_norm, t6_i8, t6_lamb, t6_resc, t6_topk, m1_6, w1_6, d1_6, g1_6, e1_6, m2_6, w2_6, d2_6, g2_6, e2_6, m3_6, w3_6, d3_6, g3_6, e3_6, m4_6, w4_6, d4_6, g4_6, e4_6, t6_out, t6_priv, t6_shard, t6_prec, t6_tok, t6_chat], t6_logs)
|
| 734 |
|
| 735 |
# --- TAB 7 ---
|
| 736 |
with gr.Tab("Specious"):
|
|
|
|
| 747 |
with gr.Accordion("More", open=False):
|
| 748 |
m3_7, w3_7 = gr.Textbox(label="Model 3"), gr.Textbox(label="Weight 3", value="1.0"); m4_7, w4_7 = gr.Textbox(label="Model 4"), gr.Textbox(label="Weight 4", value="1.0"); m5_7, w5_7 = gr.Textbox(label="Model 5"), gr.Textbox(label="Weight 5", value="1.0")
|
| 749 |
t7_out = gr.Textbox(label="Output Repo"); t7_priv = gr.Checkbox(label="Private", value=True)
|
| 750 |
+
t7_btn = gr.Button("Execute")
|
| 751 |
+
t7_logs = LogsView()
|
| 752 |
+
t7_btn.click(wrapper_specious, [t7_token, t7_method, t7_base, t7_norm, t7_i8, t7_t, t7_filt_w, m1_7, w1_7, f1_7, m2_7, w2_7, m3_7, w3_7, m4_7, w4_7, m5_7, w5_7, t7_out, t7_priv, t7_shard, t7_prec, t7_tok, t7_chat], t7_logs)
|
| 753 |
|
| 754 |
# --- TAB 8 (MoEr) ---
|
| 755 |
with gr.Tab("MoEr"):
|
|
|
|
| 759 |
t8_shard = gr.Slider(label="Max Shard Size (GB)", value=5.0, minimum=1.0, maximum=20.0); t8_prec = gr.Dropdown(["float16", "bfloat16", "float32"], value="bfloat16", label="Output Precision"); t8_tok = gr.Dropdown(["base", "union", "model:path"], value="base", label="Tokenizer Source"); t8_chat = gr.Textbox(label="Chat Template", placeholder="auto")
|
| 760 |
t8_base = gr.Textbox(label="Base Model"); t8_experts = gr.TextArea(label="Experts List"); t8_gate = gr.Dropdown(["cheap_embed", "random", "hidden"], value="cheap_embed", label="Gate Mode"); t8_dtype = gr.Dropdown(["float16", "bfloat16"], value="bfloat16", label="Internal Dtype")
|
| 761 |
t8_out = gr.Textbox(label="Output Repo"); t8_priv = gr.Checkbox(label="Private", value=True)
|
| 762 |
+
t8_btn = gr.Button("Build MoE")
|
| 763 |
+
t8_logs = LogsView()
|
| 764 |
+
t8_btn.click(wrapper_moer, [t8_token, t8_base, t8_experts, t8_gate, t8_dtype, t8_out, t8_priv, t8_shard, t8_prec, t8_tok, t8_chat], t8_logs)
|
| 765 |
|
| 766 |
# --- TAB 9 (Rawer) ---
|
| 767 |
with gr.Tab("Rawer"):
|
|
|
|
| 771 |
t9_shard = gr.Slider(label="Max Shard Size (GB)", value=5.0, minimum=1.0, maximum=20.0); t9_prec = gr.Dropdown(["float16", "bfloat16", "float32"], value="bfloat16", label="Output Precision"); t9_tok = gr.Dropdown(["base", "union", "model:path"], value="base", label="Tokenizer Source"); t9_chat = gr.Textbox(label="Chat Template", placeholder="auto")
|
| 772 |
t9_method = gr.Dropdown(["linear", "passthrough"], value="linear", label="Method"); t9_dtype = gr.Dropdown(["float32", "float16", "bfloat16"], value="float32", label="Config Dtype")
|
| 773 |
t9_out = gr.Textbox(label="Output Repo"); t9_priv = gr.Checkbox(label="Private", value=True)
|
| 774 |
+
t9_btn = gr.Button("Merge Raw")
|
| 775 |
+
t9_logs = LogsView()
|
| 776 |
+
t9_btn.click(wrapper_rawer, [t9_token, t9_models, t9_method, t9_dtype, t9_out, t9_priv, t9_shard, t9_prec, t9_tok, t9_chat], t9_logs)
|
| 777 |
|
| 778 |
# --- TAB 10 ---
|
| 779 |
with gr.Tab("Mario,DARE!"):
|
|
|
|
| 783 |
with gr.Row():
|
| 784 |
t10_ratio = gr.Slider(0, 5, 1.0, label="Ratio"); t10_mask = gr.Slider(0, 0.99, 0.5, label="Mask Rate")
|
| 785 |
t10_out = gr.Textbox(label="Output Repo"); t10_priv = gr.Checkbox(label="Private", value=True)
|
| 786 |
+
t10_btn = gr.Button("Run")
|
| 787 |
+
t10_res = gr.Textbox(label="Result")
|
| 788 |
+
t10_btn.click(task_dare_custom, [t10_token, t10_base, t10_ft, t10_ratio, t10_mask, t10_out, t10_priv], t10_res)
|
| 789 |
|
| 790 |
if __name__ == "__main__":
|
| 791 |
demo.queue().launch(css=css, ssr_mode=False)
|