This repository was archived by the owner on Jun 3, 2025. It is now read-only.
set embeddings weight QAT params to correct device in DP mode #1013
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
overwritten methods are not accounted for in the replica phase of torch DataParallel's forward pass, this causes an issue in sparseml's QAT of embeddings as embedding QAT buffers may not be on the correct device for an input in DP mode.
This PR introduces a temporary fix to send QAT values to the correct device for the forward pass. Future work should find a way to reconcile overwriting methods with torch DP/DDP as this is used/planned elsewhere in sparseml as well.
test_plan:
Tested failing command on multi-gpu environment against fix:
sparseml.transformers.question_answering --output_dir qa-models/sparse_quantized --model_name_or_path zoo:nlp/masked_language_modeling/bert-base/pytorch/huggingface/wikipedia_bookcorpus/12layer_pruned80_quant-none-vnni --recipe zoo:nlp/masked_language_modeling/bert-base/pytorch/huggingface/wikipedia_bookcorpus/12layer_pruned80_quant-none-vnni?recipe_type=transfer-question_answering --distill_teacher zoo:nlp/question_answering/bert-base/pytorch/huggingface/squad/base-none --dataset_name squad --per_device_train_batch_size 12 --per_device_eval_batch_size 24 --preprocessing_num_workers 6 --do_train --do_eval --evaluation_strategy epoch --fp16 --seed 21636 --per_device_train_batch_size 16 --per_device_eval_batch_size 24 --preprocessing_num_workers 6 --save_strategy no --save_total_limit 1