Skip to content

bcpack_tables: the four width-9 tables match the MDU's own (BUILD-2010) - #6140

Open
slint6614-dev wants to merge 1 commit into
ItsNotRexed:mainfrom
slint6614-dev:fix/bcpack-width9-tables
Open

slint6614-dev wants to merge 1 commit into
ItsNotRexed:mainfrom
slint6614-dev:fix/bcpack-width9-tables

Conversation

@slint6614-dev

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: BUILD-2010 (claim)

What and why

tools/bcpack_tables.py PROB_TABLES[(9, q)] differed from FREQ_TABLE[8][q] in third_party/bcpack-rs/src/tables.rs for q = 8, 10, 13 and 14, by 1 to 3 in a few bands (@TG0000's finding). Both versions sum to 65,536 (band p weighted by its 2^(p-1) symbols), so no existing check could tell which one is wrong.

tables.rs says it is generated from mdu_minirans.v in microsoft/silicon-rans at 2f6827d, the MDU decoder's own tables. I read freq_table in that file at that commit: all 144 entries (widths 1-9, q 0-15) equal FREQ_TABLE, and the four width-9 entries are the bcpack-rs values, for example q = 14 is 31006, 16338, 6570, 1137 (the Python table had 31009, 16335, 6572, 1136). The other 140 Python entries already matched. So the Python side was off, probably from the fitting its docstring mentions, and this PR takes the hardware values:

(width, q) was now (MDU)
(9, 8) …, 1219, 1150, … …, 1221, 1149, …
(9, 10) …, 2054, 1625, … …, 2056, 1624, …
(9, 13) 12593, 10175, … 12594, 10174, …
(9, 14) 31009, 16335, 6572, 1136, … 31006, 16338, 6570, 1137, …

tests/test_bcpack_tables.py gets ProbTablesMatchHardware: every PROB_TABLES[(w, q)] for widths 1-9 must equal the first w + 1 entries of FREQ_TABLE[w - 1][q], read from tables.rs in the repository (no network). Width 10 is in PROB_TABLES only. The MDU tables stop at 9 alphabet bits, so there is nothing to compare it with, and this PR leaves it alone.

Unused today, as the finding says: the default lane widths are at most 8.

Tested

Linux (WSL2 Ubuntu 26.04), Python 3.14; no GPU or game files involved.

  • python -I tests/test_bcpack_tables.py: OK; under pytest, 35 passed and 144 subtests.
  • Negative control: the new test with main's tools/bcpack_tables.py fails exactly the four subtests (9, 8), (9, 10), (9, 13) and (9, 14).
  • tests/test_bcpack.py, test_bcpack_tables_bptc.py, test_bcpack_history_calib.py, test_calibrated_texture.py, test_calibrated_texture_extra.py: OK.
  • python -m compileall -q, git diff --check, tests/test_text_write_line_endings.py: OK.
  • The two open PRs that also change tools/bcpack_tables.py (ASSET-334: Add a standalone Rust BCPack DDS batch exporter #5303, ASSET-518: Report per-entry BCPack publication and fallback outcomes #6109) change other parts of it. That file merges cleanly with both (git merge-tree); they already conflict with main in tests/test_ttpf_assets.py.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not a translator change.)

🤖 Generated with Claude Code

https://claude.ai/code/session_013nWg6GaC13rCneTote8CNR

PROB_TABLES[(9, q)] for q = 8, 10, 13, 14 differed from FREQ_TABLE in
third_party/bcpack-rs, which is generated from Microsoft's mdu_minirans.v,
by 1 to 3 in a few bands. Both summed to 65536, so neither failed a check.
mdu_minirans.v at silicon-rans 2f6827d has the bcpack-rs values; take them,
and test every width 1-9 table against FREQ_TABLE so they stay in step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nWg6GaC13rCneTote8CNR
@thehollowedone

Copy link
Copy Markdown

Independent Windows CPU check of 06c8965c on 561b65a8. Windows x64, CPython 3.12.8.

An independent parse of the pinned Microsoft table found all 144 width-1–9 rows equal to the vendored Rust values and to the active Python entries. Width 10 has no corresponding hardware row in that source.

The selected BCPack, BPTC, history, calibrated-texture, and line-ending suites passed 119 tests. Two optional calibrated-texture checks skipped because NumPy was unavailable. Synthetic fixtures and public tables only. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 06c8965 merged with main 6adeaf0 on Linux/Python 3.12.16: pass

Commands run (merged worktree, -I isolated mode):

  • python -I tests/test_bcpack_tables.py -> Ran 35 tests, OK
  • Negative control: git checkout upstream/main -- tools/bcpack_tables.py, rerun -> FAILED (failures=4): the new test_widths_1_to_9_match_the_mdu_freq_table fails for the changed rows, e.g. main has (9, 8): (1282, 1256, 1219, 1150, ...) where the PR has (1282, 1256, 1221, 1149, ...). Restored with git checkout HEAD -- tools/bcpack_tables.py.

Diff read: the PR corrects a handful of probability-table entries (widths 9 rows such as (9, 8), (9, 10), (9, 13), (9, 14)) in tools/bcpack_tables.py, and the new test compares every width 1 to 9 entry with the 9 x 16 rows of FREQ_TABLE parsed from the vendored third_party/bcpack-rs/src/tables.rs. I did not check those rows against anything outside that vendored file.

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.

3 participants