Skip to content

RR F pack tool: the bias split's integer part as the runtime computes it - #268

Merged
phantoslayer21 merged 1 commit into
mainfrom
kspeed/rr-pack-signzero
Nov 16, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
kspeed/rr-pack-signzero

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

The RR F packing tool now uses the runtime's rounding for the bias split, so tools/pack_model.py and the runtime pack a model to the same bytes.

  • Each bias blob of the block stages is f32 [values | cb | cs]: cb is the nearest integer of the bias, cs the exact remainder. The tool took cb from numpy's round, which gives -0.0 for a value in [-0.5, 0); the runtime's host split (rr_pack.cpp rne_int) gives +0.0 there. On a real model this made test_model_pack.py report the bias blobs as different; values and remainders were already equal.
  • layout.rint_host follows the runtime's rule exactly (same integers; -0.0 keeps -0.0) and is used by bias_split and the score-bias split.
  • Values are unchanged. The kernels need only cb + cs = the value with |cs| <= 1/2, and the sign of a zero cb reaches no output. The runtime and the kernels are not changed.

Test: clean/rr_f/tests/test_layout_bias_split.py (constructed values: negatives in [-0.5, 0), -0.0, ties, extremes, non-finite, and the score-bias split through pack_weights), compared byte for byte with a line-for-line copy of the runtime's split.

…plit computes it (sign of zero)

layout.bias_split and pack_weights' score-bias split took cb = numpy round, which gives -0.0 for a value in [-0.5, 0);
the runtime's host split (rr_pack.cpp rne_int: floor, then up) gives +0.0 there, so tools/pack_model.py and the runtime
packed a real model differently in the cb words of the bias blobs (test_model_pack.py: 70 of 159 blobs). rint_host now
follows the runtime's rule exactly (same integers; -0.0 keeps -0.0). The kernels need only cb + cs = value and
|cs| <= 1/2, and the sign of a zero cb reaches no shipped output, so no runtime or kernel change.
Test: clean/rr_f/tests/test_layout_bias_split.py (constructed values: negatives in [-0.5, 0), -0.0, ties, extremes,
non-finite; the score-bias split).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21 phantoslayer21 added this to the 0.6.5 milestone Nov 16, 2026
@phantoslayer21
phantoslayer21 merged commit 5e32102 into main Nov 16, 2026
10 checks passed
@phantoslayer21
phantoslayer21 deleted the kspeed/rr-pack-signzero branch November 16, 2026 17:07
phantoslayer21 added a commit that referenced this pull request Nov 16, 2026
…release-0.6.1

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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