try different layout
Browse files
app.py
CHANGED
@@ -176,41 +176,56 @@ with demo:
|
|
176 |
gr.Markdown(
|
177 |
"""
|
178 |
# TensorFlow XLA Text Generation Benchmark
|
179 |
-
|
180 |
-
|
|
|
|
|
181 |
PyTorch to TensorFlow with XLA.
|
182 |
"""
|
183 |
)
|
184 |
with gr.Tabs():
|
185 |
with gr.TabItem("Greedy Search"):
|
186 |
-
gr.Markdown(
|
187 |
-
"""
|
188 |
-
### Greedy Search benchmark parameters
|
189 |
-
- `max_new_tokens = 64`;
|
190 |
-
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
191 |
-
"""
|
192 |
-
)
|
193 |
-
with gr.Row():
|
194 |
-
model_selector = gr.Dropdown(
|
195 |
-
choices=["DistilGPT2", "GPT2", "OPT-1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
|
196 |
-
value="T5 Small",
|
197 |
-
label="Model",
|
198 |
-
interactive=True,
|
199 |
-
)
|
200 |
-
eager_enabler = gr.Radio(
|
201 |
-
["Yes", "No"],
|
202 |
-
value="Yes",
|
203 |
-
label="Plot TF Eager Execution?",
|
204 |
-
interactive=True
|
205 |
-
)
|
206 |
plot_fn = functools.partial(get_plot, generate_type="Greedy Search")
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
209 |
eager_enabler.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
210 |
with gr.TabItem("Sample"):
|
211 |
plot_fn = functools.partial(get_plot, generate_type="Sample")
|
212 |
with gr.Row():
|
213 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
gr.Markdown(
|
215 |
"""
|
216 |
### Sample benchmark parameters
|
@@ -220,6 +235,13 @@ with demo:
|
|
220 |
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
221 |
"""
|
222 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
model_selector = gr.Dropdown(
|
224 |
choices=["DistilGPT2", "GPT2", "OPT-1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
|
225 |
value="T5 Small",
|
@@ -232,35 +254,17 @@ with demo:
|
|
232 |
label="Plot TF Eager Execution?",
|
233 |
interactive=True
|
234 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
plot = gr.Image(value=plot_fn("T5 Small", "Yes")) # Show plot when the gradio app is initialized
|
236 |
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
237 |
eager_enabler.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
238 |
-
with gr.TabItem("Beam Search"):
|
239 |
-
gr.Markdown(
|
240 |
-
"""
|
241 |
-
### Beam Search benchmark parameters
|
242 |
-
- `max_new_tokens = 256`;
|
243 |
-
- `num_beams = 16`;
|
244 |
-
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
245 |
-
"""
|
246 |
-
)
|
247 |
-
with gr.Row():
|
248 |
-
model_selector = gr.Dropdown(
|
249 |
-
choices=["DistilGPT2", "GPT2", "OPT-1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
|
250 |
-
value="T5 Small",
|
251 |
-
label="Model",
|
252 |
-
interactive=True,
|
253 |
-
)
|
254 |
-
eager_enabler = gr.Radio(
|
255 |
-
["Yes", "No"],
|
256 |
-
value="Yes",
|
257 |
-
label="Plot TF Eager Execution?",
|
258 |
-
interactive=True
|
259 |
-
)
|
260 |
-
plot_fn = functools.partial(get_plot, generate_type="Beam Search")
|
261 |
-
plot = gr.Image(value=plot_fn("T5 Small", "Yes")) # Show plot when the gradio app is initialized
|
262 |
-
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
263 |
-
eager_enabler.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
264 |
with gr.TabItem("Benchmark Information"):
|
265 |
gr.Dataframe(
|
266 |
headers=["Parameter", "Value"],
|
|
|
176 |
gr.Markdown(
|
177 |
"""
|
178 |
# TensorFlow XLA Text Generation Benchmark
|
179 |
+
Instructions:
|
180 |
+
1. Pick a tab for the type of generation (or other information);
|
181 |
+
2. Select a model from the dropdown menu;
|
182 |
+
3. Optionally omit results from TensorFlow Eager Execution, if you wish to better compare the performance of
|
183 |
PyTorch to TensorFlow with XLA.
|
184 |
"""
|
185 |
)
|
186 |
with gr.Tabs():
|
187 |
with gr.TabItem("Greedy Search"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
plot_fn = functools.partial(get_plot, generate_type="Greedy Search")
|
189 |
+
with gr.Row():
|
190 |
+
with gr.Column():
|
191 |
+
model_selector = gr.Dropdown(
|
192 |
+
choices=["DistilGPT2", "GPT2", "OPT-1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
|
193 |
+
value="T5 Small",
|
194 |
+
label="Model",
|
195 |
+
interactive=True,
|
196 |
+
)
|
197 |
+
eager_enabler = gr.Radio(
|
198 |
+
["Yes", "No"],
|
199 |
+
value="Yes",
|
200 |
+
label="Plot TF Eager Execution?",
|
201 |
+
interactive=True
|
202 |
+
)
|
203 |
+
gr.Markdown(
|
204 |
+
"""
|
205 |
+
### Greedy Search benchmark parameters
|
206 |
+
- `max_new_tokens = 64`;
|
207 |
+
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
208 |
+
"""
|
209 |
+
)
|
210 |
+
plot = gr.Image(value=plot_fn("T5 Small", "Yes")) # Show plot when the gradio app is initialized
|
211 |
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
212 |
eager_enabler.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
213 |
with gr.TabItem("Sample"):
|
214 |
plot_fn = functools.partial(get_plot, generate_type="Sample")
|
215 |
with gr.Row():
|
216 |
with gr.Column():
|
217 |
+
model_selector = gr.Dropdown(
|
218 |
+
choices=["DistilGPT2", "GPT2", "OPT-1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
|
219 |
+
value="T5 Small",
|
220 |
+
label="Model",
|
221 |
+
interactive=True,
|
222 |
+
)
|
223 |
+
eager_enabler = gr.Radio(
|
224 |
+
["Yes", "No"],
|
225 |
+
value="Yes",
|
226 |
+
label="Plot TF Eager Execution?",
|
227 |
+
interactive=True
|
228 |
+
)
|
229 |
gr.Markdown(
|
230 |
"""
|
231 |
### Sample benchmark parameters
|
|
|
235 |
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
236 |
"""
|
237 |
)
|
238 |
+
plot = gr.Image(value=plot_fn("T5 Small", "Yes")) # Show plot when the gradio app is initialized
|
239 |
+
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
240 |
+
eager_enabler.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
241 |
+
with gr.TabItem("Beam Search"):
|
242 |
+
plot_fn = functools.partial(get_plot, generate_type="Beam Search")
|
243 |
+
with gr.Row():
|
244 |
+
with gr.Column():
|
245 |
model_selector = gr.Dropdown(
|
246 |
choices=["DistilGPT2", "GPT2", "OPT-1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
|
247 |
value="T5 Small",
|
|
|
254 |
label="Plot TF Eager Execution?",
|
255 |
interactive=True
|
256 |
)
|
257 |
+
gr.Markdown(
|
258 |
+
"""
|
259 |
+
### Beam Search benchmark parameters
|
260 |
+
- `max_new_tokens = 256`;
|
261 |
+
- `num_beams = 16`;
|
262 |
+
- `pad_to_multiple_of = 64` for Tensorflow XLA models. Others do not pad (input prompts between 2 and 33 tokens).
|
263 |
+
"""
|
264 |
+
)
|
265 |
plot = gr.Image(value=plot_fn("T5 Small", "Yes")) # Show plot when the gradio app is initialized
|
266 |
model_selector.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
267 |
eager_enabler.change(fn=plot_fn, inputs=[model_selector, eager_enabler], outputs=plot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
with gr.TabItem("Benchmark Information"):
|
269 |
gr.Dataframe(
|
270 |
headers=["Parameter", "Value"],
|