Skip to content

Implemented fixes in 2:4 sparsity tutorial #2616

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

Merged
merged 2 commits into from
Oct 24, 2023
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
6 changes: 4 additions & 2 deletions prototype_source/semi_structured_sparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ Now that those are defined, we just need one additional helper function, which w
We will get started by loading our model and tokenizer, and then setting up our dataset.

.. code:: python

# load model
model_name = "bert-base-cased"
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
Expand Down Expand Up @@ -344,6 +345,7 @@ Running the following code gives me an F1 score of 86.9. This is quite close to
training_args = transformers.TrainingArguments(
"trainer",
num_train_epochs=1,
lr_scheduler_type="constant",
per_device_train_batch_size=64,
per_device_eval_batch_size=512,
)
Expand Down Expand Up @@ -446,7 +448,7 @@ We will also evaluate the model to show the accuracy degradation of zero-shot pr
with torch.inference_mode():
predictions = trainer.predict(tokenized_squad_dataset["validation"])
pruned = compute_metrics(
*predictions.predictions
*predictions.predictions,
tokenized_squad_dataset["validation"],
squad_dataset["validation"],
)
Expand Down Expand Up @@ -498,7 +500,7 @@ Now that we have a model in this format, we can accelerate it for inference just
print("sparse eval metrics: ", metrics_sparse)
sparse_perf = measure_execution_time(
model,
batch_sizes_perf_cuda,
batch_sizes,
tokenized_squad_dataset["validation"],
)
print("sparse perf metrics: ", sparse_perf)
Expand Down