Skip to content

Improve LayerNorm reciprocal-square-root accuracy - #1667

Open
ollycassidy13 wants to merge 1 commit into
Xilinx:devfrom
ollycassidy13:feature/siglip-layernorm-rsqrt-refinement
Open

Improve LayerNorm reciprocal-square-root accuracy#1667
ollycassidy13 wants to merge 1 commit into
Xilinx:devfrom
ollycassidy13:feature/siglip-layernorm-rsqrt-refinement

Conversation

@ollycassidy13

Copy link
Copy Markdown

Improve LayerNorm reciprocal-square-root accuracy

Why

LayerNorm can operate on low-variance inputs where error in the existing reciprocal-square-root approximation becomes large enough to noticeably affect output accuracy in SigLip.

How

This adds an optional second Newton–Raphson refinement:
r = y × (1.5 - 0.5 × x × y²)

The refinement is implemented as a pipelined three-FMA FP32 datapath. The LayerNorm configuration exposes numRsqrtRefinements, defaulting to the existing single-refinement behavior, and updates latency and DSP estimates accordingly. An RTL simulation test verifies the improved result against the ONNX LayerNorm reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant