Skip to content

Commit 739af85

Browse files
committed
Refactor LiteRT-LM unsupported-tokenizer tests to @pytest.mark.xfail
- Removed expected_error_regex handling from run_litertlm_export_test. - Converted all test_litertlm_export_unsupported_tokenizer methods to normal export calls decorated with @pytest.mark.xfail. - Removed KERAS_BACKEND assignment from qwen3_moe and qwen_moe causal LM tests; backend is set externally per KerasHub testing convention.
1 parent 865c13a commit 739af85

13 files changed

Lines changed: 25 additions & 57 deletions

keras_hub/src/models/bloom/bloom_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ def test_litert_export(self):
176176
input_data=self.input_data,
177177
)
178178

179-
def test_litertlm_export_unsupported(self):
179+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
180+
def test_litertlm_export_unsupported_tokenizer(self):
180181
self.run_litertlm_export_test(
181182
cls=BloomCausalLM,
182183
init_kwargs=self.init_kwargs,
183184
prefill_seq_len=8,
184-
expected_error_regex='Cannot infer HuggingFace tokenizer family.*Supported families',
185185
)
186186

187187
@pytest.mark.extra_large

keras_hub/src/models/falcon/falcon_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ def test_litert_export(self):
176176
input_data=self.input_data,
177177
)
178178

179-
def test_litertlm_export_unsupported(self):
179+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
180+
def test_litertlm_export_unsupported_tokenizer(self):
180181
self.run_litertlm_export_test(
181182
cls=FalconCausalLM,
182183
init_kwargs=self.init_kwargs,
183184
prefill_seq_len=8,
184-
expected_error_regex='Cannot infer HuggingFace tokenizer family.*Supported families',
185185
)
186186

187187
@pytest.mark.extra_large

keras_hub/src/models/gpt_neo_x/gpt_neo_x_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ def test_litert_export(self):
124124
}, # More lenient thresholds for numerical differences
125125
)
126126

127-
def test_litertlm_export_unsupported(self):
127+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
128+
def test_litertlm_export_unsupported_tokenizer(self):
128129
"""GPT-NeoX tokenizer is not a supported LiteRT-LM family."""
129130
self.run_litertlm_export_test(
130131
cls=GPTNeoXCausalLM,
131132
init_kwargs=self.init_kwargs,
132133
prefill_seq_len=8,
133-
expected_error_regex="Cannot infer HuggingFace tokenizer family|Supported families are 'gpt2', 'llama3', and 'qwen3'",
134134
)

keras_hub/src/models/gpt_oss/gpt_oss_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ def test_litert_export(self):
121121
input_data=self.input_data,
122122
)
123123

124-
def test_litertlm_export_unsupported(self):
124+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
125+
def test_litertlm_export_unsupported_tokenizer(self):
125126
self.run_litertlm_export_test(
126127
cls=GptOssCausalLM,
127128
init_kwargs=self.init_kwargs,
128129
prefill_seq_len=8,
129-
expected_error_regex='Cannot infer HuggingFace tokenizer family',
130130
)
131131

132132
@pytest.mark.extra_large

keras_hub/src/models/opt/opt_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def setUp(self):
4545
self.train_data = ([" airplane at airport", " airplane at airport"],)
4646
self.input_data = self.preprocessor(*self.train_data)[0]
4747

48-
def test_litertlm_export_unsupported(self):
48+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
49+
def test_litertlm_export_unsupported_tokenizer(self):
4950
self.run_litertlm_export_test(
5051
cls=OPTCausalLM,
5152
init_kwargs=self.init_kwargs,
5253
prefill_seq_len=8,
53-
expected_error_regex='Cannot infer HuggingFace tokenizer family.*Supported families',
5454
)
5555

5656
def test_causal_lm_basics(self):

keras_hub/src/models/parseq/parseq_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def test_litert_export(self):
130130
output_thresholds={"*": {"max": 1e-3, "mean": 1e-4}},
131131
)
132132

