From 46b722842b726fa09feedd3ef394e7a75c107a70 Mon Sep 17 00:00:00 2001 From: datta0 Date: Sun, 1 Jun 2025 05:57:43 +0000 Subject: [PATCH] Make replacement logic conscise --- unsloth/models/_utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index f41f95a85f..0230f84565 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -217,12 +217,11 @@ def extract_approx_params_from_config(config): billions = float(match_B.group(1)) return int(1_000_000_000 * billions) else: - for fam in lowercase_b_families: - if fam in cleaned.lower(): - match_b = re.search(r"([0-9]+(?:\.[0-9]+)?)\s*b", cleaned) - if match_b: - billions = float(match_b.group(1)) - return int(1_000_000_000 * billions) + if any(fam in cleaned.lower() for fam in lowercase_b_families): + match_b = re.search(r"([0-9]+(?:\.[0-9]+)?)\s*b", cleaned) + if match_b: + billions = float(match_b.group(1)) + return int(1_000_000_000 * billions) else: match_any = re.search(r"([0-9]+(?:\.[0-9]+)?)\s*[bB]", cleaned) if match_any: