Skip to content

Commit 570d0ca

Browse files
authored
Merge branch 'mlcommons:dev' into dev
2 parents 301c64d + 3a5743b commit 570d0ca

14 files changed

Lines changed: 345 additions & 99 deletions

File tree

.github/workflows/build_wheel_off.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
paths:
88
- VERSION
99

10+
1011
jobs:
1112
build_wheels:
1213
if: github.repository_owner == 'mlcommons'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright Notice
2+
3+
© 2026-2027 MLCommons. All Rights Reserved.
4+
5+
This file is licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License can be obtained at:
6+
7+
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
8+
9+
Unless required by applicable law or agreed to in writing, software distributed under the License is provided on an "AS IS" basis, without warranties or conditions of any kind, either express or implied. Please refer to the License for the specific language governing permissions and limitations under the License.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from mlc import utils
2+
from utils import is_true
3+
import os
4+
5+
6+
def preprocess(i):
7+
8+
os_info = i['os_info']
9+
10+
env = i['env']
11+
12+
if env.get('MLC_DATASET_DOWNLOAD_SRC', '') != "mlcommons":
13+
print("Using MLCommons Inference source from '" +
14+
env['MLC_MLPERF_INFERENCE_SOURCE'] + "'")
15+
downloader_path = os.path.join(
16+
env['MLC_MLPERF_INFERENCE_SOURCE'], 'automotive', 'llm', 'download_data.py')
17+
env['MLC_DATASET_MMLU_PATH'] = os.path.join(
18+
env.get('MLC_DATASET_MMLU_OUT_PATH', os.getcwd()), "mmlu.json")
19+
run_cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} {downloader_path} --output {env['MLC_DATASET_MMLU_PATH']}"
20+
if env.get('MLC_DATASET_MMLU_COUNT', '') != '':
21+
run_cmd += f" --count {int(env['MLC_DATASET_MMLU_COUNT'])})"
22+
23+
env['MLC_RUN_CMD'] = run_cmd
24+
25+
return {'return': 0}
26+
27+
28+
def postprocess(i):
29+
30+
env = i['env']
31+
32+
print(
33+
f"Path to the MMLU dataset: {env['MLC_DATASET_MMLU_PATH']}")
34+
35+
return {'return': 0}

script/get-dataset-mmlu/meta.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
alias: get-dataset-mmlu
2+
automation_alias: script
3+
automation_uid: 5b4e0237da074764
4+
cache: true
5+
deps:
6+
- names:
7+
- python
8+
tags: get,python
9+
skip_if_env:
10+
MLC_DATASET_DOWNLOAD_SRC: mlcommons
11+
- names:
12+
- automotive-src
13+
tags: mlperf,automotive,source
14+
skip_if_env:
15+
MLC_DATASET_DOWNLOAD_SRC: mlcommons # skip if download happens from mlc infrastructure
16+
- tags: get,generic-python-lib,_package.tqdm
17+
skip_if_env:
18+
MLC_DATASET_DOWNLOAD_SRC: mlcommons
19+
- tags: get,generic-python-lib,_package.datasets
20+
skip_if_env:
21+
MLC_DATASET_DOWNLOAD_SRC: mlcommons
22+
input_mapping:
23+
out_path: MLC_DATASET_MMLU_OUT_PATH
24+
new_env_keys:
25+
- MLC_DATASET_MMLU_PATH
26+
tags:
27+
- get-dataset-mmlu
28+
uid: 137c805565214b95
29+
variations:
30+
# calibration:
31+
# env:
32+
# MLC_IGBH_CALIBRATION_FLAG: --calibration
33+
no-of-samples.#:
34+
env:
35+
MLC_DATASET_MMLU_COUNT: '#'
36+
mlc:
37+
env:
38+
MLC_DATASET_DOWNLOAD_SRC: mlcommons

script/get-dataset-mmlu/run.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
#MLC Script location: ${MLC_TMP_CURRENT_SCRIPT_PATH}
4+
5+
#To export any variable
6+
#echo "VARIABLE_NAME=VARIABLE_VALUE" >>tmp-run-env.out
7+
8+
#${MLC_PYTHON_BIN_WITH_PATH} contains the path to python binary if "get,python" is added as a dependency
9+
10+
11+
12+
function exit_if_error() {
13+
test $? -eq 0 || exit $?
14+
}
15+
16+
function run() {
17+
echo "Running: "
18+
echo "$1"
19+
echo ""
20+
eval "$1"
21+
exit_if_error
22+
}
23+
24+
run "$MLC_RUN_CMD"

