lvkaokao commited on
Commit
584126f
Β·
1 Parent(s): 3074bf3

fix: remove cache_git submodule, update format and submission logic

Browse files
.gitignore CHANGED
@@ -1,4 +1,6 @@
1
  __pycache__/
2
  **/__pycache__/
3
  cache_hf
4
- .gradio
 
 
 
1
  __pycache__/
2
  **/__pycache__/
3
  cache_hf
4
+ .gradio
5
+ cache_git
6
+
app.py CHANGED
@@ -265,7 +265,7 @@ def submit_model(model, revision, private, compute_dtype, model_size_input):
265
  giving the user real-time progress updates.
266
  """
267
  if not model or model.strip() == "":
268
- yield styled_error("Please enter a model name."); return
269
  model_params_manual, err = _parse_model_size_input(model_size_input)
270
  if err:
271
  yield err; return
@@ -282,7 +282,7 @@ def submit_quant(model, revision, private, quant_scheme, model_size_input):
282
  giving the user real-time progress updates.
283
  """
284
  if not model or model.strip() == "":
285
- yield styled_error("Please enter a model name."); return
286
  model_params_manual, err = _parse_model_size_input(model_size_input)
287
  if err:
288
  yield err; return
 
265
  giving the user real-time progress updates.
266
  """
267
  if not model or model.strip() == "":
268
+ styled_error("Please enter a model name.")
269
  model_params_manual, err = _parse_model_size_input(model_size_input)
270
  if err:
271
  yield err; return
 
282
  giving the user real-time progress updates.
283
  """
284
  if not model or model.strip() == "":
285
+ styled_error("Please enter a model name.")
286
  model_params_manual, err = _parse_model_size_input(model_size_input)
287
  if err:
288
  yield err; return
assets/org_icons/qwen.webp ADDED
src/display/formatting.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  def model_hyperlink(link, model_name):
2
  return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
3
 
@@ -14,33 +16,57 @@ def make_clickable_model(model_name, result_file=""):
14
  return model_hyperlink(link, model_name) + " " + model_hyperlink(details_link, "πŸ“‘")
15
 
16
  def styled_error(error):
17
- # Inject a JS alert so the message pops up, plus show inline as fallback
18
- safe = error.replace("'", "\\'").replace("\n", " ")
19
- return (
20
- f"<script>setTimeout(function(){{alert('❌ ' + '{safe}');}}, 50);</script>"
21
- f"<p style='color: red; font-size: 15px; text-align: center; margin-top: 8px;'>❌ {error}</p>"
22
- )
23
 
24
 
25
  def styled_warning(warn):
26
- return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
27
 
28
 
29
  def styled_message(message):
30
- return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
 
31
 
32
 
33
  def styled_progress(step: int, total: int, message: str) -> str:
34
  """Return a styled progress indicator (HTML)."""
35
  pct = int(step / total * 100) if total > 0 else 0
 
 
 
 
 
 
 
36
  return (
37
- f"<div style='text-align:center; padding:10px;'>"
38
- f"<p style='color: #2196F3; font-size: 16px; margin-bottom: 8px;'>⏳ {message}</p>"
39
- f"<div style='background:#e0e0e0; border-radius:8px; height:20px; width:80%; margin:0 auto;'>"
40
- f"<div style='background: linear-gradient(90deg, #2196F3, #21CBF3); height:100%; "
41
- f"border-radius:8px; width:{pct}%; transition: width 0.3s;'></div>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  f"</div>"
43
- f"<p style='color: #666; font-size: 13px; margin-top: 4px;'>{step}/{total} β€” {pct}%</p>"
44
  f"</div>"
45
  )
46
 
 
1
+ import gradio as gr
2
+
3
  def model_hyperlink(link, model_name):
4
  return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
5
 
 
16
  return model_hyperlink(link, model_name) + " " + model_hyperlink(details_link, "πŸ“‘")
17
 
18
  def styled_error(error):
19
+ raise gr.Error(error)
 
 
 
 
 
20
 
21
 
