-
Notifications
You must be signed in to change notification settings - Fork 149
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
One shot user flow tweaks #2195
Conversation
test_stage:
obcq_modifiers:
QuantizationModifier:
ignore:
- Tanh
- GELUActivation
post_oneshot_calibration: true
scheme_overrides:
# For the embeddings, only weight-quantization makes sense
Embedding:
input_activations: null
weights:
num_bits: 8
symmetric: false
SparseGPTModifier:
sparsity: 0.0
quantize: true
targets: ["re:encoder.layer.\\d+$"]
from sparseml.transformers import oneshot
from sparseml import export
from transformers import AutoModel, AutoTokenizer
from datasets import load_dataset
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--recipe-path", type=str)
MODEL_ID = "sentence-transformers/all-MiniLM-L6-v2"
DATASET_ID = "neural-bridge/rag-dataset-12000"
NUM_SAMPLES = 512
if __name__ == "__main__":
args = parser.parse_args()
model = AutoModel.from_pretrained(MODEL_ID)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
ds = load_dataset(DATASET_ID, split="train")
ds = ds.shuffle(seed=42).select(range(NUM_SAMPLES))
ds = ds.rename_column("context", "text")
oneshot(
model=model,
tokenizer=tokenizer,
dataset=ds,
recipe=args.recipe_path,
output_dir="./minilm-int8-pt",
max_seq_length=model.config.max_position_embeddings,
concatenate_data=False,
)
export(model=model, integration="transformers", task="mlm", target_path="example_export")
python3 example.py --recipe-path recipe.yaml |
"Provide it manually using sequence_length argument" | ||
) | ||
if hasattr(model.config, "max_position_embeddings"): | ||
sequence_length = model.config.max_position_embeddings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a _LOGGER.info
here that you are using the default and what the value is
tokenized_dataset = self.get_dataset_split("calibration") | ||
if "labels" in tokenized_dataset.column_names: | ||
tokenized_dataset = tokenized_dataset.remove_columns("labels") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the issue here? if this is relatively safe to keep, then leave a comment on why this specific column needs to be removed
@@ -20,7 +20,7 @@ | |||
from sparseml.transformers.utils.preprocessing_functions import ( | |||
PreprocessingFunctionRegistry, | |||
) | |||
from sparsezoo.utils.helpers import import_from_path | |||
# from sparsezoo.utils.helpers import import_from_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this was giving you issue might be a sparsezoo version issue
Sorry - I didn't mean to put a PR on this ... I was just trying to hack something together. Will close |
Enables:
labels
are not allowed to be passed to BERT)helper_functions.create_data_loader
b/csequence_length
is calculated duringhelper_functions.create_model
, which does not run if amodel
is passed toexport
Also, there seems to be a stray import from sparsezoo which is failing