script/get-git-repo/customize.py

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
from mlc import utils
22
import os
33
import shutil
4+
from datetime import datetime
5+
import re
46

57

68
def preprocess(i):
79

810
os_info = i['os_info']
911

10-
# if os_info['platform'] == 'windows':
11-
# return {'return':1, 'error': 'Windows is not supported in this script
12-
# yet'}
13-
1412
env = i['env']
1513
meta = i['meta']
1614

@@ -83,10 +81,11 @@ def postprocess(i):
8381

8482
env['MLC_GET_DEPENDENT_CACHED_PATH'] = git_checkout_path
8583

86-
if os.path.exists("tmp-mlc-git-hash.out"):
87-
with open("tmp-mlc-git-hash.out", "r") as f:
88-
git_hash = f.readline().strip()
89-
env['MLC_GIT_REPO_CURRENT_HASH'] = git_hash
84+
version_string = generate_src_version_string(env)
85+
env['MLC_GIT_REPO_VERSION_STRING'] = version_string
86+
87+
if (env.get('MLC_GIT_REPO_VERSION_ENV_NAME', '') != ''):
88+
env[env['MLC_GIT_REPO_VERSION_ENV_NAME']] = version_string
9089

9190
return {'return': 0}
9291

@@ -109,3 +108,50 @@ def update_env(env, key, env_key, var):
109108
env[key.format(env_key)] = var
110109

111110
return
111+
112+
113+
def generate_src_version_string(env):
114+
"""
115+
Generates a descriptive version string including checkout state,
116+
date, short hash, and modifiers (PRs, cherry-picks, patches).
117+
"""
118+
119+
# 1. Base Components
120+
checkout = env.get("MLC_GIT_CHECKOUT", "unknown")
121+
sha = env.get("MLC_GIT_SHA", "00000000")
122+
123+
# Generate the date string (e.g., 20260224)
124+
# This uses the current build/checkout date.
125+
date_str = datetime.now().strftime("%Y%m%d")
126+
127+
# Sanitize checkout string (e.g., "feature/login" -> "feature-login")
128+
safe_checkout = re.sub(r'[^a-zA-Z0-9]', '-', checkout).strip('-').lower()
129+
short_sha = sha[:8]
130+
131+
# Start building the string parts: Branch + Date + Hash
132+
version_parts = [f"{safe_checkout}-{date_str}-g{short_sha}"]
133+
134+
# 2. Add Pull Request info
135+
pr = env.get("MLC_GIT_APPLIED_PR")
136+
if pr:
137+
# Extract just the numbers from the PR string
138+
pr_num = re.search(r'\d+', pr)
139+
pr_str = pr_num.group(0) if pr_num else "pr"
140+
version_parts.append(f"pr{pr_str}")
141+
142+
# 3. Add Cherry-pick info
143+
cps = env.get("MLC_GIT_APPLIED_CHERRYPICKS")
144+
if cps:
145+
cp_list = [cp for cp in cps.split(';') if cp.strip()]
146+
if cp_list:
147+
version_parts.append(f"cp{len(cp_list)}")
148+
149+
# 4. Add Patch info
150+
patches = env.get("MLC_GIT_APPLIED_PATCHES")
151+
if patches:
152+
patch_list = [p for p in patches.split(';') if p.strip()]
153+
if patch_list:
154+
version_parts.append(f"p{len(patch_list)}")
155+
156+
# Assemble the final string
157+
return "-".join(version_parts)

script/get-git-repo/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ new_env_keys:
2525
- MLC_GIT_CHECKOUT_PATH
2626
- MLC_GIT_REPO_*
2727
- <<<MLC_GIT_CHECKOUT_PATH_ENV_NAME>>>
28+
- <<<MLC_GIT_REPO_VERSION_ENV_NAME>>>
2829
post_deps:
2930
- dynamic: true
3031
enable_if_env:

script/get-git-repo/run.bat