22
  def styled_warning(warn):
23
+ raise gr.Warning(warn)
24
 
25
 
26
  def styled_message(message):
27
+ gr.Info(message)
28
+ return ""
29
 
30
 
31
  def styled_progress(step: int, total: int, message: str) -> str:
32
  """Return a styled progress indicator (HTML)."""
33
  pct = int(step / total * 100) if total > 0 else 0
34
+ # Dots indicator: filled for completed steps, hollow for remaining
35
+ dots = "".join(
36
+ "<span style='display:inline-block;width:10px;height:10px;border-radius:50%;"
37
+ f"background:{'#2563eb' if i < step else '#cbd5e1'};"
38
+ "margin:0 3px;transition:background 0.3s;'></span>"
39
+ for i in range(total)
40
+ )
41
  return (
42
+ f"<div style='"
43
+ f"font-family:Manrope,sans-serif;"
44
+ f"background:linear-gradient(135deg,#eff6ff 0%,#f0fdf4 100%);"
45
+ f"border:1px solid #bfdbfe;"
46
+ f"border-radius:16px;"
47
+ f"padding:20px 28px;"
48
+ f"max-width:520px;"
49
+ f"margin:16px auto;"
50
+ f"box-shadow:0 4px 16px rgba(37,99,235,0.10);"
51
+ f"'>"
52
+ # Step label
53
+ f"<div style='display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;'>"
54
+ f"<span style='font-size:14px;font-weight:600;color:#1e3a8a;'>βš™ {message}</span>"
55
+ f"<span style='font-size:12px;font-weight:700;color:#2563eb;"
56
+ f"background:#dbeafe;border-radius:20px;padding:2px 10px;'>{step}/{total}</span>"
57
+ f"</div>"
58
+ # Progress bar
59
+ f"<div style='background:#e2e8f0;border-radius:999px;height:8px;overflow:hidden;'>"
60
+ f"<div style='height:100%;width:{pct}%;"
61
+ f"background:linear-gradient(90deg,#2563eb,#38bdf8);"
62
+ f"border-radius:999px;"
63
+ f"transition:width 0.4s cubic-bezier(.4,0,.2,1);'>"
64
+ f"</div></div>"
65
+ # Dots + percentage
66
+ f"<div style='display:flex;align-items:center;justify-content:space-between;margin-top:10px;'>"
67
+ f"<div>{dots}</div>"
68
+ f"<span style='font-size:12px;color:#64748b;font-weight:600;'>{pct}%</span>"
69
  f"</div>"
 
70
  f"</div>"
71
  )
72
 
src/submission/submit.py CHANGED
@@ -327,7 +327,7 @@ def add_new_eval(
327
  )
328
 
329
  if (not model_on_hub or model_config is None) and (not gguf_on_hub or gguf_files is None):
330
- yield styled_error(f'Model "{model}" {hub_error}'); return
331
 
332
  if model_config is not None:
333
  architectures = getattr(model_config, "architectures", None)
@@ -353,10 +353,10 @@ def add_new_eval(
353
  )
354
  if scheme is None:
355
  supported = ", ".join(SUPPORTED_QUANT_SCHEMES.keys())
356
- yield styled_error(
357
  f'Unsupported quantization scheme "{compute_dtype}". '
358
  f"Currently supported: {supported}."
359
- ); return
360
  if not is_valid:
