From 9c838cba9b7c701f88c678473badf2c5c131b19b Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 28 Feb 2024 17:59:57 -0500 Subject: [PATCH] SPSA: tuning integers, raise C_curr to 0.50 to allow C_end below 0.50 Allows passing C_end as 0 for integer tunes for example, which ensures that no matter the iteration number, C_curr will be exactly 0.50. This is useful for tuning very small numbers which have great impact, like depths, or impactful but small weights. The formula for C_curr is C_end x (total_iters/curr_iters)^Gamma, where Gamma is usually 0.101 --- OpenBench/templatetags/mytags.py | 2 +- OpenBench/workloads/get_workload.py | 2 +- OpenBench/workloads/verify_workload.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenBench/templatetags/mytags.py b/OpenBench/templatetags/mytags.py index 5c04f97..9bd73a1 100644 --- a/OpenBench/templatetags/mytags.py +++ b/OpenBench/templatetags/mytags.py @@ -241,7 +241,7 @@ def spsa_param_digest(workload): param = workload.spsa['parameters'][name] # C and R if we got a workload right now - c = param['c'] / c_compression + c = max(param['c'] / c_compression, 0.00 if param['float'] else 0.50) r = param['a'] / r_compression / c ** 2 fstr = '%.4f' if param['float'] else '%d' diff --git a/OpenBench/workloads/get_workload.py b/OpenBench/workloads/get_workload.py index 08e1d5c..3b33e6d 100644 --- a/OpenBench/workloads/get_workload.py +++ b/OpenBench/workloads/get_workload.py @@ -276,7 +276,7 @@ def spsa_to_dictionary(test, workload): } # C & R are constants for a particular assignment, for all Permutations - spsa[name]['c'] = param['c'] / c_compression + spsa[name]['c'] = max(param['c'] / c_compression, 0.00 if param['float'] else 0.50) spsa[name]['r'] = param['a'] / r_compression / spsa[name]['c'] ** 2 for f in range(permutations): diff --git a/OpenBench/workloads/verify_workload.py b/OpenBench/workloads/verify_workload.py index e1c8cbe..eafae2f 100644 --- a/OpenBench/workloads/verify_workload.py +++ b/OpenBench/workloads/verify_workload.py @@ -252,11 +252,11 @@ def verify_spsa_inputs(errors, request, field): if not (float(minimum) <= float(value) <= float(maximum)): errors.append('Value must be within [Min, Max], for %s' % (name)) - if float(c) <= 0.00: - errors.append('C must be > 0.00, for %s' % (name)) + if data_type.strip() == 'float' and float(c) <= 0.00: + errors.append('C for floats must be > 0.00, for %s' % (name)) if float(r) <= 0.00: - errors.append('C must be > 0.00, for %s' % (name)) + errors.append('R must be > 0.00, for %s' % (name)) except: traceback.print_exc()