clip_by_norm

std.optim.clip_by_norm · Level L1

Gradient clipping by norm: the gradient scaled by min(1, max_norm/‖g‖), computed as max_norm/max(‖g‖, max_norm) so a zero gradient stays zero.

g · max_norm / max(‖g‖₂, max_norm)

Signature

clip_by_norm(grad: f64[n], max_norm: f64[]) → f64[n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

gradf64[n]max_normf64[]Multiplyg2ReduceSumsSqrtnormMaximumbigDividescaleMultiplyclippedclippedf64[n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference g * c / max(norm(g), c) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 156 float64 results inside the running error bound; the closest uses 43% of it.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 44% of it.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
71%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
1.39

Identity

Calls
—
Called by
—
sha256:e2b51d04ce79943f8a65ccad83b4670fe376512210468033dd555e809eef456a

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.optim.clip_by_norm · Ω:clip_by_norm
Pins
sha256:dfde5919c9d966dd9157b81aec53b539d9d6b99d03d8d86218207ff83f7487e4this graph alone
Evidence
sha256:9dd15ce78f870ae804f804b6a532932420f091b5f4cb836e89c65b8c127763afthe hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.