Skip to content

Commit eedd68e

Browse files
Merge pull request #4438 from CIeNET-International:emma/fix-mistral-8x7b-e2e
PiperOrigin-RevId: 949026263
2 parents e190ed6 + 1fb4be1 commit eedd68e

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

src/maxtext/utils/globals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"qwen3.5-397b-a17b": "Qwen/Qwen3.5-397B-A17B",
8686
"qwen3.5-35b-a3b": "Qwen/Qwen3.5-35B-A3B",
8787
"mixtral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1",
88+
"mistral-7b": "mistralai/Mistral-7B-v0.1",
8889
"mixtral-8x22b": "mistralai/Mixtral-8x22B-Instruct-v0.1",
8990
"olmo3-7b": "allenai/Olmo-3-7B-Instruct",
9091
"olmo3-7b-pt": "allenai/Olmo-3-1025-7B",

tests/utils/forward_pass_logit_checker.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
import jax
7979
import jax.numpy as jnp
8080
from maxtext.configs import pyconfig
81-
from maxtext.utils.globals import MAXTEXT_TEST_ASSETS_ROOT
81+
from maxtext.utils.globals import MAXTEXT_TEST_ASSETS_ROOT, HF_IDS
8282
from maxtext.checkpoint_conversion.utils.hf_utils import convert_jax_weight_to_torch
8383
from maxtext.common.common_types import DECODING_ACTIVE_SEQUENCE_INDICATOR, MODEL_MODE_TRAIN
8484
from maxtext.layers import quantizations
@@ -232,13 +232,13 @@ def check_kl_divergence(model_logits, golden_logits, atol=0.02, clip_logits_epsi
232232

233233
def get_data(golden_data_point, config):
234234
"""Get the golden data for the test indexed at golden_data_index"""
235+
model_prefix = config.model_name.split("-")[0]
235236

236237
max_logging.log(f"config.global_batch_size_to_train_on={config.global_batch_size_to_train_on}")
237238
if config.use_multimodal:
238239
assert "pixel_values" in golden_data_point, "no image found in golden data while use_multimodal=True"
239240
pixel_values = np.asarray(golden_data_point["pixel_values"], dtype=np.float32)
240241
max_logging.log(f"pixel_values.shape = {pixel_values.shape}")
241-
model_prefix = config.model_name.split("-")[0]
242242
# Gemma3 and Gemma4 models expect (num_images, height, width, channels)
243243
if model_prefix in ["gemma3", "gemma4"]:
244244
if pixel_values.ndim == 2:
@@ -328,22 +328,28 @@ def main(config, test_args): # pylint: disable=W0621
328328
# 1. Pre-loaded golden logits comparison (multimodal input)
329329
# 2. On-the-fly HuggingFace model comparison (text only input)
330330
hf_token = config.hf_access_token
331-
try:
332-
if test_args.hf_model_path:
333-
max_logging.log(f"Loading tokenizer from {test_args.hf_model_path}.")
334-
tokenizer = AutoTokenizer.from_pretrained(
335-
test_args.hf_model_path, token=hf_token, trust_remote_code=test_args.trust_remote_code
336-
)
337-
else:
338-
max_logging.log(f"Loading tokenizer from {config.tokenizer_path}.")
339-
tokenizer = AutoTokenizer.from_pretrained(
340-
config.tokenizer_path, token=hf_token, trust_remote_code=test_args.trust_remote_code
341-
)
342-
except Exception as e: # pylint: disable=broad-except
343-
max_logging.log(f"Tokenizer loading error: {e}.\nLoading tokenizer from {config.tokenizer_path}.")
344-
tokenizer = AutoTokenizer.from_pretrained(
345-
config.tokenizer_path, token=hf_token, trust_remote_code=test_args.trust_remote_code
346-
)
331+
tokenizer_load_paths = []
332+
if test_args.hf_model_path:
333+
tokenizer_load_paths.append(test_args.hf_model_path)
334+
tokenizer_load_paths.append(config.tokenizer_path)
335+
336+
hf_model_id = HF_IDS.get(config.model_name)
337+
if hf_model_id:
338+
tokenizer_load_paths.append(hf_model_id)
339+
340+
tokenizer = None
341+
last_exception = None
342+
for path in tokenizer_load_paths:
343+
try:
344+
max_logging.log(f"Loading tokenizer from {path}.")
345+
tokenizer = AutoTokenizer.from_pretrained(path, token=hf_token, trust_remote_code=test_args.trust_remote_code)
346+
break
347+
except Exception as e: # pylint: disable=broad-except,broad-exception-caught
348+
last_exception = e
349+
max_logging.log(f"Failed to load tokenizer from {path}: {e}")
350+
351+
if tokenizer is None:
352+
raise last_exception
347353

348354
if config.model_name.startswith(("llama3.1", "mixtral")):
349355
tokenizer.pad_token = tokenizer.eos_token

0 commit comments

Comments
 (0)