CTRL-GT-ORDER-0
CTRL-GT-ORDER-0 is the algebraic safe-gain global throttle. It computes directly from the current stability margin estimate, with no controller state. The firmware implementation uses a division-free candidate search over a table of binary-fraction alpha values to avoid ap_fixed division crashes in CSIM.
Definition
The controller enforces:
In squared-norm form (no division, no sqrt):
A precomputed table of binary-fraction candidates is searched in descending order. The first (largest) satisfying the inequality is selected; if none satisfy, :
table = {1.0, 0.875, 0.75, 0.625, 0.5, 0.375, 0.25, 0.1875, 0.125, 0.0625, 0.03125}
for each α_cand in table:
if α_cand² · η² · ||ΔG||² ≤ χ² · (||Δθ_raw||² + ε²):
α = α_cand (break)
else:
α = α_min (fallback)
Then:
Inputs
| Input | Meaning |
|---|---|
| raw optimizer update | |
| base learning rate | |
| curvature / sensitivity proxy | |
| target stability margin | |
| numerical guard |
Outputs
| Output | Meaning |
|---|---|
| global throttle scalar | |
| effective learning rate | |
| globally scaled update |
State
None.
Expected Behavior
This controller reacts immediately. If spikes, drops in the same step. The binary-fraction candidate set produces alpha values representable as shift-add combinations.
Known Failure Modes
- can oscillate if is noisy,
- can drive updates below the fixed-point quantum,
- coarse candidate spacing (11 values between 1.0 and 0.03125) may produce visible alpha steps; mitigated by adding more candidates at the cost of iteration cycles.
hls4ml Implementation
Architecture
GT-0 is implemented as two separate kernels in the three-phase batch_end block:
Phase 1 — Raw-update controller sensor (raw_update_sensor_order0, shared with GT-1):
nnet::raw_update_sensor_order0<CONFIG>(w_update, b_update, wgrad, bgrad,
&raw_update_norm_sq, &dgrad_norm_sq, reset);
Maintains static prev_weight_grad/prev_bias_grad. The controller no longer
uses actual/throttled parameter movement as its denominator. It uses the raw SGD
proposal before alpha:
For SGD, sgd.h computes Delta theta_raw = -learning_rate * gradient, so the
raw update norm already includes .
Phase 2 — Law (global_throttle_order0_law, called once with global sums):
The inequality
is evaluated directly on the squared norms — no division, no sqrt, no reciprocal.
An 11-entry candidate table (descending) is searched via a fully unrolled loop.
If no candidate satisfies the constraint, the law uses a nonzero minimum
candidate (0.03125, or a higher configured AlphaMin) and logs
controller_feasible = 0.
Phase 3 — Apply — shared across all controllers. The writer logs actual fixed-point movement after assignment separately as telemetry.
Controller parameters in config struct
The synthesized trainable_configN struct receives four
static constexpr double fields from the YAML Controller block:
| Field | YAML key | Default |
|---|---|---|
controller_chi | Chi | 1.5 |
controller_epsilon | Epsilon | 1e-12 |
controller_alpha_min | AlphaMin | 0.0 |
controller_alpha_max | AlphaMax | 1.0 |
These are emitted by vivado_writer.py:_make_trainable_dense_config.
Call-chain emission
The three-phase batch_end block:
if (batch_end) {
// Phase 1 — SGD proposal and raw-update norm reduction
metric_t global_raw_update_norm_sq = 0, global_dgrad_norm_sq = 0;
// (per Dense layer in backward order)
nnet::sgd<config>(wgrad, bgrad, w_update, b_update, lr);
{
metric_t __raw, __dg;
nnet::raw_update_sensor_order0<config>(w_update, b_update, wgrad, bgrad,
__raw, __dg, reset_accumulators);
global_raw_update_norm_sq += __raw;
global_dgrad_norm_sq += __dg;
}
// Phase 2 — Global controller law (division-free candidate search)
nnet::global_throttle_order0_law<config>(global_raw_update_norm_sq, global_dgrad_norm_sq,
alpha, reset_accumulators);
// Phase 3 — alpha-scaled apply per layer
metric_t actual_update_norm_sq;
nnet::apply_dense_update<config>(w, b, w_update, b_update, alpha, actual_update_norm_sq);
}
Implementation Status
The original division-based GT-0 law (α = χ / (η·C + ε)) crashed CSIM at step 1
because ap_fixed division in the two / lines caused unrecoverable errors.
The law was replaced with a division-free inequality candidate search over
binary-fraction alpha values. The raw-update geometry fix is tracked in
HLS4ML-039.