Skip to content

Untied RN mode#11

Merged
pablooliveira merged 2 commits into
verificarlo:mainfrom
pablooliveira:untied-RN
Jun 29, 2026
Merged

Untied RN mode#11
pablooliveira merged 2 commits into
verificarlo:mainfrom
pablooliveira:untied-RN

Conversation

@pablooliveira

Copy link
Copy Markdown
Member

By setting z = rng::uniform() sample to 0.5; we get an untied round-to-nearest (tie away from zero) mode.
This PR implements such a mode and adds some tests.

During design a compromise arose:

  • we can achieve zero-hit performance by using a compile-time template to select between rng::uniform() and 0.5; yet this implies that the rounding mode is set once and for all at the beginning;
  • we can allow changing the rounding mode dynamically, which I would like to do in our LLM explorations, but this requires an IF branch.

In the end I decided to implement the IF branch since its overhead cost should be very low, we will pay the branch miss-prediction only the first time after a change of mode. Later the branch should be well predicted and have little overhead.

@yohanchatelain yohanchatelain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR! I agree with you about the low overhead and to have a dynamic switch is always more convenient to use.

@pablooliveira pablooliveira merged commit 03e951a into verificarlo:main Jun 29, 2026
5 checks passed
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.

2 participants