Repository navigation
test: size the slot-cap request from what the ledger accepts - #175
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nine DiffusionGemma tests compare float bits with frozen references. On the hosted macos-26 runner (Apple M1 VM) they differ in the low bits, with no change in shape, dtype or sign. Add a `.referenceHardware` Swift Testing trait that runs a test only when MLX_REFERENCE_HARDWARE=1, and mark the nine tests with it. Elsewhere they report as skipped with the reason. No assertion, tolerance or reference changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three gated tests also held checks that pass on any hardware. Split them so only the bit-for-bit comparison is gated: - prefixIdentityTokensOwnerAndEmptyStateFailClosed() runs its fail-closed probes on all hardware. The donor-logits bit comparison moves to failClosedProbesLeaveDonorLogitsBitExact(). - nativeFactoryLoadsExactStateAndReleasesItsModel() keeps the load and model-release checks on all hardware. The logits bit comparison moves to nativeFactoryDenoiseMatchesReferenceBits(). - The two parameterized vision tests run their bf16 case on all hardware. The fp32 case moves to a separate gated test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks done
davidtai
force-pushed
the
test/historical-window-slot-cap
branch
from
September 29, 2026 04:44
a763e8b to
aca2ba9
Compare
davidtai
changed the base branch from
main
to
test/gate-bit-exact-reference-tests
September 29, 2026 04:44
…a tests Split the three tests that were still gated whole, so their checks that pass on any hardware run everywhere: - chunkedSessionBoundsPrefillAndCanCancelAfterPrefill() keeps the prefill bounds, the complete flag, the counters, cancel, the emitted checkpoint and the released cache for widths 1, 3 and 7. The KV and logits bit comparisons move to chunkedSessionMatchesIndependentNativeReference(). - sharedWeightsConditioningKeepsCommittedCacheState() keeps the fixture checks, both cache positions and the unchanged encoder KV after the provisional canvas. The reference comparisons stay in sharedWeightsConditioningAndCommittedCacheMatchReference(). - committedPrefixRestoreKeepsPositionsAfterDonorRetirement() keeps the token count, retained bytes, donor release and both positions. The reference comparisons stay in committedPrefixRestoreIsExactAfterDonorAppendAndRetirement(). Each pair shares one helper. The fixture reference, case-count and parameter-count checks of the block and fp32 vision fixtures also run everywhere now, in blockOracleFixtureIsPinned() and fp32FixtureIsPinned(). CONTRIBUTING.md says which comparisons the gate covers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
slotCapLeavesRoomForServing() sized its request from bytesReserved. bytesReserved includes the paged pool's physical-floor overhead, which a request's target KV replaces when it reserves. The overhead depends on the buffer sizes the MLX allocator returns: a 36,864-byte segment gets a 49,152-byte buffer, or a 65,536-byte buffer reused from the process-wide cache. When earlier work left 64 KiB buffers in the cache, the capped arm left more than 5.5 windows of real slack instead of half a window, and the uncapped arm's reservation fit. Find the largest request the ledger accepts beside the capped set with trial reservations, then take half a window off it. The assertions do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
davidtai
force-pushed
the
test/historical-window-slot-cap
branch
from
September 29, 2026 05:06
aca2ba9 to
06224a8
Compare
This was referenced Sep 29, 2026
Gajesh2007
changed the base branch from
test/gate-bit-exact-reference-tests
to
main
October 2, 2026 22:48
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
HistoricalWindowCheckpointTests.slotCapLeavesRoomForServing()failed once on the hosted runner. It failed at!uncapped.reserved(#174 run 36513144872). The request size that the test printed was different on each machine:requestTokensCause
The test sized its request from
admissibleBytesCapacity - bytesReserved, with half a window (38,098 bytes) to spare. Then it gave the same request to an uncapped fixture with six more staged windows. It expected a refusal.bytesReservedis the ledger plus the physical-floor overhead:physical - nominal(AdmissionPhysicalFloor.swift:13-17,AdmissionV2.swift:401-403and1193-1197).AdmissionPhysicalFloor.swift:3-4). So the real slack is half a window plus the overhead.PagedKVSegments.swift:186-191,PagedKVPool+Segments.swift:178-190). Each segment needs 36,864 bytes. A new buffer has 49,152 bytes. A buffer reused from MLX's process-wide cache can have 65,536 bytes. So the overhead depends on what earlier tests left in the cache.The earlier guess was that a charge from earlier tests stayed in
bytesReserved. That guess was wrong. The charge belongs to the test's own pool. Only its size depends on the process-wide allocator cache. The product charges the real buffer size and refunds it correctly. The rule that a request's target KV replaces the overhead is by design. So no product code changes.Fix
The test now finds the largest request that the ledger accepts beside the capped set (the closure parameter is
candidate). It uses trialreserveandreleaseAllcalls in a binary search. Then it takes half a window off that size. No assertion changes. The capped request must still fit, and the uncapped arm must still refuse it.The first commit only formats the file with
.swift-format. The Lint job formats each changed file as a whole.Test plan
Local probe (not in this PR). Before the test, it fills the MLX buffer cache with 64 × 65,536-byte buffers (
seg64):requestTokensseg64!uncapped.reserved(3 of 3). Overhead 491,520 bytesseg64The request size no longer depends on the cache. The difference from main on a clean cache, 960 tokens (245,760 bytes), is the overhead that the old sizing counted.
HistoricalWindowCheckpointTestspasses all 20 tests locally. Local runs are only evidence for the ledger arithmetic here, not for numerics.slotCapLeavesRoomForServing()passed withrequestTokens=1045472.slotCapLeavesRoomForServing()passed withrequestTokens=1045472, the same value as on the laptop. The only failures were the nine DiffusionGemma bit-exact tests (112 issues) that test: run bit-exact reference tests only on reference hardware #174 gates. XCTest ran 999 tests with 0 failures.scripts/check_forkdiff.py --upstream-ref refs/remotes/upstream/main: passes.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes: the changed file is formatted withswift format format --configuration .swift-formatDependencies
Stacked on #174 (base
test/gate-bit-exact-reference-tests). Merge #174 first, then this PR. This PR's Fork Tests run contains both changes.Authorship
The commits were written by Claude Opus 5.5.
🤖 Generated with Claude Code