133-
def test_litertlm_export_unsupported(self):
133+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
134+
def test_litertlm_export_unsupported_tokenizer(self):
134135
self.run_litertlm_export_test(
135136
cls=PARSeqCausalLM,
136137
init_kwargs=self.init_kwargs,
137138
prefill_seq_len=8,
138-
expected_error_regex='LiteRT-LM export supports.*tokenizers',
139139
)

keras_hub/src/models/qwen/qwen_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def test_litert_export(self):
125125
input_data=self.input_data,
126126
)
127127

128-
def test_litertlm_export_unsupported(self):
128+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
129+
def test_litertlm_export_unsupported_tokenizer(self):
129130
# Use a preprocessor with sequence_length >= prefill_seq_len so the
130131
# unsupported-tokenizer error is reached before cache-length checks.
131132
preprocessor = QwenCausalLMPreprocessor(
@@ -138,7 +139,6 @@ def test_litertlm_export_unsupported(self):
138139
cls=QwenCausalLM,
139140
init_kwargs=init_kwargs,
140141
prefill_seq_len=8,
141-
expected_error_regex="Cannot infer HuggingFace tokenizer family.*Supported families",
142142
)
143143

144144
@pytest.mark.extra_large

keras_hub/src/models/qwen3_5/qwen3_5_causal_lm_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def test_saved_model(self):
128128
input_data=self.input_data,
129129
)
130130

131-
def test_litertlm_export_unsupported(self):
131+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
132+
def test_litertlm_export_unsupported_tokenizer(self):
132133
# Use a preprocessor with sequence_length >= prefill_seq_len so the
133134
# unsupported-tokenizer error is reached before cache-length checks.
134135
preprocessor = Qwen3_5CausalLMPreprocessor(
@@ -141,7 +142,6 @@ def test_litertlm_export_unsupported(self):
141142
cls=Qwen3_5CausalLM,
142143
init_kwargs=init_kwargs,
143144
prefill_seq_len=8,
144-
expected_error_regex="Cannot infer HuggingFace tokenizer family.*Supported families",
145145
)
146146

147147
@pytest.mark.extra_large

keras_hub/src/models/qwen3_moe/qwen3_moe_causal_lm_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import os
21
from unittest.mock import patch
32

4-
os.environ["KERAS_BACKEND"] = "torch"
5-
63
import pytest
74
from keras import ops
85

@@ -131,12 +128,12 @@ def test_litert_export(self):
131128
input_data=self.input_data,
132129
)
133130

134-
def test_litertlm_export_unsupported(self):
131+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
132+
def test_litertlm_export_unsupported_tokenizer(self):
135133
self.run_litertlm_export_test(
136134
cls=Qwen3MoeCausalLM,
137135
init_kwargs=self.init_kwargs,
138136
prefill_seq_len=8,
139-
expected_error_regex='Cannot infer HuggingFace tokenizer family',
140137
)
141138

142139
@pytest.mark.extra_large

keras_hub/src/models/qwen_moe/qwen_moe_causal_lm_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import os
21
from unittest.mock import patch
32

4-
if "KERAS_BACKEND" not in os.environ:
5-
os.environ["KERAS_BACKEND"] = "jax"
6-
73
import keras
84
import pytest
95
from keras import ops
@@ -151,12 +147,12 @@ def test_litert_export(self):
151147
input_data=self.input_data,
152148
)
153149

154-
def test_litertlm_export_unsupported(self):
150+
@pytest.mark.xfail(reason="Tokenizer not supported for LiteRT-LM export")
151+
def test_litertlm_export_unsupported_tokenizer(self):
155152
self.run_litertlm_export_test(
156153
cls=QwenMoeCausalLM,
157154
init_kwargs=self.init_kwargs,
158155
prefill_seq_len=8,
159-
expected_error_regex='Cannot infer HuggingFace tokenizer family.*Supported families',
160156
)
161157

162158
@pytest.mark.extra_large

0 commit comments

Comments
 (0)