Skip to content

Commit 24b7501

Browse files
Fix the AI comments except one
1 parent 51261e5 commit 24b7501

File tree

3 files changed

+2
-94
lines changed

3 files changed

+2
-94
lines changed

keras/src/models/model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,9 @@ def quantize(self, mode, **kwargs):
444444
)
445445

446446
config = kwargs.get("quant_config")
447-
print("Inside the model.py before the instance check")
448447
if not isinstance(config, GPTQConfig):
449448
raise TypeError(
450-
"When using 'gptq' mode, you must pass a `gptq_config` "
449+
"When using 'gptq' mode, you must pass a `quant_config` "
451450
"keyword argument of type `keras.quantizers.GPTQConfig`."
452451
)
453452

keras/src/models/model_test.py

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import io
21
import logging
32
import os
43
import pickle
5-
import tarfile
64
from collections import namedtuple
75

86
import numpy as np
97
import pytest
10-
import requests
118
from absl.testing import parameterized
12-
from datasets import load_dataset
139

1410
from keras.src import backend
1511
from keras.src import layers
@@ -27,93 +23,6 @@
2723
logging.basicConfig(level=logging.INFO)
2824

2925

30-
def get_dataset_text(dataset_identifier: str, nsamples=1000) -> str:
31-
"""
32-
Loads a specified dataset and extracts its text content into a
33-
single string.
34-
"""
35-
DATASET_CONFIGS = {
36-
"wikitext2": {
37-
"name": "wikitext",
38-
"config": "wikitext-2-raw-v1",
39-
"split": "test",
40-
"text_column": "text",
41-
},
42-
"ptb": {
43-
"name": "ptb_text_only",
44-
"config": "penn_treebank",
45-
"split": "validation",
46-
"text_column": "sentence",
47-
},
48-
"c4": {
49-
"name": "allenai/c4",
50-
"config": "en",
51-
"split": "validation", # Use validation for C4's test split
52-
"text_column": "text",
53-
},
54-
}
55-
56-
if dataset_identifier not in DATASET_CONFIGS:
57-
raise ValueError(
58-
f"Unknown dataset identifier '{dataset_identifier}'. "
59-
f"Available options are: {list(DATASET_CONFIGS.keys())}"
60-
)
61-
62-
config = DATASET_CONFIGS[dataset_identifier]
63-
64-
if dataset_identifier == "ptb":
65-
url = "http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz"
66-
try:
67-
# 1. Download the archive into memory
68-
response = requests.get(url)
69-
response.raise_for_status()
70-
71-
# 2. Extract only the test file from the in-memory archive
72-
with tarfile.open(
73-
fileobj=io.BytesIO(response.content), mode="r:gz"
74-
) as tar:
75-
test_path = "./simple-examples/data/ptb.test.txt"
76-
test_bytes = tar.extractfile(test_path).read()
77-
78-
# 3. Decode the bytes and join into a single string
79-
test_lines = test_bytes.decode("utf-8").strip().split("\n")
80-
all_text = "\n\n".join(test_lines)
81-
82-
print("✅ Successfully processed PTB test data.")
83-
return all_text
84-
85-
except Exception as e:
86-
print(f"Failed to download or process PTB data: {e!r}")
87-
raise e
88-
89-
load_kwargs = {"name": config["config"]}
90-
91-
if dataset_identifier == "c4":
92-
load_kwargs["streaming"] = True
93-
# For PTB, force a redownload to bypass potential cache errors.
94-
if dataset_identifier == "ptb":
95-
load_kwargs["download_mode"] = "force_redownload"
96-
97-
print(f"Loading dataset '{config['name']}'...")
98-
99-
test_data = load_dataset(
100-
config["name"], split=config["split"], **load_kwargs
101-
)
102-
103-
if dataset_identifier == "c4":
104-
print(f" -> Limiting C4 to the first {nsamples} documents forspeed.")
105-
test_data = test_data.take(nsamples)
106-
107-
all_text = "\n\n".join(
108-
row[config["text_column"]]
109-
for row in test_data
110-
if row.get(config["text_column"])
111-
)
112-
113-
print(f"Successfully loaded and processed {dataset_identifier}.")
114-
return all_text
115-
116-
11726
def _get_model():
11827
input_a = Input(shape=(3,), batch_size=2, name="input_a")
11928
input_b = Input(shape=(3,), batch_size=2, name="input_b")

keras/src/quantizers/gptqutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_dataloader(tokenizer, seqlen, dataset, nsamples=128, seed=0):
2929
if dataset == "wikitext2":
3030
d_name, d_config = "wikitext", "wikitext-2-raw-v1"
3131
elif dataset == "ptb":
32-
url = "http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz"
32+
url = "https://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz"
3333
try:
3434
# 1. Download the archive into memory
3535
response = requests.get(url)

0 commit comments

Comments
 (0)