From 3b376ae2a444dd87c60abe0ce39925943143ed8a Mon Sep 17 00:00:00 2001 From: Giuseppe Zappia Date: Mon, 13 Oct 2025 09:35:54 -0600 Subject: [PATCH 1/3] fixed bug where new runs would always be 50 percent --- spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectrum.py b/spectrum.py index 62fe2a4..224ebd1 100644 --- a/spectrum.py +++ b/spectrum.py @@ -248,7 +248,7 @@ def main(): print(f"No existing SNR results file found for {args.model_name}. Proceeding with SNR calculation.") batch_size = input_dialog(title="Batch Size", text="Enter the batch size:").run() batch_size = int(batch_size) if batch_size else 1 - modifier = ModelModifier(model_name=args.model_name, batch_size=batch_size) + modifier = ModelModifier(model_name=args.model_name, batch_size=batch_size, top_percent=args.top_percent) selected_weight_types = modifier.interactive_select_weights() if selected_weight_types: modifier.assess_layers_snr(selected_weight_types) From 19964951712ade0932f04c163e0298e04e7933be Mon Sep 17 00:00:00 2001 From: Giuseppe Zappia Date: Mon, 13 Oct 2025 21:32:34 -0600 Subject: [PATCH 2/3] Added arguments for headless execution --- spectrum.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/spectrum.py b/spectrum.py index 224ebd1..9c4d917 100644 --- a/spectrum.py +++ b/spectrum.py @@ -234,6 +234,8 @@ def main(): parser = argparse.ArgumentParser(description="Process SNR data for layers.") parser.add_argument('--model-name', type=str, required=True, help='Model name or path to the model') parser.add_argument('--top-percent', type=int, default=None, help='Top percentage of layers to select, overriding the default') + parser.add_argument('--all-layer-types', type=bool, default=False, help='Whether to include all layers in selection') + parser.add_argument('--batch-size', type=int, default=None, help='Batch size to use in SnR calculation') args = parser.parse_args() # Check for existing SNR results file @@ -244,12 +246,29 @@ def main(): print(f"Found existing SNR results file for {args.model_name}") modifier = ModelModifier(top_percent=args.top_percent) modifier.generate_unfrozen_params_yaml(snr_file_path, args.top_percent) + + weight_types = modifier.get_weight_types() + print(weight_types) else: print(f"No existing SNR results file found for {args.model_name}. Proceeding with SNR calculation.") - batch_size = input_dialog(title="Batch Size", text="Enter the batch size:").run() + + if args.batch_size is None: + batch_size = input_dialog(title="Batch Size", text="Enter the batch size:").run() + else: + batch_size = args.batch_size + batch_size = int(batch_size) if batch_size else 1 + modifier = ModelModifier(model_name=args.model_name, batch_size=batch_size, top_percent=args.top_percent) - selected_weight_types = modifier.interactive_select_weights() + + if args.all_layer_types: + weight_types = modifier.get_weight_types() + print(f"selecting all weight types: {weight_types}") + selected_weight_types = modifier.sort_weight_types(weight_types) + modifier.layer_types = selected_weight_types + else: + selected_weight_types = modifier.interactive_select_weights() + if selected_weight_types: modifier.assess_layers_snr(selected_weight_types) modifier.save_snr_to_json() @@ -258,4 +277,4 @@ def main(): print("No weight types selected.") if __name__ == "__main__": - main() + main() \ No newline at end of file From 62683af5e2deef2b83644abd8a76672c0d59018a Mon Sep 17 00:00:00 2001 From: giuseppe-zappia <61301653+giuseppe-zappia@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:24:11 -0600 Subject: [PATCH 3/3] Update spectrum.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectrum.py b/spectrum.py index 9c4d917..da83d02 100644 --- a/spectrum.py +++ b/spectrum.py @@ -234,7 +234,7 @@ def main(): parser = argparse.ArgumentParser(description="Process SNR data for layers.") parser.add_argument('--model-name', type=str, required=True, help='Model name or path to the model') parser.add_argument('--top-percent', type=int, default=None, help='Top percentage of layers to select, overriding the default') - parser.add_argument('--all-layer-types', type=bool, default=False, help='Whether to include all layers in selection') + parser.add_argument('--all-layer-types', action='store_true', help='Whether to include all layers in selection') parser.add_argument('--batch-size', type=int, default=None, help='Batch size to use in SnR calculation') args = parser.parse_args()