361
  msg = (
362
  f"Only {scheme.name} quantized models are supported for evaluation. "
@@ -368,14 +368,14 @@ def add_new_eval(
368
  + " Please submit a model quantized with GPTQ, AWQ, AutoRound, "
369
  "BitsAndBytes (NF4/FP4), HQQ, or a similar method."
370
  )
371
- yield styled_error(msg); return
372
 
373
  # ── Fetch model info / license / model card ──────────────────────
374
  try:
375
  model_info = API.model_info(repo_id=model, revision=revision)
376
  except Exception:
377
  logger.error("Failed to fetch model info for %s", model, exc_info=True)
378
- yield styled_error("Could not get your model information. Please fill it up properly."); return
379
 
380
  license_str = _get_license(model_info)
381
  _ok, _err, model_card = check_model_card(model)
@@ -409,11 +409,11 @@ def add_new_eval(
409
  )
410
 
411
  if not model_params:
412
- yield styled_error(
413
  "Could not determine model parameter count automatically. "
414
  "Please enter the model size (in billions of parameters) in the "
415
  "'Model size' input field and re-submit."
416
- ); return
417
 
418
  size_err = check_model_size_limit(model_params)
419
  if size_err:
@@ -484,7 +484,7 @@ def add_new_eval(
484
  # ── Duplicate check ──────────────────────────────────────────────
485
  dedup_key = f"{model}_{revision}_{quant_type}_{precision}_{weight_dtype}_{compute_dtype}"
486
  if dedup_key in _EVAL_REQUESTED:
487
- yield styled_warning("This model has been already submitted."); return
488
 
489
  # ── Upload ───────────────────────────────────────────────────────
490
  file_tag = (
@@ -494,7 +494,7 @@ def add_new_eval(
494
  try:
495
  _upload_to_hub(eval_entry, user_name, model_path, file_tag, model, task_label="eval")
496
  except Exception:
497
- yield styled_error("Submission upload failed. Please try again later."); return
498
 
499
  yield styled_message(
500
  "Your request has been submitted to the evaluation queue!\n"
@@ -548,10 +548,10 @@ def add_new_quant(
548
  scheme = SUPPORTED_QUANT_SCHEMES.get(quant_scheme)
549
  if scheme is None:
550
  supported = ", ".join(SUPPORTED_QUANT_SCHEMES.keys())
551
- yield styled_error(
552
  f'Unsupported quantization scheme "{quant_scheme}". '
553
  f"Currently supported: {supported}."
554
- ); return
555
 
556
  # ── Step 1b: Validate input model (must be FP, not quantized) ────
557
  yield styled_progress(3, TOTAL_STEPS, "Checking model on HuggingFace Hub …")
@@ -559,7 +559,7 @@ def add_new_quant(
559
  model_name=model, revision=revision, test_tokenizer=True,
560
  )
561
  if not model_on_hub or model_config is None:
562
- yield styled_error(f'Model "{model}" {hub_error}'); return
563
 
564
  architecture = "?"
565
  architectures = getattr(model_config, "architectures", None)
@@ -570,11 +570,11 @@ def add_new_quant(
570
 
571
  quantization_config = getattr(model_config, "quantization_config", None)
572
  if quantization_config:
573
- yield styled_error(
574
  "The submitted model appears to already be quantized. "
575
  "auto_quant expects a full-precision (float32/float16/bfloat16) model as input. "
576
  "If you want to evaluate an already-quantized model, use auto_eval instead."
577
- ); return
578
 
579
  # Detect input dtype
580
  torch_dtype = getattr(model_config, "torch_dtype", None)
@@ -582,17 +582,17 @@ def add_new_quant(
582
  input_bits = SUPPORTED_INPUT_DTYPES.get(input_dtype)
583
  if input_bits is None:
584
  supported_dtypes = ", ".join(SUPPORTED_INPUT_DTYPES.keys())
585
- yield styled_error(
586
  f'Model dtype "{input_dtype}" is not supported for quantization. '
587
  f"Supported input dtypes: {supported_dtypes}."
588
- ); return
589
 
590
  # ── Fetch model info / license / model card ──────────────────────
591
  try:
592
  model_info = API.model_info(repo_id=model, revision=revision)
593
  except Exception:
594
  logger.error("Failed to fetch model info for %s", model, exc_info=True)
595
- yield styled_error("Could not get your model information. Please fill it up properly."); return
596
 
597
  license_str = _get_license(model_info)
598
  _ok, _err, model_card = check_model_card(model)
@@ -607,11 +607,11 @@ def add_new_quant(
607
  fp_label = "16bit" if input_bits == 16 else "32bit"
608
  model_params, model_weight_gb = get_model_size(model_info, precision=fp_label)
609
  if not model_params:
610
- yield styled_error(
611
  "Could not determine model parameter count automatically. "
612
  "Please enter the model size (in billions of parameters) in the "
613
  "'Model size' input field and re-submit."
614
- ); return
615
 
616
  size_err = check_model_size_limit(model_params)
617
  if size_err:
@@ -626,10 +626,10 @@ def add_new_quant(
626
  yield styled_progress(5, TOTAL_STEPS, "Estimating VRAM & selecting GPU …")
627
  num_layers = get_num_layers(model_config)
628
  if num_layers is None or num_layers <= 0:
629
- yield styled_error(
630
  "Could not determine the number of layers in the model. "
631
  "This is required to estimate quantization memory."
632
- ); return
633
 
634
  quant_memory_gb = estimate_quantization_memory_gb(
635
  model_weight_gb=model_weight_gb,
@@ -717,7 +717,7 @@ def add_new_quant(
717
  # ── Duplicate check ──────────────────────────────────────────────
718
  dedup_key = f"{model}_{revision}_{scheme.name}_{scheme.precision}_{scheme.weight_dtype}_{scheme.hardware}"
719
  if dedup_key in _QUANT_REQUESTED:
720
- yield styled_warning("This model has been already submitted for quantization."); return
721
 
722
  # ── Upload ───────────────────────────────────────────────────────
723
  file_tag = (
@@ -727,7 +727,7 @@ def add_new_quant(
727
  try:
728
  _upload_to_hub(quant_entry, user_name, model_path, file_tag, model, task_label="quant")
729
  except Exception:
730
- yield styled_error("Quantization submission upload failed. Please try again later."); return
731
 
732
  yield styled_message(
733
  "Your quantization request has been submitted!\n"
 
327
  )
328
 
329
  if (not model_on_hub or model_config is None) and (not gguf_on_hub or gguf_files is None):
330
+ styled_error(f'Model "{model}" {hub_error}')
331
 
332
  if model_config is not None:
333
  architectures = getattr(model_config, "architectures", None)
 
353
  )
354
  if scheme is None:
355
  supported = ", ".join(SUPPORTED_QUANT_SCHEMES.keys())
356
+ styled_error(
357
  f'Unsupported quantization scheme "{compute_dtype}". '
358
  f"Currently supported: {supported}."
359
+ )
360
  if not is_valid:
361
  msg = (
362
  f"Only {scheme.name} quantized models are supported for evaluation. "
 
368
  + " Please submit a model quantized with GPTQ, AWQ, AutoRound, "
369
  "BitsAndBytes (NF4/FP4), HQQ, or a similar method."
370
  )
371
+ styled_error(msg)
372
 
373
  # ── Fetch model info / license / model card ──────────────────────
374
  try:
375
  model_info = API.model_info(repo_id=model, revision=revision)
376
  except Exception:
377
  logger.error("Failed to fetch model info for %s", model, exc_info=True)
378
+ styled_error("Could not get your model information. Please fill it up properly.")
379
 
380
  license_str = _get_license(model_info)
381
  _ok, _err, model_card = check_model_card(model)
 
409
  )
410
 
411
  if not model_params:
412
+ styled_error(
413
  "Could not determine model parameter count automatically. "
414
  "Please enter the model size (in billions of parameters) in the "
415
  "'Model size' input field and re-submit."
416
+ )
417
 
418
  size_err = check_model_size_limit(model_params)
419
  if size_err:
 
484
  # ── Duplicate check ──────────────────────────────────────────────
485
  dedup_key = f"{model}_{revision}_{quant_type}_{precision}_{weight_dtype}_{compute_dtype}"
486
  if dedup_key in _EVAL_REQUESTED:
487
+ styled_warning("This model has been already submitted.")
488
 
489
  # ── Upload ───────────────────────────────────────────────────────
490
  file_tag = (
 
494
  try:
495
  _upload_to_hub(eval_entry, user_name, model_path, file_tag, model, task_label="eval")
496
  except Exception:
497
+ styled_error("Submission upload failed. Please try again later.")
498
 
499
  yield styled_message(
500
  "Your request has been submitted to the evaluation queue!\n"
 
548
  scheme = SUPPORTED_QUANT_SCHEMES.get(quant_scheme)
549
  if scheme is None:
550
  supported = ", ".join(SUPPORTED_QUANT_SCHEMES.keys())
551
+ styled_error(
552
  f'Unsupported quantization scheme "{quant_scheme}". '
553
  f"Currently supported: {supported}."
554
+ )
555
 
556
  # ── Step 1b: Validate input model (must be FP, not quantized) ────
557
  yield styled_progress(3, TOTAL_STEPS, "Checking model on HuggingFace Hub …")
 
559
  model_name=model, revision=revision, test_tokenizer=True,
560
  )
561
  if not model_on_hub or model_config is None:
562
+ styled_error(f'Model "{model}" {hub_error}')
563
 
564
  architecture = "?"
565
  architectures = getattr(model_config, "architectures", None)
 
570
 
571
  quantization_config = getattr(model_config, "quantization_config", None)
572
  if quantization_config:
573
+ styled_error(
574
  "The submitted model appears to already be quantized. "
575
  "auto_quant expects a full-precision (float32/float16/bfloat16) model as input. "
576
  "If you want to evaluate an already-quantized model, use auto_eval instead."
577
+ )
578
 
579
  # Detect input dtype
580
  torch_dtype = getattr(model_config, "torch_dtype", None)
 
582
  input_bits = SUPPORTED_INPUT_DTYPES.get(input_dtype)
583
  if input_bits is None:
584
  supported_dtypes = ", ".join(SUPPORTED_INPUT_DTYPES.keys())
585
+ styled_error(
586
  f'Model dtype "{input_dtype}" is not supported for quantization. '
587
  f"Supported input dtypes: {supported_dtypes}."
588
+ )
589
 
590
  # ── Fetch model info / license / model card ──────────────────────
591
  try:
592
  model_info = API.model_info(repo_id=model, revision=revision)
593
  except Exception:
594
  logger.error("Failed to fetch model info for %s", model, exc_info=True)
595
+ styled_error("Could not get your model information. Please fill it up properly.")
596
 
597
  license_str = _get_license(model_info)
598
  _ok, _err, model_card = check_model_card(model)
 
607
  fp_label = "16bit" if input_bits == 16 else "32bit"
608
  model_params, model_weight_gb = get_model_size(model_info, precision=fp_label)
609
  if not model_params:
610
+ styled_error(
611
  "Could not determine model parameter count automatically. "
612
  "Please enter the model size (in billions of parameters) in the "
613
  "'Model size' input field and re-submit."
614
+ )
615
 
616
  size_err = check_model_size_limit(model_params)
617
  if size_err:
 
626
  yield styled_progress(5, TOTAL_STEPS, "Estimating VRAM & selecting GPU …")
627
  num_layers = get_num_layers(model_config)
628
  if num_layers is None or num_layers <= 0:
629
+ styled_error(
630
  "Could not determine the number of layers in the model. "
631
  "This is required to estimate quantization memory."
632
+ )
633
 
634
  quant_memory_gb = estimate_quantization_memory_gb(
635
  model_weight_gb=model_weight_gb,
 
717
  # ── Duplicate check ──────────────────────────────────────────────
718
  dedup_key = f"{model}_{revision}_{scheme.name}_{scheme.precision}_{scheme.weight_dtype}_{scheme.hardware}"
719
  if dedup_key in _QUANT_REQUESTED:
720
+ styled_warning("This model has been already submitted for quantization.")
721
 
722
  # ── Upload ───────────────────────────────────────────────────────
723
  file_tag = (
 
727
  try:
728
  _upload_to_hub(quant_entry, user_name, model_path, file_tag, model, task_label="quant")
729
  except Exception:
730
+ styled_error("Quantization submission upload failed. Please try again later.")
731
 
732
  yield styled_message(
733
  "Your quantization request has been submitted!\n"