|
7 | 7 | # torchrun --nproc_per_node=2 ddp_qwen3_example.py \ |
8 | 8 | # --model Qwen/Qwen3-8B \ |
9 | 9 | # --nsamples 128 \ |
10 | | -# --iters 200 \ |
| 10 | +# --iters 100 \ |
11 | 11 | # --disable_torch_compile \ |
12 | 12 | # --deterministic |
13 | 13 | ############################################################################# |
|
19 | 19 | import torch |
20 | 20 | import torch.distributed as dist |
21 | 21 | from compressed_tensors.offload import dispatch_model, init_dist, load_offloaded_model |
22 | | -from datasets import load_dataset |
23 | 22 | from loguru import logger |
24 | 23 | from transformers import AutoModelForCausalLM, AutoTokenizer |
25 | 24 | import torch.distributed as dist |
26 | 25 | from llmcompressor import oneshot |
27 | | -from llmcompressor.datasets.utils import get_rank_partition |
28 | | -from llmcompressor.modifiers.autoround import AutoRoundModifier |
29 | 26 |
|
30 | 27 |
|
31 | 28 | def fix_everything(seed=42): |
@@ -87,14 +84,19 @@ def config_deterministic(): |
87 | 84 | ) |
88 | 85 | ################################## |
89 | 86 |
|
90 | | -tokenizer = AutoTokenizer.from_pretrained(model_name) |
| 87 | +tokenizer = AutoTokenizer.from_pretrained(model_id) |
91 | 88 |
|
92 | 89 | # Select calibration dataset. |
93 | 90 | NUM_CALIBRATION_SAMPLES = args.nsamples |
94 | 91 | MAX_SEQUENCE_LENGTH = 2048 |
95 | 92 | ITERS = args.iters |
96 | | -# Get aligned calibration dataset. |
97 | 93 |
|
| 94 | +# Make sure model are loaded before importing auto-round related code. |
| 95 | +# This requirement will be lifted once https://github.com/intel/auto-round/pull/1460 is merged. |
| 96 | +from llmcompressor.modifiers.autoround import AutoRoundModifier |
| 97 | + |
| 98 | +# Get aligned calibration dataset. |
| 99 | +from auto_round.calib_dataset import get_dataset |
98 | 100 | ds = get_dataset( |
99 | 101 | tokenizer=tokenizer, |
100 | 102 | seqlen=MAX_SEQUENCE_LENGTH, |
|
0 commit comments