[fix] decide native-vs-transformers loading by directory name, not substring

"model" in args.load_from matched any path containing "model" (for
example a Hugging Face cache path or /data/models/...), so the scripts
loaded ./out/*.pth instead of the transformers checkpoint the user
passed. Compare the last path component with "model" instead.

Signed-off-by: YoungjuKim <fjvbn2003@gmail.com>
pull/889/head
YoungjuKim 2026-10-17 03:53:56 +09:00
parent f659b55761
commit cd36b4a013
No known key found for this signature in database
3 changed files with 4 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import os
import time
import argparse
import random
@ -11,7 +12,7 @@ warnings.filterwarnings('ignore')
def init_model(args):
tokenizer = AutoTokenizer.from_pretrained(args.load_from)
if 'model' in args.load_from:
if os.path.basename(os.path.normpath(args.load_from)) == 'model':
model = MiniMindForCausalLM(MiniMindConfig(
hidden_size=args.hidden_size,
num_hidden_layers=args.num_hidden_layers,

View File

@ -56,7 +56,7 @@ TEST_CASES = [
def init_model(args):
tokenizer = AutoTokenizer.from_pretrained(args.load_from)
if 'model' in args.load_from:
if os.path.basename(os.path.normpath(args.load_from)) == 'model':
model = MiniMindForCausalLM(MiniMindConfig(hidden_size=args.hidden_size, num_hidden_layers=args.num_hidden_layers, use_moe=bool(args.use_moe)))
moe_suffix = '_moe' if args.use_moe else ''
ckp = f'./{args.save_dir}/{args.weight}_{args.hidden_size}{moe_suffix}.pth'

View File

@ -27,7 +27,7 @@ app = FastAPI()
def init_model(args):
tokenizer = AutoTokenizer.from_pretrained(args.load_from)
if 'model' in args.load_from:
if os.path.basename(os.path.normpath(args.load_from)) == 'model':
moe_suffix = '_moe' if args.use_moe else ''
ckp = f'../{args.save_dir}/{args.weight}_{args.hidden_size}{moe_suffix}.pth'
model = MiniMindForCausalLM(MiniMindConfig(