Skip to content

fix(codegen): handle bias formulas in numeric format SSOT (closes #1064) - #1065

Merged
gHashTag merged 2 commits into
masterfrom
fix/parser-bias-formula
Jun 13, 2026
Merged

fix(codegen): handle bias formulas in numeric format SSOT (closes #1064)#1065
gHashTag merged 2 commits into
masterfrom
fix/parser-bias-formula

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #1064.

Summary

The bias field in specs/numeric/formats_catalog.t27 can carry either a literal int or a rule-derived formula like 2^N-1. Two formats use the formula form: gf512 (bias 2^194-1), gf1024 (bias 2^390-1). Both were added by PR #1051 as limit-of-ladder phi-aligned formats. The codegen parser did int(bias_str) unconditionally, raised ValueError, and silently dropped both rows with a WARN: malformed CATALOG line log.

This is what caused the count drift documented in #1064: shipped gen/ JSON was 77, post-#1051 SSOT carries 83 raw lines, a fresh codegen re-run yielded only 81, paper #3 (arXiv:2606.09686) Table 1 claims 84.

Change

  • New parse_bias(s) -> (int, str) helper. Tries int(s); falls back to evaluating simple 2^N+offset forms when they fit in i64; otherwise returns sentinel -2 with the raw string preserved in a new bias_formula field.
  • Format dataclass gets bias_formula: str -- always populated with the raw SSOT string (even for literal-int rows, for symmetry).
  • All typed emitters (Rust struct, C header, TS interface, hpp, vh, etc.) continue to render the bias int field as before; the new bias_formula appears only in JSON and Python emitters via asdict(). Non-breaking for the typed emitters that hardcode their Format schema.

Verification

$ python3 tools/gen_formats_catalog.py specs/numeric/formats_catalog.t27 gen/numeric/
[...]
$ python3 -c "import json; print(json.load(open('gen/numeric/formats_catalog.json'))['count'])"
83

gf512 and gf1024 now appear in the regenerated JSON with bias=-2 and the formula preserved:

{"id": "gf512", "bits": 512, ..., "bias": -2, "bias_formula": "2^194-1", ...}
{"id": "gf1024", "bits": 1024, ..., "bias": -2, "bias_formula": "2^390-1", ...}

What this does NOT fix

This patch reconciles codegen with SSOT: both are now 83.

It does not reconcile SSOT vs paper #3 (84). That delta is the MXFP6 split (paper has MXFP6 E2M3 + MXFP6 E3M2 as separate rows; SSOT collapses into one mxfp6) and the standalone E8M0 block-scale row. Reconciliation options tracked in #1064:

  • patch SSOT to match paper (split MXFP6, add standalone E8M0) -> 85, then collapse one to land 84
  • file arXiv erratum to 2606.09686 updating Table 1 to 83
  • accept the audit-disclosed 83 as the ship number for playra/numeric-format-catalog v3 on HuggingFace

The CI invariant (grep -c '// CATALOG:' specs/numeric/formats_catalog.t27 == json.load('gen/numeric/formats_catalog.json')['count']) will land in a follow-up PR.

Refs


Filed by Trinity S3AI (gHashTag), 2026-06-10 +07

The bias field in formats_catalog.t27 can carry either a literal int or
a rule-derived formula like 2^N-1. Two formats use the formula form:

  gf512:  bias = 2^194-1
  gf1024: bias = 2^390-1

Both were added by PR #1051 as limit-of-ladder phi-aligned formats. The
parser did int(bias_str) unconditionally, which raised ValueError, so
both rows were silently dropped with a "malformed CATALOG line" warning.

This is why count drifted: committed gen/ JSON shipped 77 (pre-#1051),
post-#1051 SSOT carries 83 raw lines, codegen yielded 81 even after a
fresh re-run, paper #3 (arXiv:2606.09686) claims 84. Four sources of
truth, none matching. See issue #1064 for the full audit.

Fix:
- parse_bias(s) helper: tries int(); falls back to evaluating simple
  2^N+offset forms within int64 range; otherwise returns sentinel -2
  with the raw string in a new bias_formula field
- Format dataclass: adds bias_formula: str (preserves the raw SSOT
  string for every row, including the literal-int cases for symmetry)
- All existing emitters (Rust struct, C header, TS interface, Python,
  Markdown table, etc.) continue to render the int bias field as
  before; bias_formula appears only in JSON and python emitter where
  asdict() picks it up automatically -- non-breaking for the typed
  emitters that hardcode their Format schema.

Verification after fix:
  $ python3 tools/gen_formats_catalog.py specs/numeric/formats_catalog.t27 gen/numeric/
  $ python3 -c "import json; print(json.load(open('gen/numeric/formats_catalog.json'))['count'])"
  83

gf512 and gf1024 now appear in the JSON with bias=-2 and the formula
preserved in bias_formula. Downstream tools that need the actual i64
value can carry the string forward and evaluate at use-site (mpmath
or big-int arithmetic) without losing provenance.

This does NOT yet reconcile SSOT 83 vs paper #3 claim of 84; that
delta is the MXFP6 split + standalone E8M0 in Table 1 vs the SSOT's
collapsed mxfp6 row + Microscaling cluster layout. See #1064 for the
follow-up plan. The CI invariant (raw line count == JSON count) will
land in a separate PR.

Refs: #1051 (GF ladder expansion), #1063 (HF Discovery thread), #1064
@github-actions

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-06-10 11:45:58 UTC

Summary

Status Count
Total Open PRs 10
PRs with Failing Checks 7
PRs with All Checks Green 3
READY 2
FAILING 7
PENDING 0

PR #1065 originally committed regenerated gen/numeric/* outputs alongside
the source fix in tools/gen_formats_catalog.py. Per L2 generation rules,
gen/ artefacts must be auto-regenerated post-merge by ./scripts/tri gen,
not committed in source PRs.

This commit:
- reverts gen/numeric/* back to master state
- keeps the source fix (tools/gen_formats_catalog.py) intact
- adds docs/NOW.md entry per NOW Sync Gate

Closes #1064
@github-actions

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-06-13 14:18:32 UTC

Summary

Status Count
Total Open PRs 11
PRs with Failing Checks 8
PRs with All Checks Green 3
READY 2
FAILING 8
PENDING 0

@gHashTag
gHashTag merged commit cedbeaf into master Jun 13, 2026
21 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.

Catalog count drift: paper 84 / SSOT 83 / regen 81 / shipped gen 77 -- reconciliation plan

1 participant