from quark.common.profiler import GlobalProfilerfrom quark.torch import LLMTemplate, ModelQuantizer ckpt_path = "google/gemma-4-31B-it"output_dir = "/path/to/amd/gemma-4-31B-it-mxfp4" exclude_layers = ["*vision_tower*", "*multi_modal_projector*", "*lm_head"] if "gemma4" not in LLMTemplate.list_available(): gemma4_template = LLMTemplate( model_type="gemma4", kv_layers_name=["*language_model.*k_proj", "*language_model.*v_proj"], q_layer_name="*language_model.*q_proj", exclude_layers_name=exclude_layers, ) LLMTemplate.register_template(gemma4_template) template = LLMTemplate.get("gemma4")quant_config = template.get_config( scheme="mxfp4", exclude_layers=exclude_layers,) profiler = GlobalProfiler(output_path=f"{output_dir}/quark_profile.yaml")quantizer = ModelQuantizer(quant_config)quantizer.direct_quantize_checkpoint( pretrained_model_path=ckpt_path, save_path=output_dir,)