rahul7star commited on
Commit
f007bf3
Β·
verified Β·
1 Parent(s): 5307759

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -166
app.py CHANGED
@@ -1778,127 +1778,21 @@ def worker_mode_a(
1778
  JOB_STATUS["running"] = False
1779
 
1780
  def worker_mode_b(
1781
- gguf_repo,
1782
- gguf_file,
1783
- imatrix_file,
1784
- profile,
1785
- target_repo,
1786
  ):
1787
 
1788
- JOB_STATUS["running"] = True
1789
-
1790
- try:
1791
-
1792
- LOG_BUFFER.clear()
1793
-
1794
- log("=" * 70)
1795
- log("πŸš€ MODE B START")
1796
- log("=" * 70)
1797
-
1798
-
1799
- if not gguf_repo or not gguf_file:
1800
-
1801
- raise RuntimeError(
1802
- "❌ Missing GGUF repository or BF16 file"
1803
- )
1804
-
1805
-
1806
- # -----------------------------
1807
- # BF16 CACHE
1808
- # -----------------------------
1809
-
1810
- # bf16 = get_or_download_bf16(
1811
- # gguf_repo,
1812
- # gguf_file
1813
- # )
1814
- bf16 = get_bucket_bf16( "Laguna-S-2.1-GGUF")
1815
-
1816
-
1817
-
1818
-
1819
- log(
1820
- f"πŸ“¦ BF16 SOURCE:\n{bf16}"
1821
- )
1822
-
1823
-
1824
-
1825
- # -----------------------------
1826
- # IMATRIX
1827
- # -----------------------------
1828
-
1829
- imatrix = None
1830
-
1831
-
1832
- if imatrix_file:
1833
-
1834
- imatrix = download_imatrix(
1835
- gguf_repo,
1836
- imatrix_file
1837
- )
1838
-
1839
- log(
1840
- f"πŸ“Š IMATRIX:\n{imatrix}"
1841
- )
1842
-
1843
-
1844
-
1845
- # -----------------------------
1846
- # MODE B QUANT ONLY
1847
- # -----------------------------
1848
-
1849
- gguf = quantize_mode_b(
1850
- bf16,
1851
- profile,
1852
- imatrix
1853
- )
1854
-
1855
-
1856
- size = (
1857
- os.path.getsize(gguf)
1858
- /
1859
- (1024 ** 3)
1860
- )
1861
-
1862
-
1863
- log(
1864
- f"πŸ“¦ OUTPUT SIZE {size:.2f} GB"
1865
- )
1866
-
1867
-
1868
-
1869
- # -----------------------------
1870
- # UPLOAD
1871
- # -----------------------------
1872
-
1873
- upload_output(
1874
- gguf,
1875
- None,
1876
- target_repo
1877
- )
1878
-
1879
-
1880
- log("=" * 70)
1881
- log("πŸŽ‰ MODE B COMPLETE")
1882
- log("=" * 70)
1883
-
1884
-
1885
-
1886
- except Exception as e:
1887
-
1888
- import traceback
1889
-
1890
- log(
1891
- f"❌ MODE B ERROR: {e}"
1892
- )
1893
-
1894
- log(
1895
- traceback.format_exc()
1896
- )
1897
-
1898
 
1899
- finally:
1900
-
1901
- JOB_STATUS["running"] = False
 
 
 
1902
  def pipeline(
1903
  mode,
1904
  source_repo,
@@ -1970,12 +1864,13 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
1970
  ## Mode A β€” HuggingFace Model
1971
  `HF Model β†’ F16 GGUF β†’ APEX β†’ Final GGUF`
1972
 
1973
- ## Mode B β€” Existing BF16 GGUF
1974
- `BF16 GGUF β†’ Bucket Cache β†’ APEX β†’ Final GGUF`
1975
 
1976
  βœ… Separate pipelines
 
 
1977
  βœ… Memory efficient
1978
- βœ… Bucket cache support
1979
  βœ… APEX quantization
1980
  βœ… llama.cpp fallback
1981
  """)
@@ -1988,7 +1883,7 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
1988
  mode = gr.Radio(
1989
  choices=[
1990
  "Mode A - HF Model",
1991
- "Mode B - Existing BF16 GGUF"
1992
  ],
1993
  value="Mode A - HF Model",
1994
  label="Pipeline Mode"
@@ -2021,30 +1916,22 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
2021
 
2022
  with gr.Group(
2023
  visible=False
2024
- ) as gguf_group:
2025
 
2026
  gr.Markdown(
2027
- "## πŸ“¦ Mode B: Existing BF16 GGUF"
2028
- )
2029
-
2030
-
2031
- gguf_repo = gr.Textbox(
2032
- label="GGUF Repository"
2033
  )
2034
 
2035
 
2036
- gguf_file = gr.Dropdown(
2037
- label="BF16 GGUF File",
2038
- choices=[],
2039
- interactive=True
2040
  )
2041
 
2042
 
2043
- imatrix_file = gr.Dropdown(
2044
- label="IMATRIX (Optional)",
2045
- choices=[],
2046
- allow_custom_value=True,
2047
- interactive=True
2048
  )
2049
 
2050
 
@@ -2067,9 +1954,9 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
2067
  )
2068
 
2069
 
2070
- target_repo = gr.Textbox(
2071
- label="Output HuggingFace Repository",
2072
- value="rahul7star/gemma-gguf"
2073
  )
2074
 
2075
 
@@ -2115,13 +2002,10 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
2115
  )
2116
  )
2117
 
2118
-
2119
  return (
2120
-
2121
  gr.update(
2122
  visible=False
2123
  ),
2124
-
2125
  gr.update(
2126
  visible=True
2127
  )
@@ -2133,22 +2017,7 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
2133
  inputs=mode,
2134
  outputs=[
2135
  hf_group,
2136
- gguf_group
2137
- ]
2138
- )
2139
-
2140
-
2141
-
2142
- # ==================================================
2143
- # MODE B REPO SCAN
2144
- # ==================================================
2145
-
2146
- gguf_repo.change(
2147
- load_repo_files,
2148
- inputs=gguf_repo,
2149
- outputs=[
2150
- gguf_file,
2151
- imatrix_file
2152
  ]
2153
  )
2154
 
@@ -2163,11 +2032,10 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
2163
  inputs=[
2164
  mode,
2165
  source_repo,
2166
- gguf_repo,
2167
- gguf_file,
2168
- imatrix_file,
2169
  profile,
2170
- target_repo
2171
  ],
2172
  outputs=status
2173
  )
@@ -2188,8 +2056,6 @@ with gr.Blocks(title="APEX GGUF Factory") as demo:
2188
  outputs=logs
2189
  )
2190
 
2191
-
2192
-
2193
  # ==================================================
2194
  # LAUNCH
2195
  # ==================================================
 
1778
  JOB_STATUS["running"] = False
1779
 
1780
  def worker_mode_b(
1781
+ bf16_path,
1782
+ imatrix_path,
1783
+ output_path,
1784
+ quant_type
 
1785
  ):
1786
 
1787
+ print("BF16:", bf16_path)
1788
+ print("IMatrix:", imatrix_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1789
 
1790
+ run_apex_quant(
1791
+ input_path=bf16_path,
1792
+ imatrix=imatrix_path,
1793
+ output_path=output_path,
1794
+ quant=quant_type
1795
+ )
1796
  def pipeline(
1797
  mode,
1798
  source_repo,
 
1864
  ## Mode A β€” HuggingFace Model
1865
  `HF Model β†’ F16 GGUF β†’ APEX β†’ Final GGUF`
1866
 
1867
+ ## Mode B β€” Bucket BF16 GGUF
1868
+ `Bucket BF16 GGUF β†’ APEX β†’ Final GGUF`
1869
 
1870
  βœ… Separate pipelines
1871
+ βœ… No downloads
1872
+ βœ… Direct bucket processing
1873
  βœ… Memory efficient
 
1874
  βœ… APEX quantization
1875
  βœ… llama.cpp fallback
1876
  """)
 
1883
  mode = gr.Radio(
1884
  choices=[
1885
  "Mode A - HF Model",
1886
+ "Mode B - Bucket BF16"
1887
  ],
1888
  value="Mode A - HF Model",
1889
  label="Pipeline Mode"
 
1916
 
1917
  with gr.Group(
1918
  visible=False
1919
+ ) as bucket_group:
1920
 
1921
  gr.Markdown(
1922
+ "## πŸ“¦ Mode B: Bucket BF16 GGUF"
 
 
 
 
 
1923
  )
1924
 
1925
 
1926
+ bf16_path = gr.Textbox(
1927
+ label="BF16 GGUF Bucket Path",
1928
+ placeholder="/bucket/models/.../BF16"
 
1929
  )
1930
 
1931
 
1932
+ imatrix_path = gr.Textbox(
1933
+ label="I-Matrix Bucket Path (Optional)",
1934
+ placeholder="/bucket/models/.../imatrix"
 
 
1935
  )
1936
 
1937
 
 
1954
  )
1955
 
1956
 
1957
+ output_path = gr.Textbox(
1958
+ label="Output Bucket Path",
1959
+ value="/bucket/output"
1960
  )
1961
 
1962
 
 
2002
  )
2003
  )
2004
 
 
2005
  return (
 
2006
  gr.update(
2007
  visible=False
2008
  ),
 
2009
  gr.update(
2010
  visible=True
2011
  )
 
2017
  inputs=mode,
2018
  outputs=[
2019
  hf_group,
2020
+ bucket_group
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2021
  ]
2022
  )
2023
 
 
2032
  inputs=[
2033
  mode,
2034
  source_repo,
2035
+ bf16_path,
2036
+ imatrix_path,
 
2037
  profile,
2038
+ output_path
2039
  ],
2040
  outputs=status
2041
  )
 
2056
  outputs=logs
2057
  )
2058
 
 
 
2059
  # ==================================================
2060
  # LAUNCH
2061
  # ==================================================