Spaces:
Runtime error
Runtime error
Andrea Seveso
commited on
Commit
·
ff797f9
1
Parent(s):
8d2a6ac
Remove precision
Browse files- app.py +0 -12
- src/display/utils.py +0 -16
- src/leaderboard/read_evals.py +8 -14
- src/submission/check_validity.py +3 -4
- src/submission/submit.py +3 -6
app.py
CHANGED
@@ -21,7 +21,6 @@ from src.display.utils import (
|
|
21 |
AutoEvalColumn,
|
22 |
ModelType,
|
23 |
fields,
|
24 |
-
Precision
|
25 |
)
|
26 |
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
27 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
@@ -77,8 +76,6 @@ def init_leaderboard(dataframe):
|
|
77 |
filter_columns=[
|
78 |
ColumnFilter(AutoEvalColumn.model_type.name,
|
79 |
type="checkboxgroup", label="Model types"),
|
80 |
-
ColumnFilter(AutoEvalColumn.precision.name,
|
81 |
-
type="checkboxgroup", label="Precision"),
|
82 |
ColumnFilter(
|
83 |
AutoEvalColumn.params.name,
|
84 |
type="slider",
|
@@ -167,14 +164,6 @@ with demo:
|
|
167 |
)
|
168 |
|
169 |
with gr.Column():
|
170 |
-
precision = gr.Dropdown(
|
171 |
-
choices=[i.value.name for i in Precision if i !=
|
172 |
-
Precision.Unknown],
|
173 |
-
label="Precision",
|
174 |
-
multiselect=False,
|
175 |
-
value="float16",
|
176 |
-
interactive=True,
|
177 |
-
)
|
178 |
base_model_name_textbox = gr.Textbox(
|
179 |
label="Base model (for delta or adapter weights)")
|
180 |
|
@@ -186,7 +175,6 @@ with demo:
|
|
186 |
model_name_textbox,
|
187 |
base_model_name_textbox,
|
188 |
revision_name_textbox,
|
189 |
-
precision,
|
190 |
model_type,
|
191 |
],
|
192 |
submission_result,
|
|
|
21 |
AutoEvalColumn,
|
22 |
ModelType,
|
23 |
fields,
|
|
|
24 |
)
|
25 |
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
26 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
|
|
76 |
filter_columns=[
|
77 |
ColumnFilter(AutoEvalColumn.model_type.name,
|
78 |
type="checkboxgroup", label="Model types"),
|
|
|
|
|
79 |
ColumnFilter(
|
80 |
AutoEvalColumn.params.name,
|
81 |
type="slider",
|
|
|
164 |
)
|
165 |
|
166 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
base_model_name_textbox = gr.Textbox(
|
168 |
label="Base model (for delta or adapter weights)")
|
169 |
|
|
|
175 |
model_name_textbox,
|
176 |
base_model_name_textbox,
|
177 |
revision_name_textbox,
|
|
|
178 |
model_type,
|
179 |
],
|
180 |
submission_result,
|
src/display/utils.py
CHANGED
@@ -37,8 +37,6 @@ for task in Tasks:
|
|
37 |
# Model information
|
38 |
auto_eval_column_dict.append(
|
39 |
["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
40 |
-
auto_eval_column_dict.append(
|
41 |
-
["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
42 |
auto_eval_column_dict.append(
|
43 |
["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
44 |
auto_eval_column_dict.append(
|
@@ -56,7 +54,6 @@ class EvalQueueColumn: # Queue column
|
|
56 |
model = ColumnContent("model", "markdown", True)
|
57 |
revision = ColumnContent("revision", "str", True)
|
58 |
private = ColumnContent("private", "bool", True)
|
59 |
-
precision = ColumnContent("precision", "str", True)
|
60 |
status = ColumnContent("status", "str", True)
|
61 |
|
62 |
# All the model information that we might need
|
@@ -86,19 +83,6 @@ class ModelType(Enum):
|
|
86 |
return ModelType.Unknown
|
87 |
|
88 |
|
89 |
-
class Precision(Enum):
|
90 |
-
float16 = ModelDetails("float16")
|
91 |
-
bfloat16 = ModelDetails("bfloat16")
|
92 |
-
Unknown = ModelDetails("?")
|
93 |
-
|
94 |
-
def from_str(precision):
|
95 |
-
if precision in ["torch.float16", "float16"]:
|
96 |
-
return Precision.float16
|
97 |
-
if precision in ["torch.bfloat16", "bfloat16"]:
|
98 |
-
return Precision.bfloat16
|
99 |
-
return Precision.Unknown
|
100 |
-
|
101 |
-
|
102 |
# Column selection
|
103 |
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
104 |
|
|
|
37 |
# Model information
|
38 |
auto_eval_column_dict.append(
|
39 |
["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
|
|
|
|
40 |
auto_eval_column_dict.append(
|
41 |
["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
42 |
auto_eval_column_dict.append(
|
|
|
54 |
model = ColumnContent("model", "markdown", True)
|
55 |
revision = ColumnContent("revision", "str", True)
|
56 |
private = ColumnContent("private", "bool", True)
|
|
|
57 |
status = ColumnContent("status", "str", True)
|
58 |
|
59 |
# All the model information that we might need
|
|
|
83 |
return ModelType.Unknown
|
84 |
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
# Column selection
|
87 |
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
88 |
|
src/leaderboard/read_evals.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from src.submission.check_validity import is_model_on_hub
|
2 |
-
from src.display.utils import AutoEvalColumn, ModelType, Tasks
|
3 |
from src.display.formatting import make_clickable_model
|
4 |
import numpy as np
|
5 |
import dateutil
|
@@ -15,13 +15,12 @@ print("--- CONFIRMED: Running the modified version of read_evals.py ---")
|
|
15 |
class EvalResult:
|
16 |
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
17 |
"""
|
18 |
-
eval_name: str #
|
19 |
full_model: str # org/model (path on hub)
|
20 |
org: str
|
21 |
model: str
|
22 |
revision: str # commit hash, "" if main
|
23 |
results: dict
|
24 |
-
precision: Precision = Precision.Unknown
|
25 |
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
26 |
architecture: str = "Unknown"
|
27 |
likes: int = 0
|
@@ -37,9 +36,6 @@ class EvalResult:
|
|
37 |
|
38 |
config = data.get("config")
|
39 |
|
40 |
-
# Precision
|
41 |
-
precision = Precision.from_str(config.get("model_dtype"))
|
42 |
-
|
43 |
# Get model and org
|
44 |
org_and_model = config.get(
|
45 |
"model_name", config.get("model_args", None))
|
@@ -48,11 +44,11 @@ class EvalResult:
|
|
48 |
if len(org_and_model) == 1:
|
49 |
org = None
|
50 |
model = org_and_model[0]
|
51 |
-
result_key = f"{model}
|
52 |
else:
|
53 |
org = org_and_model[0]
|
54 |
model = org_and_model[1]
|
55 |
-
result_key = f"{org}
|
56 |
full_model = "/".join(org_and_model)
|
57 |
|
58 |
still_on_hub, _, model_config = is_model_on_hub(
|
@@ -79,7 +75,6 @@ class EvalResult:
|
|
79 |
org=org,
|
80 |
model=model,
|
81 |
results=results,
|
82 |
-
precision=precision,
|
83 |
revision=config.get("model_sha", ""),
|
84 |
still_on_hub=still_on_hub,
|
85 |
)
|
@@ -87,7 +82,7 @@ class EvalResult:
|
|
87 |
def update_with_request_file(self, requests_path):
|
88 |
"""Finds the relevant request file for the current model and updates info with it"""
|
89 |
request_file = get_request_file_for_model(
|
90 |
-
requests_path, self.full_model
|
91 |
|
92 |
try:
|
93 |
with open(request_file, "r") as f:
|
@@ -97,13 +92,12 @@ class EvalResult:
|
|
97 |
self.date = request.get("submitted_time", "")
|
98 |
except Exception:
|
99 |
print(
|
100 |
-
f"Could not find request file for {self.org}/{self.model}
|
101 |
|
102 |
def to_dict(self):
|
103 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
104 |
data_dict = {
|
105 |
"eval_name": self.eval_name, # not a column, just a save name,
|
106 |
-
AutoEvalColumn.precision.name: self.precision.value.name,
|
107 |
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
108 |
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
109 |
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
@@ -118,7 +112,7 @@ class EvalResult:
|
|
118 |
return data_dict
|
119 |
|
120 |
|
121 |
-
def get_request_file_for_model(requests_path, model_name
|
122 |
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
123 |
request_files = os.path.join(
|
124 |
requests_path,
|
@@ -126,7 +120,7 @@ def get_request_file_for_model(requests_path, model_name, precision=None):
|
|
126 |
)
|
127 |
request_files = glob.glob(request_files)
|
128 |
|
129 |
-
# Select correct request file
|
130 |
request_file = ""
|
131 |
request_files = sorted(request_files, reverse=True)
|
132 |
for tmp_request_file in request_files:
|
|
|
1 |
from src.submission.check_validity import is_model_on_hub
|
2 |
+
from src.display.utils import AutoEvalColumn, ModelType, Tasks
|
3 |
from src.display.formatting import make_clickable_model
|
4 |
import numpy as np
|
5 |
import dateutil
|
|
|
15 |
class EvalResult:
|
16 |
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
17 |
"""
|
18 |
+
eval_name: str # org_model (uid)
|
19 |
full_model: str # org/model (path on hub)
|
20 |
org: str
|
21 |
model: str
|
22 |
revision: str # commit hash, "" if main
|
23 |
results: dict
|
|
|
24 |
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
25 |
architecture: str = "Unknown"
|
26 |
likes: int = 0
|
|
|
36 |
|
37 |
config = data.get("config")
|
38 |
|
|
|
|
|
|
|
39 |
# Get model and org
|
40 |
org_and_model = config.get(
|
41 |
"model_name", config.get("model_args", None))
|
|
|
44 |
if len(org_and_model) == 1:
|
45 |
org = None
|
46 |
model = org_and_model[0]
|
47 |
+
result_key = f"{model}"
|
48 |
else:
|
49 |
org = org_and_model[0]
|
50 |
model = org_and_model[1]
|
51 |
+
result_key = f"{org}"
|
52 |
full_model = "/".join(org_and_model)
|
53 |
|
54 |
still_on_hub, _, model_config = is_model_on_hub(
|
|
|
75 |
org=org,
|
76 |
model=model,
|
77 |
results=results,
|
|
|
78 |
revision=config.get("model_sha", ""),
|
79 |
still_on_hub=still_on_hub,
|
80 |
)
|
|
|
82 |
def update_with_request_file(self, requests_path):
|
83 |
"""Finds the relevant request file for the current model and updates info with it"""
|
84 |
request_file = get_request_file_for_model(
|
85 |
+
requests_path, self.full_model)
|
86 |
|
87 |
try:
|
88 |
with open(request_file, "r") as f:
|
|
|
92 |
self.date = request.get("submitted_time", "")
|
93 |
except Exception:
|
94 |
print(
|
95 |
+
f"Could not find request file for {self.org}/{self.model}")
|
96 |
|
97 |
def to_dict(self):
|
98 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
99 |
data_dict = {
|
100 |
"eval_name": self.eval_name, # not a column, just a save name,
|
|
|
101 |
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
102 |
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
103 |
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
|
|
112 |
return data_dict
|
113 |
|
114 |
|
115 |
+
def get_request_file_for_model(requests_path, model_name):
|
116 |
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
117 |
request_files = os.path.join(
|
118 |
requests_path,
|
|
|
120 |
)
|
121 |
request_files = glob.glob(request_files)
|
122 |
|
123 |
+
# Select correct request file
|
124 |
request_file = ""
|
125 |
request_files = sorted(request_files, reverse=True)
|
126 |
for tmp_request_file in request_files:
|
src/submission/check_validity.py
CHANGED
@@ -55,15 +55,14 @@ def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_rem
|
|
55 |
return False, "was not found on hub!", None
|
56 |
|
57 |
|
58 |
-
def get_model_size(model_info: ModelInfo
|
59 |
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
60 |
try:
|
61 |
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
62 |
except (AttributeError, TypeError):
|
63 |
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
64 |
|
65 |
-
size_factor = 8
|
66 |
-
precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
67 |
model_size = size_factor * model_size
|
68 |
return model_size
|
69 |
|
@@ -88,7 +87,7 @@ def already_submitted_models(requested_models_dir: str) -> set[str]:
|
|
88 |
with open(os.path.join(root, file), "r") as f:
|
89 |
info = json.load(f)
|
90 |
file_names.append(
|
91 |
-
f"{info['model']}_{info['revision']}
|
92 |
|
93 |
# Select organisation
|
94 |
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
|
|
55 |
return False, "was not found on hub!", None
|
56 |
|
57 |
|
58 |
+
def get_model_size(model_info: ModelInfo):
|
59 |
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
60 |
try:
|
61 |
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
62 |
except (AttributeError, TypeError):
|
63 |
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
64 |
|
65 |
+
size_factor = 8 # Default size factor for float32 models
|
|
|
66 |
model_size = size_factor * model_size
|
67 |
return model_size
|
68 |
|
|
|
87 |
with open(os.path.join(root, file), "r") as f:
|
88 |
info = json.load(f)
|
89 |
file_names.append(
|
90 |
+
f"{info['model']}_{info['revision']}")
|
91 |
|
92 |
# Select organisation
|
93 |
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
src/submission/submit.py
CHANGED
@@ -19,7 +19,6 @@ def add_new_eval(
|
|
19 |
model: str,
|
20 |
base_model: str,
|
21 |
revision: str,
|
22 |
-
precision: str,
|
23 |
model_type: str,
|
24 |
):
|
25 |
global REQUESTED_MODELS
|
@@ -34,7 +33,6 @@ def add_new_eval(
|
|
34 |
user_name = model.split("/")[0]
|
35 |
model_path = model.split("/")[1]
|
36 |
|
37 |
-
precision = precision.split(" ")[0]
|
38 |
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
39 |
|
40 |
if model_type is None or model_type == "":
|
@@ -50,7 +48,7 @@ def add_new_eval(
|
|
50 |
except Exception:
|
51 |
return styled_error("Could not get your model information. Please fill it up properly.")
|
52 |
|
53 |
-
model_size = get_model_size(model_info=model_info
|
54 |
|
55 |
# Were the model card and license filled?
|
56 |
try:
|
@@ -69,7 +67,6 @@ def add_new_eval(
|
|
69 |
"model": model,
|
70 |
"base_model": base_model,
|
71 |
"revision": revision,
|
72 |
-
"precision": precision,
|
73 |
"status": "PENDING",
|
74 |
"submitted_time": current_time,
|
75 |
"model_type": model_type,
|
@@ -80,13 +77,13 @@ def add_new_eval(
|
|
80 |
}
|
81 |
|
82 |
# Check for duplicate submission
|
83 |
-
if f"{model}_{revision}
|
84 |
return styled_warning("This model has been already submitted.")
|
85 |
|
86 |
print("Creating eval file")
|
87 |
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
88 |
os.makedirs(OUT_DIR, exist_ok=True)
|
89 |
-
out_path = f"{OUT_DIR}/{model_path}
|
90 |
|
91 |
with open(out_path, "w") as f:
|
92 |
f.write(json.dumps(eval_entry))
|
|
|
19 |
model: str,
|
20 |
base_model: str,
|
21 |
revision: str,
|
|
|
22 |
model_type: str,
|
23 |
):
|
24 |
global REQUESTED_MODELS
|
|
|
33 |
user_name = model.split("/")[0]
|
34 |
model_path = model.split("/")[1]
|
35 |
|
|
|
36 |
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
37 |
|
38 |
if model_type is None or model_type == "":
|
|
|
48 |
except Exception:
|
49 |
return styled_error("Could not get your model information. Please fill it up properly.")
|
50 |
|
51 |
+
model_size = get_model_size(model_info=model_info)
|
52 |
|
53 |
# Were the model card and license filled?
|
54 |
try:
|
|
|
67 |
"model": model,
|
68 |
"base_model": base_model,
|
69 |
"revision": revision,
|
|
|
70 |
"status": "PENDING",
|
71 |
"submitted_time": current_time,
|
72 |
"model_type": model_type,
|
|
|
77 |
}
|
78 |
|
79 |
# Check for duplicate submission
|
80 |
+
if f"{model}_{revision}" in REQUESTED_MODELS:
|
81 |
return styled_warning("This model has been already submitted.")
|
82 |
|
83 |
print("Creating eval file")
|
84 |
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
85 |
os.makedirs(OUT_DIR, exist_ok=True)
|
86 |
+
out_path = f"{OUT_DIR}/{model_path}_eval_request_False.json"
|
87 |
|
88 |
with open(out_path, "w") as f:
|
89 |
f.write(json.dumps(eval_entry))
|