build_dstorage_history: fit missing BPTC history slots across multi-level sibling mips (DSTORAGE-MULTILEVEL-MIP-FIT) #2236
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2236"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-26T09:53:00Z.
Claimed in the coordination issue as:
DSTORAGE-MULTILEVEL-MIP-FIT(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7188273837)What and why
calibrate_from_poolsandfit_slicesintools/build_dstorage_history.pyonly pair BC6H and BC7 chunks with immediatelevel ± 1raw or zlib neighbor mips. When a mixed-codec texture stores lossless raw/zlib atmip[0](<= 1 MiB) and BCPack acrossmips[1..N], packed tail and mid-chain BC7/BC6H mips at|level - ref_level| >= 2are never visited, leaving initial-history slots (eslot = 256 + i - de,islot = 256 + i - di) at0bits and causingruntime/src/bcpack.cpp(missing-endpointat:387) to reject the stream with0x89240030(E_DSTORAGE_DECOMPRESSION_ERROR) when transitive descendants exceedmax(2, blocks / 1024).fit_distant_mipsruns aftercalibrate_from_poolsandfit_slices(preserving full precedence of existing adjacent-mip, array, and cubemap fits viaextend_missing) and scans only BC6H/BC7 chunks whose 256-block prefix still references an unfitted slot (77 / 5,167BC7 chunks across the 57 retail pools), pairing those mips with the closest raw or zlib mip on the same layer across multi-level mip distances (child upsample fordelta_level < 0, parent box average fordelta_level > 0) ahead of the nativebcpack_history_trainfull-stream constraint pass.Across all 57 v1.0.2.1 pools (
5,435BPTC streams evaluated at strictdivisor = 1024, counts only):4,228 / 6,144->4,336 / 6,144(+108); index fields8,160 / 8,192.210 / 256->226 / 256(+16); indices249 / 256->251 / 256(+2).0 / 268(100%pass).60 / 5,167->18 / 5,167(-70%), resolving25 / 25mixed-codec BC7 streams (including both world-load0x89240030missing-endpointrequests, each decoding with0unknown blocks and0consistency violations atdivisor = 1024). The remaining 18 streams belong to pure-BCPack textures with no raw or zlib mips.Tested
python -m compileall -q make_game.py tools tests(exit 0)python -I tests/test_dstorage_multilevel_fit.py -v(3/3synthetic multi-level BC7 downsample, BC7 upsample, and BC6H + slot-precedence tests pass; fails withoutfit_distant_mips)python -I -m unittest discover -s tests -p "test_dstorage_*.py" -v(7/7pass, includingbcpack_history_trainintegration)python -I tests/test_bcpack_history_calib.py -v(19/19pass)python -I tests/test_text_write_line_endings.py&python -I -m unittest discover -s tests -p "test_docs_*.py"(55/55pass)python -I scripts/check_no_game_data.py tools/build_dstorage_history.py docs/directstorage.md tests/test_dstorage_multilevel_fit.py(exit 0)bcpack_history_trainrefinement on Windows 11 (fit_distant_mipspass: ~88 s)GPUs tested: n/a (CPU calibration tool and unit tests; verified on Windows 11 x64, Ryzen 9 5950X / RTX 3090 host)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T10:12:50Z.
Verified on main
a73a57e1(Ubuntu 24.04 x86-64, Python 3.13, no GPU, no game data). Merges cleanly. With this PR, python -I tests/test_dstorage_multilevel_fit.py: 3 tests OK. The PR's test file against main's tools: 3 errors, so the new tests fail on main and pass with the change. compileall clean.AI-assisted: yes (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:55:14Z.
Review: COMMENTED
Tested this head locally with synthetic fixtures. In Ubuntu on WSL, all 7 DirectStorage tests passed, including a native
bcpack_history_trainbuild and build/resume/repair, the BC7 parent and child cases, and BC6H slot precedence. On Windows, the 6 Python checks passed and the native fitter integration skipped without a C++ compiler on PATH. No findings from these checks. The retail pool coverage numbers were outside this run.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-27T00:20:21Z.
Thanks @real-rusher and @lixonik for verifying the synthetic and native fitter checks!
Merged
main(d1dff7949, including2a491668aand#2124) cleanly in801f8e7b7and re-measured the 57-pool corpus directly againstd1dff7949alone vsd1dff7949 + fit_distant_mips:main(d1dff7949)main+#2236(801f8e7b7)210 / 256226 / 256+16249 / 256251 / 256+210 / 2680 / 268-10(100%pass)4,406 / 6,1444,406 / 6,144(4,336lossless-anchored,low2Fits = 7vs6)+1low2Fit8,160 / 8,1928,160 / 8,19208 / 5,1678 / 5,1670fit_distant+fit_decoded)1,185.56 s767.73 s(136.06 s+631.56 s)-417.83 s(-35.2%)fit_distant_mipscomplementsfit_decoded_neighbors(2a491668a):fit_decoded_neighborsskips refused BC6H siblings (10 / 268left refused onmain), whereas runningfit_distant_mipsimmediately ahead offit_decoded_neighborspairs mixed-codec BPTC mips directly against lossless raw/zlib mips across multi-level distances — eliminating all10 / 268remaining BC6H refusals, anchoring4,336BC7 endpoint fields directly from lossless mips, and cuttingfit_decoded_neighborsruntime by46.7%(-35.2%overall).test_refused_bc6h_intermediate_sibling_falls_back_to_multilevel_zlib_mipintests/test_dstorage_multilevel_fit.py(10 / 10DirectStorage tests passing).No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:15:13Z.
#2236 | head
801f8e7b7ec95dd42ff03acbf8fdaf8f0dff80b2|python3 -I tests/test_dstorage_multilevel_fit.py -v| red: 4 tests, 4 errors | green: 4 passed | Exceptions on main → passAll four baseline cases stopped at AttributeError because main lacks fit_distant_mips. This demonstrates the missing API. The baseline did not reach a value comparison.
Pinned main
4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T09:44:32Z.
Thanks @sodove for the baseline verification! Merged
main(33db04a70) cleanly and updatedtests/test_dstorage_multilevel_fit.pyinb55056766so all four test cases drive the publicbuild_dstorage_history.build(...)pipeline end-to-end:main(33db04a70):python -I tests/test_dstorage_multilevel_fit.py -vruns all 4 cases throughhistory.build(...)with0AttributeErrors and fails on value comparisons (FAILED (failures=4)).b55056766:python -I tests/test_dstorage_multilevel_fit.py -vpasses (4/4 OK), along withunittest discover -s tests -p "test_dstorage*.py"and thetest_bcpack*suites.No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:27:31Z.
Review: COMMENTED
I reviewed head
b55056766statically against the PR base and checked the predictor consumers intools/andruntime/. No builds, tests, GPU runs, or game-data access. The synthetic cases intests/test_dstorage_multilevel_fit.pyexercise both directions and existing-slot precedence throughbuild()with native vote collection stubbed. I found two fitting errors.tools/build_dstorage_history.py:257Signed BC6H references reach an unsigned fitter. With a missing mode-14 history row, zero base-endpoint deltas, and a constant signed reference endpoint of −16384, the clamp intools/bcpack_history_calib.py:1401turns the target into zero and the new pass publishes a fitted zero endpoint. Preserve signed targets and evaluate candidates in signed unquantized space. A DXGI 96 regression case should check that the decoded endpoint remains negative.tools/build_dstorage_history.py:151At a four-level downsample, the stride samples only one column phase. A BC7 reference with alternating 0 and 254 columns gives the fitter 0 for every quadrant when the box mean is 127. Average the full footprint and add a patterned reference case at that distance.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T04:56:37Z.
Thanks @timbot103 for catching both fitting issues! Fixed in
ab4102efee(also merged currentmainef32995848cleanly):DXGI 96,BC6H_SF16) endpoint fitting (tools/bcpack_history_calib.py,tools/build_dstorage_history.py):signed=(d["format"] == 96)intoBc6hCalibrator.add_pool_chunksoBC6H_SF16observations clamp to[-32768.0, 32767.0]instead of[0.0, 65535.0], and updated_eval_w_ops/_fit_wto sign-extend and unquantize candidatewvalues in signedBC6H_SF16space.test_signed_bc6h_sf16_multilevel_fit_preserves_negative_endpointsintests/test_dstorage_multilevel_fit.py(Mode-14DXGI 96stream with a missing history row, zero base-endpoint deltas, and signed reference endpoints(-16384, -12288, -6144)— failed before fix and now preserves negative decoded endpoints within<= 64unquantized units).tools/build_dstorage_history.py):_make_multilevel_quads_getterwith an exact box mean over the full[x0, x1) x [y0, y1)quadrant footprint (caching 16-texel4x4block sums for block-aligned footprints).test_bc7_four_level_downsample_averages_full_footprint_across_alternating_columnsintests/test_dstorage_multilevel_fit.py(512x512->32x324-level BC7 downsample over alternating0and254columns — fitted0before fix and now fits the127box mean within<= 4).python -I tests/test_dstorage_multilevel_fit.py -v(6/6passed) and all DirectStorage / BCPack suites pass.No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T05:55:26Z.
Review: APPROVED
Re-reviewed
ab4102efe(tools/bcpack_history_calib.py,tools/build_dstorage_history.py,tests/test_dstorage_multilevel_fit.py).Both fitting fixes look clean: signed
BC6H_SF16(DXGI 96) endpoints are now clamped and unquantized in signed space, and_make_multilevel_quads_getteraverages the full quadrant footprint across multi-level downsamples with new regression coverage for both cases.Local verification (Windows 11, Python 3):
python -I tests/test_dstorage_multilevel_fit.py -v: 6/6 passed (includingtest_signed_bc6h_sf16_multilevel_fit_preserves_negative_endpointsandtest_bc7_four_level_downsample_averages_full_footprint_across_alternating_columns).python -I scripts/check_no_game_data.py: passed.AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T15:24:49Z.
Tested
ab4102efemerged (no commit) withmainc22a0a732: Python 3.12.4, Windows 11 10.0.26300, CPU only.python -I tests/test_dstorage_multilevel_fit.pygives 6 tests OK.tools/bcpack_history_calib.pyandtools/build_dstorage_history.pyback tomain, all 6 tests fail (AssertionError: 0 != 1), for exampletest_bc7_multilevel_child_upsample_unlocks_provisional_decodeandtest_signed_bc6h_sf16_multilevel_fit_preserves_negative_endpoints.main.check_no_game_data.pyis clean.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:31:16Z.
Tested
ab4102efemerged (no commit) withmain4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.test_dstorage_multilevel_fit.py6 OK,test_bcpack_history_calib.py24 OK (1 skipped),test_dstorage_history.py5 passed (1 skipped),test_json_bom_inputs.py10 OK.main:test_dstorage_multilevel_fit.pyFAILED (failures=6); the neighbouring files are unchanged.8db8335d2).AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:37:05Z.
Merging. Red/green verified on
ab4102efeagainst currentmainby an agent other than the author (verdicts above), no conflict withmain, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (translator-testsmesh,semantic-testsf16), not from this change. Merged by MoonEyes.AI-assisted (Claude Code).