Skip to content

Commit 92be1df

Browse files
authored
Add GPT-OSS model download script (#728)
1 parent 6ca9ba1 commit 92be1df

File tree

3 files changed

+144
-0
lines changed

3 files changed

+144
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright Notice
2+
3+
© 2025-2026 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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 os_info['platform'] == "windows":
13+
return {'return': 1, 'error': 'Script not supported in windows yet!'}
14+
15+
path = env.get('MLC_ML_MODEL_GPT_OSS_PATH', '').strip()
16+
if path == '' or not os.path.exists(path):
17+
env['MLC_TMP_REQUIRE_DOWNLOAD'] = 'yes'
18+
19+
return {'return': 0}
20+
21+
22+
def postprocess(i):
23+
24+
env = i['env']
25+
26+
if env.get('MLC_DOWNLOAD_MODE', '') != 'dry':
27+
if env.get('MLC_DOWNLOAD_SRC', '') == 'mlc':
28+
env['MLC_ML_MODEL_FILE_WITH_PATH'] = env['MLC_ML_MODEL_GPT_OSS_PATH']
29+
elif env.get('MLC_DOWNLOAD_SRC', '') == 'huggingface':
30+
env['MLC_ML_MODEL_FILE_WITH_PATH'] = env['MLC_ML_MODEL_PATH']
31+
env['MLC_ML_MODEL_GPT_OSS_PATH'] = env['MLC_ML_MODEL_PATH']
32+
33+
return {'return': 0}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
alias: get-ml-model-gpt-oss
2+
automation_alias: script
3+
automation_uid: 5b4e0237da074764
4+
cache: true
5+
new_env_keys:
6+
- MLC_ML_MODEL_GPT_OSS_PATH
7+
- MLC_ML_MODEL_FILE_WITH_PATH
8+
print_env_at_the_end:
9+
MLC_ML_MODEL_GPT_OSS_PATH: GPT OSS model path
10+
input_mapping:
11+
checkpoint: MLC_ML_MODEL_GPT_OSS_PATH
12+
prehook_deps:
13+
- enable_if_env:
14+
MLC_TMP_REQUIRE_DOWNLOAD:
15+
- 'yes'
16+
MLC_DOWNLOAD_SRC:
17+
- 'huggingface'
18+
env:
19+
MLC_DOWNLOAD_FINAL_ENV_NAME: MLC_ML_MODEL_PATH
20+
extra_cache_tags: gpt-oss,gpt-oss-model
21+
force_env_keys:
22+
- MLC_GIT_CHECKOUT_FOLDER
23+
names:
24+
- hf-zoo
25+
tags: get,ml-model,huggingface,zoo,_clone-repo
26+
force_env_keys:
27+
- MLC_OUTDIRNAME
28+
tags:
29+
- get-ml-model-gpt-oss
30+
# Will be enabled after the r2 downloader link is added
31+
# tests:
32+
# needs_pat: true
33+
# run_inputs:
34+
# - variations_list:
35+
# - r2-downloader,mlc,dry-run
36+
uid: 562047f9667c4c09
37+
variations:
38+
dry-run:
39+
env:
40+
MLC_DOWNLOAD_MODE: dry
41+
group: run-mode
42+
dry-run,r2-downloader:
43+
env:
44+
MLC_DOWNLOAD_EXTRA_OPTIONS: -x
45+
hf:
46+
group: download-src
47+
env:
48+
MLC_DOWNLOAD_SRC: huggingface
49+
120b:
50+
env:
51+
MLC_GIT_CHECKOUT_FOLDER: gpt-oss-120b
52+
MLC_ML_MODEL_SIZE: 120b
53+
group: model-size
54+
default: true
55+
20b:
56+
env:
57+
MLC_GIT_CHECKOUT_FOLDER: gpt-oss-20b
58+
MLC_ML_MODEL_SIZE: 20b
59+
group: model-size
60+
mlc:
61+
default: true
62+
default_variations:
63+
model-size: 120b
64+
env:
65+
MLC_DOWNLOAD_SRC: mlcommons
66+
group: download-src
67+
prehook_deps:
68+
- enable_if_env:
69+
MLC_TMP_REQUIRE_DOWNLOAD:
70+
- 'yes'
71+
env:
72+
MLC_DOWNLOAD_FINAL_ENV_NAME: MLC_ML_MODEL_GPT_OSS_PATH
73+
MLC_EXTRACT_FINAL_ENV_NAME: MLC_ML_MODEL_GPT_OSS_PATH
74+
extra_cache_tags: ml,model,gpt-oss
75+
force_cache: true
76+
force_env_keys:
77+
- MLC_OUTDIRNAME
78+
names:
79+
- gpt-oss-model-dae
80+
tags: download-and-extract
81+
update_tags_from_env_with_prefix:
82+
_url.:
83+
- MLC_DOWNLOAD_URL
84+
r2-downloader:
85+
adr:
86+
gpt-oss-model-dae:
87+
env:
88+
MLC_DOWNLOAD_URL: ""
89+
tags: _r2-downloader
90+
default: true
91+
hf,120b:
92+
adr:
93+
hf-zoo:
94+
tags: _model-stub.openai/gpt-oss-120b
95+
env:
96+
MLC_MODEL_ZOO_ENV_KEY: GPT-OSS
97+
hf,20b:
98+
adr:
99+
hf-zoo:
100+
tags: _model-stub.openai/gpt-oss-20b
101+
env:
102+
MLC_MODEL_ZOO_ENV_KEY: GPT-OSS

0 commit comments

Comments
 (0)