alozowski HF staff commited on
Commit
5dae46b
1 Parent(s): 8a0773c

check-submit (#920)

Browse files

- Check for existing model submission with matching precision and revision (71270e3c664505e33f08235b392418955df3d7ca)

Files changed (1) hide show
  1. src/submission/submit.py +14 -11
src/submission/submit.py CHANGED
@@ -66,8 +66,10 @@ def add_new_eval(
66
  weight_type: str,
67
  model_type: str,
68
  use_chat_template: bool,
69
- profile: gr.OAuthProfile | None
70
- ):
 
 
71
  # Login required
72
  if profile is None:
73
  return styled_error("Hub Login Required")
@@ -75,11 +77,10 @@ def add_new_eval(
75
  # Name of the actual user who sent the request
76
  username = profile.username
77
 
78
- global REQUESTED_MODELS
79
- global USERS_TO_SUBMISSION_DATES
80
- if not REQUESTED_MODELS:
81
- REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
82
-
83
 
84
  org_or_user = ""
85
  model_path = model
@@ -96,7 +97,7 @@ def add_new_eval(
96
  # Is the user rate limited?
97
  if org_or_user != "":
98
  user_can_submit, error_msg = user_submission_permission(
99
- org_or_user, USERS_TO_SUBMISSION_DATES, RATE_LIMIT_PERIOD, RATE_LIMIT_QUOTA
100
  )
101
  if not user_can_submit:
102
  return styled_error(error_msg)
@@ -112,15 +113,18 @@ def add_new_eval(
112
  model_info = API.model_info(repo_id=model, revision=revision)
113
  except Exception as e:
114
  return styled_error("Could not get your model information. Please fill it up properly.")
 
 
 
 
115
 
116
  # Check model size early
117
  model_size = get_model_size(model_info=model_info, precision=precision)
118
-
119
  # First check: Absolute size limit for float16 and bfloat16
120
  if precision in ["float16", "bfloat16"] and model_size > 100:
121
  return styled_error(f"Sadly, models larger than 100B parameters cannot be submitted in {precision} precision at this time. "
122
  f"Your model size: {model_size:.2f}B parameters.")
123
-
124
  # Second check: Precision-adjusted size limit for 8bit, 4bit, and GPTQ
125
  if precision in ["8bit", "4bit", "GPTQ"]:
126
  size_checker = ModelSizeChecker(model=model, precision=precision, model_size_in_b=model_size)
@@ -147,7 +151,6 @@ def add_new_eval(
147
  architectures = getattr(model_config, "architectures", None)
148
  if architectures:
149
  architecture = ";".join(architectures)
150
-
151
  # Were the model card and license filled?
152
  try:
153
  model_info.cardData["license"]
 
66
  weight_type: str,
67
  model_type: str,
68
  use_chat_template: bool,
69
+ profile: gr.OAuthProfile | None,
70
+ requested_models: set[str] = None,
71
+ users_to_submission_dates: dict[str, list[str]] = None,
72
+ ):
73
  # Login required
74
  if profile is None:
75
  return styled_error("Hub Login Required")
 
77
  # Name of the actual user who sent the request
78
  username = profile.username
79
 
80
+ # Initialize the requested_models and users_to_submission_dates variables
81
+ # If the caller did not provide these values, fetch them from the EVAL_REQUESTS_PATH
82
+ if requested_models is None or users_to_submission_dates is None:
83
+ requested_models, users_to_submission_dates = already_submitted_models(EVAL_REQUESTS_PATH)
 
84
 
85
  org_or_user = ""
86
  model_path = model
 
97
  # Is the user rate limited?
98
  if org_or_user != "":
99
  user_can_submit, error_msg = user_submission_permission(
100
+ org_or_user, users_to_submission_dates, RATE_LIMIT_PERIOD, RATE_LIMIT_QUOTA
101
  )
102
  if not user_can_submit:
103
  return styled_error(error_msg)
 
113
  model_info = API.model_info(repo_id=model, revision=revision)
114
  except Exception as e:
115
  return styled_error("Could not get your model information. Please fill it up properly.")
116
+
117
+ model_key = f"{model}_{model_info.sha}_{precision}"
118
+ if model_key in requested_models:
119
+ return styled_error(f"The model '{model}' with revision '{model_info.sha}' and precision '{precision}' has already been submitted.")
120
 
121
  # Check model size early
122
  model_size = get_model_size(model_info=model_info, precision=precision)
 
123
  # First check: Absolute size limit for float16 and bfloat16
124
  if precision in ["float16", "bfloat16"] and model_size > 100:
125
  return styled_error(f"Sadly, models larger than 100B parameters cannot be submitted in {precision} precision at this time. "
126
  f"Your model size: {model_size:.2f}B parameters.")
127
+
128
  # Second check: Precision-adjusted size limit for 8bit, 4bit, and GPTQ
129
  if precision in ["8bit", "4bit", "GPTQ"]:
130
  size_checker = ModelSizeChecker(model=model, precision=precision, model_size_in_b=model_size)
 
151
  architectures = getattr(model_config, "architectures", None)
152
  if architectures:
153
  architecture = ";".join(architectures)
 
154
  # Were the model card and license filled?
155
  try:
156
  model_info.cardData["license"]