3737from pathlib import Path
3838
3939import modelopt .torch .nas as mtn
40- import modelopt .torch .puzzletron .mip .mip_and_realize_models as mip_and_realize_models
41- import modelopt .torch .puzzletron .mip .sweep as sweep
40+ import modelopt .torch .puzzletron as mtpz
4241import modelopt .torch .utils .distributed as dist
43- from modelopt .torch .puzzletron .nas .plugins .puzzletron_nas_plugin import PuzzletronModel
44- from modelopt .torch .puzzletron .tools .hydra_utils import (
45- initialize_hydra_config_for_dir ,
46- register_hydra_resolvers ,
47- )
48- from modelopt .torch .puzzletron .tools .logger import mprint
4942
5043
5144def parse_args ():
@@ -74,26 +67,26 @@ def run_full_puzzletron(hydra_config_path: str):
7467 Args:
7568 config_path: Path to the YAML configuration file
7669 """
77- mprint ("Puzzletron Progress 1/8: starting puzzletron pipeline" )
70+ mtpz . tools . mprint ("Puzzletron Progress 1/8: starting puzzletron pipeline" )
7871 dist .setup (timeout = timedelta (minutes = 10 ))
7972
8073 # Register Hydra custom resolvers (needed for config resolution)
81- register_hydra_resolvers ()
74+ mtpz . tools . register_hydra_resolvers ()
8275
8376 hydra_config_path = Path (hydra_config_path ).resolve ()
8477 hydra_config_dir = str (hydra_config_path .parent )
8578 hydra_config_name = hydra_config_path .stem
8679
8780 # Load hydra config
88- hydra_cfg = initialize_hydra_config_for_dir (
81+ hydra_cfg = mtpz . tools . initialize_hydra_config_for_dir (
8982 config_dir = hydra_config_dir ,
9083 config_name = hydra_config_name ,
9184 overrides = [],
9285 )
9386
9487 # Convert model (convert from HF to DeciLM, score pruning activations,
9588 # prune the model and save pruned checkpoints)
96- input_model = PuzzletronModel ()
89+ input_model = mtpz . puzzletron_nas_plugin . PuzzletronModel ()
9790 converted_model = mtn .convert (
9891 input_model ,
9992 mode = [
@@ -120,7 +113,7 @@ def run_full_puzzletron(hydra_config_path: str):
120113 )
121114
122115 dist .cleanup ()
123- mprint ("Puzzletron Progress 8/8: puzzletron pipeline completed (multi-gpu)" )
116+ mtpz . tools . mprint ("Puzzletron Progress 8/8: puzzletron pipeline completed (multi-gpu)" )
124117
125118
126119def run_mip_only (hydra_config_path : str ):
@@ -135,33 +128,33 @@ def run_mip_only(hydra_config_path: str):
135128 dist .setup (timeout = timedelta (minutes = 10 ))
136129
137130 # Register Hydra custom resolvers (needed for config resolution)
138- register_hydra_resolvers ()
131+ mtpz . tools . register_hydra_resolvers ()
139132
140133 hydra_config_path = Path (hydra_config_path ).resolve ()
141134 hydra_config_dir = str (hydra_config_path .parent )
142135 hydra_config_name = hydra_config_path .stem
143136
144137 # Load hydra config
145- hydra_cfg = initialize_hydra_config_for_dir (
138+ hydra_cfg = mtpz . tools . initialize_hydra_config_for_dir (
146139 config_dir = hydra_config_dir ,
147140 config_name = hydra_config_name ,
148141 overrides = [],
149142 )
150143
151144 # Check if sweep mode is enabled
152145 if hasattr (hydra_cfg .mip , "sweep" ) and hydra_cfg .mip .sweep .get ("enabled" , False ):
153- mprint (
146+ mtpz . tools . mprint (
154147 "Puzzletron Progress 7/8: running MIP sweep for multiple compression rates (multi-gpu)"
155148 )
156- sweep .run_mip_sweep (hydra_cfg )
149+ mtpz . mip .run_mip_sweep (hydra_cfg )
157150 else :
158151 # mip_and_realize_models (distributed processing)
159152 # TODO: How to make it part of mnt.search() api, similarly to run_full_puzzletron() API
160- mprint ("Puzzletron Progress 7/8: running MIP and realizing models (multi-gpu)" )
161- mip_and_realize_models .launch_mip_and_realize_model (hydra_cfg )
153+ mtpz . tools . mprint ("Puzzletron Progress 7/8: running MIP and realizing models (multi-gpu)" )
154+ mtpz . mip .launch_mip_and_realize_model (hydra_cfg )
162155
163156 dist .cleanup ()
164- mprint ("Puzzletron Progress 8/8: puzzletron pipeline completed (multi-gpu)" )
157+ mtpz . tools . mprint ("Puzzletron Progress 8/8: puzzletron pipeline completed (multi-gpu)" )
165158
166159
167160def main ():
0 commit comments