Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warmup run to component benchmark #504

Merged
merged 1 commit into from
Sep 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/benchmarks/question_answering_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def benchmark(params, output="results_component_test.csv"):
ds = generate_param_dicts(params)
print(f"Running {len(ds)} benchmarks...")
results = []
warmup_run()
for d in tqdm(ds):
result = benchmark_single(**d)
results.append(result)
Expand All @@ -40,6 +41,25 @@ def benchmark(params, output="results_component_test.csv"):
df.to_csv(output)


def warmup_run():
""" This run warms up the gpu. We saw cases where the first run in the loop took longer or showed different
time profile characteristics. This warm up run is intended to reduce this kind of fluctation. """
question = [l[:-1] for l in open(questions_file)][0]
document_size = 100_000
input_dict = prepare_dict(sample_file, question, document_size)
# Run once with real prediction heads
inferencer = Inferencer.load("deepset/bert-base-cased-squad2",
batch_size=16,
gpu=True,
task_type=task_type,
max_seq_len=384,
num_processes=num_processes,
doc_stride=128,
dummy_ph=False,
benchmarking=True)
inferencer.inference_from_dicts(input_dict)


def benchmark_single(batch_size, gpu, max_seq_len, doc_stride, document_size, question, modelname):
try:
input_dict = prepare_dict(sample_file, question, document_size)
Expand Down