Lines changed: 102 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,120 @@
11
@echo off
2-
3-
rem echo ******************************************************
4-
rem echo Cloning MLCommons from %MLC_GIT_URL% with branch %MLC_GIT_CHECKOUT% %MLC_GIT_DEPTH% %MLC_GIT_RECURSE_SUBMODULES% ...
5-
6-
rem git clone %MLC_GIT_RECURSE_SUBMODULES% %MLC_GIT_URL% %MLC_GIT_DEPTH% inference
7-
rem cd inference
8-
rem git checkout -b "%MLC_GIT_CHECKOUT%"
9-
rem
10-
11-
rem Next line allows ERRORLEVEL inside if statements!
122
setlocal enabledelayedexpansion
133

14-
set CUR_DIR=%cd%
15-
set SCRIPT_DIR=%MLC_TMP_CURRENT_SCRIPT_PATH%
4+
set "CUR_DIR=%CD%"
5+
echo %CUR_DIR%
6+
set "SCRIPT_DIR=%MLC_TMP_CURRENT_SCRIPT_PATH%"
7+
set "ENV_OUT_FILE=%CUR_DIR%\tmp-run-env.out"
168

17-
set folder=%MLC_GIT_CHECKOUT_FOLDER%
9+
set "folder=%MLC_GIT_CHECKOUT_FOLDER%"
1810

1911
if not exist "%MLC_TMP_GIT_PATH%" (
12+
if exist "%folder%" (
13+
echo rmdir /s /q "%folder%"
14+
rmdir /s /q "%folder%"
15+
)
16+
echo ******************************************************
17+
echo Current directory: %CUR_DIR%
18+
echo.
19+
echo Cloning %MLC_GIT_REPO_NAME% from %MLC_GIT_URL%
20+
echo.
21+
echo %MLC_GIT_CLONE_CMD%
22+
echo.
23+
24+
%MLC_GIT_CLONE_CMD%
25+
26+
:: Retry clone once on failure
27+
if ERRORLEVEL 1 (
28+
if exist "%folder%" rmdir /s /q "%folder%"
29+
%MLC_GIT_CLONE_CMD%
30+
if ERRORLEVEL 1 exit /b !ERRORLEVEL!
31+
)
32+
33+
:: /d ensures drive letter changes if necessary
34+
cd /d "%folder%"
2035

21-
if exist "%folder%" (
22-
rmdir /S /Q "%folder%" rem Use rmdir instead of deltree
23-
)
24-
25-
echo ******************************************************
26-
echo Current directory: %CUR_DIR%
27-
echo.
28-
echo Cloning %MLC_GIT_REPO_NAME% from %MLC_GIT_URL%
29-
echo.
30-
echo "%MLC_GIT_CLONE_CMD%"
31-
echo.
32-
33-
%MLC_GIT_CLONE_CMD%
34-
IF !ERRORLEVEL! NEQ 0 EXIT !ERRORLEVEL!
35-
36-
cd "%folder%"
37-
38-
if not "%MLC_GIT_SHA%" == "" (
39-
echo.
40-
echo.
41-
git checkout "%MLC_GIT_CHECKOUT%"
42-
IF !ERRORLEVEL! NEQ 0 EXIT !ERRORLEVEL!
43-
)
36+
if not "%MLC_GIT_SHA%"=="" (
37+
echo.
38+
echo git checkout -b %MLC_GIT_SHA% %MLC_GIT_SHA%
39+
git checkout -b %MLC_GIT_SHA% %MLC_GIT_SHA%
40+
if ERRORLEVEL 1 exit /b !ERRORLEVEL!
4441

42+
) else if not "%MLC_GIT_CHECKOUT_TAG%"=="" (
43+
echo.
44+
echo git fetch --all --tags
45+
git fetch --all --tags
46+
echo git checkout tags/%MLC_GIT_CHECKOUT_TAG% -b %MLC_GIT_CHECKOUT_TAG%
47+
git checkout tags/%MLC_GIT_CHECKOUT_TAG% -b %MLC_GIT_CHECKOUT_TAG%
48+
if ERRORLEVEL 1 exit /b !ERRORLEVEL!
49+
)
4550
) else (
46-
cd "%folder%"
51+
cd /d "%folder%"
4752
)
4853

