Skip to content

Commit

Permalink
quality
Browse files Browse the repository at this point in the history
  • Loading branch information
mfuntowicz committed Mar 15, 2024
1 parent b83e125 commit 4a92318
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/optimum/nvidia/quantization/ammo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def from_description(
num_samples: int = 512,
max_sequence_length: int = 1024,
seed: int = 2016,
device: Union[str, torch.device] = "cpu"
device: Union[str, torch.device] = "cpu",
):
random.seed(seed)
np.random.seed(seed)
Expand All @@ -160,7 +160,7 @@ def from_description(
seqlen=max_sequence_length,
split=split,
seed=seed,
device=device
device=device,
)
else:
raise ValueError("Providing custom dataset is not yet supported")
Expand Down
3 changes: 1 addition & 2 deletions src/optimum/nvidia/quantization/ammo/quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def _loop():

for sample in tqdm(data):
inputs = {
name: tensor.to("cuda:0")
for name, tensor in sample.items()
name: tensor.to("cuda:0") for name, tensor in sample.items()
}
model(**inputs)

Expand Down
9 changes: 5 additions & 4 deletions src/optimum/nvidia/quantization/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@ def get_c4_new(
data[indexes]["text"],
truncation=True,
max_length=seqlen,
return_attention_mask=False
return_attention_mask=False,
)

dataset = [{
"input_ids": torch.tensor(tokens.ids, dtype=torch.long, device=device)
} for tokens in encodings.encodings]
dataset = [
{"input_ids": torch.tensor(tokens.ids, dtype=torch.long, device=device)}
for tokens in encodings.encodings
]

return dataset

Expand Down

0 comments on commit 4a92318

Please sign in to comment.