49-
if not "%MLC_GIT_SUBMODULES%" == "" (
50-
for /F %%s in ("%MLC_GIT_SUBMODULES%") do (
54+
:: ---------------------------------------------------------
55+
:: Capture Checkout & SHA information
56+
:: ---------------------------------------------------------
57+
:: Determine the active branch name
58+
for /f "delims=" %%i in ('git rev-parse --abbrev-ref HEAD') do set "ACTUAL_CHECKOUT=%%i"
59+
60+
:: Fallback to detached HEAD hash
61+
if "%ACTUAL_CHECKOUT%"=="HEAD" (
62+
for /f "delims=" %%i in ('git rev-parse HEAD') do set "ACTUAL_CHECKOUT=%%i"
63+
)
64+
65+
for /f "delims=" %%i in ('git rev-parse HEAD') do set "CURRENT_SHA=%%i"
66+
67+
:: Write to out file (No space before >> prevents trailing spaces in value)
68+
echo MLC_GIT_CHECKOUT=!ACTUAL_CHECKOUT!>>"%ENV_OUT_FILE%"
69+
echo MLC_GIT_SHA=!CURRENT_SHA!>>"%ENV_OUT_FILE%"
70+
71+
:: ---------------------------------------------------------
72+
:: Apply PR, Cherry-picks, and Patches
73+
:: ---------------------------------------------------------
74+
if not "%MLC_GIT_PR_TO_APPLY%"=="" (
5175
echo.
52-
echo Initializing submodule %%s
53-
git submodule update --init %%s
54-
IF !ERRORLEVEL! NEQ 0 EXIT !ERRORLEVEL!
55-
)
76+
echo Fetching from %MLC_GIT_PR_TO_APPLY%
77+
git fetch origin %MLC_GIT_PR_TO_APPLY%:tmp-apply
78+
79+
:: Log the PR applied
80+
echo MLC_GIT_APPLIED_PR=%MLC_GIT_PR_TO_APPLY%>>"%ENV_OUT_FILE%"
5681
)
5782

58-
if "%MLC_GIT_PATCH%" == "yes" (
59-
for %%x in (%MLC_GIT_PATCH_FILEPATHS%) do (
60-
echo.
61-
echo Applying patch %%x ...
62-
git apply %%x
63-
IF !ERRORLEVEL! NEQ 0 EXIT !ERRORLEVEL!
64-
)
83+
if not "%MLC_GIT_CHERRYPICKS%"=="" (
84+
:: Log the cherry-picks applied
85+
echo MLC_GIT_APPLIED_CHERRYPICKS=%MLC_GIT_CHERRYPICKS%>>"%ENV_OUT_FILE%"
86+
87+
:: Replace semicolons with quoted spaces to safely loop in Windows
88+
set "CPS="%MLC_GIT_CHERRYPICKS:;=" "%""
89+
for %%c in (!CPS!) do (
90+
echo.
91+
echo Applying cherrypick %%~c
92+
git cherry-pick -n %%~c
93+
if ERRORLEVEL 1 exit /b !ERRORLEVEL!
94+
)
6595
)
6696

67-
cd "%CUR_DIR%"
97+
if not "%MLC_GIT_SUBMODULES%"=="" (
98+
set "SUBS="%MLC_GIT_SUBMODULES:;=" "%""
99+
for %%s in (!SUBS!) do (
100+
echo.
101+
echo Initializing submodule %%~s
102+
git submodule update --init --recursive --checkout --force "%%~s"
103+
if ERRORLEVEL 1 exit /b !ERRORLEVEL!
104+
)
105+
)
68106

69-
exit /b 0
107+
if "%MLC_GIT_PATCH%"=="yes" (
108+
:: Log the patches applied
109+
echo MLC_GIT_APPLIED_PATCHES=%MLC_GIT_PATCH_FILEPATHS%>>"%ENV_OUT_FILE%"
110+
111+
set "PATCHES="%MLC_GIT_PATCH_FILEPATHS:;=" "%""
112+
for %%p in (!PATCHES!) do (
113+
echo.
114+
echo Applying patch %%~p
115+
git apply "%%~p"
116+
if ERRORLEVEL 1 exit /b !ERRORLEVEL!
117+
)
118+
)
70119

120+
cd /d "%CUR_DIR%"

0 commit comments

Comments
 (0)