Repository navigation
Keep each reader in the test reader trackers so the audio fault tests end the audio reader - #1886
Merged
Merged
Conversation
ReaderEnder named a reader by ObjectIdentifier and did not keep it. When a reader pass ends, its AVAssetReader is freed, and the next reader can get the same address. That reader then took the freed reader's ordinal and read count. In the MiMo audiovisual ingress tests, the audio reader took the ordinal of the video count reader, so the video frame reader became reader 2 and was ended instead of the audio reader. The tests then saw video_reader_failed and a video refusal. The outcome depended on the allocator, so #1867's PR runs passed and both dev runs after it failed. ReaderEnder now keeps every reader it sees and finds a reader by identity, so no two readers share an entry. SlowRead counts readers the same way, so a freed reader's address cannot hide a second reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
To be reverted before the PR is reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The loop (run 42337995996, job 128300096991) passed both tests in 30 of 30 iterations. This reverts commit d82b4f4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both test helpers kept each reader in first-read order and found it by identity, each with its own copy of the code and the comment. ReaderOrder now holds that rule once; ReaderEnder and SlowRead use it. Behavior and test assertions do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 of 16 tasks
This was referenced Nov 8, 2026
div0-space
pushed a commit
to LibraxisAI/mlx-swift-lm
that referenced
this pull request
Nov 29, 2026
ReaderEnder keyed its read counts by ObjectIdentifier and did not keep the readers. A freed reader's address can go to a later reader, which then takes the freed reader's ordinal and read count and can be ended on the wrong pass. testAudioReaderThatFailsTwiceThrowsItsFailure can fail this way when the retry reader gets the address of the reader that failed. ReaderOrder keeps every reader that reads, in first-read order, and matches readers with ===. This is the fix of Layr-Labs/d-inference#1886. No test assertion or call site changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch had an error being deployed
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.
Summary
devhas been red since #1867 merged. Two of its tests, the audio reader fault tests inMiMoV26EncodedAudiovisualIngressTests, failed on both push runs after the merge. The cause is the test helperReaderEnder, not the provider.ReaderEnderidentified each reader byObjectIdentifierand did not keep a reference to it. The allocator can give a newAVAssetReaderthe address of a reader that was freed, so the new reader took the old reader's ordinal and read count. The helper then ended the video frame reader instead of the audio reader. This PR makes the helper keep every reader it sees and find each reader by identity.Cause
MiMoV26EncodedMediaIngress.decoderuns its reader passes one at a time, in one task, always in this order:MiMoV26EncodedVisualDecoder.inspectVideocounts the video samples (reader 1).MiMoV26EncodedAudiovisualDecoder.decodereads the LPCM audio track (reader 2, inpassthroughPass).audiovisualFramesdecodes the video frames (reader 3).The passes do not run at the same time, and their order does not change. The production labels are correct:
passthroughPassand the AAC pass throwVideoReaderFailure(reader:medium: .audio), andVideoReaderFailureReportnames the operation fromfailure.medium.Reader 1 is freed when its pass returns. If reader 2 gets the same address,
ObjectIdentifier(reader2)equals the identifier of reader 1. Reader 2 then uses reader 1's entry: ordinal 1, with its read count already past 2. So reader 2 is never ended. The next new reader, the video frame reader, gets ordinal 2 (order.count + 1). The helper ends it at read 2, and the run reportsvideo_reader_failed. The address is reused only sometimes, so the PR runs of #1867 passed and the two dev runs failed.Evidence
22338b4b), job 128282254866:testAnAudioReaderThatFailsTwiceIsRefusedAsInvalidMediafailed.failure.mediumwasvideo, the refusal wasnative media input is unsupported or exceeds its bound, and the reports were twovideo_reader_failedpasses. In the same job,testAFailedAudioReaderPassIsReadAgainAndReportedpassed.1703f03a), job 128290701728:testAFailedAudioReaderPassIsReadAgainAndReportedfailed with[Pass(operation: "video_reader_failed", retrying: true, transient: false)]. In the same job,testAnAudioReaderThatFailsTwiceIsRefusedAsInvalidMediapassed.endedcounts were correct (1 and 2). This agrees with the address reuse: one reader was still ended, but it was the wrong reader.Fix
ReaderEnder(provider-swift/Tests/ProviderCoreTests/Inference/Vision/ReaderEnder.swift) keeps each reader in an array, in the order of its first read, and finds a reader with===. A reader that the helper keeps cannot be freed, so its address cannot go to a later reader. The ordinal is the reader's index plus 1. The API does not change, so the MiMo and Nemotron tests use the helper as before. All assertions stay as they were.SlowReadinNemotronSuperVideoReaderRetryTestscounted readers in aSet<ObjectIdentifier>, which has the same fault: address reuse can hide a second reader. It now keeps its readers in the same way.ReaderOrder(inReaderEnder.swift). It keeps each reader in the order of its first read and counts its reads.The production code does not change.
Linked issue
None. This fixes the
devfailure that came after #1867.Test plan
f3d1f4d8is green: both Provider Unit Tests shards, the Provider Tests gate and Check the CI plans. Shard 1 passed both MiMo audio reader tests. In attempt 1, the shard 2 runner lost contact with GitHub during "Set up runner", before checkout and before any test ran. Attempt 2 of that job passed. The fix before the refactor (d3e40e93) was green in run 42339081354. The two Vercel deployments failed; they also failed on Decode a video again when its reader fails, and keep the cause #1851 and Read a MiMo audio track again when its reader fails, and keep the cause #1867, and this PR does not touch the landing or console code.d82b4f40ran the two tests 30 times in shard 1, each time in a newswift test --skip-buildprocess on the built products. Run 42337995996, job 128300096991:LOOP: 30/30 iterations passed both tests. In the same job the full shard also passed both tests. On that commit, "Check the CI plans" failed only becauseProviderCIWorkflowTestscompares the workflow'srun:lines to a fixed list and the loop step added one.d3e40e93reverts the loop commit, so its tree is the same as the fix commit892b58d4.python3 scripts/docs-impact-check.pywith the changed files andpython3 scripts/changelog.py checkpass. Nothing was built or tested on the laptop.Components touched
Protocol / interface changes
Documentation impact
Changelog
changelog.d/<topic>.mdfragment and ranmake changelog-check.Notes for reviewers
Tests/MLXLMTests/ReaderPassFaults.swiftin Layr-Labs/mlx-swift-lm). This fix does not need a fork change, so this PR does not change the fork. In the fork,testAudioReaderThatFailsTwiceThrowsItsFailureends readers 1 and 2. If the retry reader gets the address of the reader that failed first, that test can fail in the same way. The fork can get the same change in a separate PR.Refactor Pass
Done by a separate refactor reviewer. Result: one cleanup, in commit
f3d1f4d8.ReaderEnderandSlowReadeach had their own copy of the reader-tracking code and of the comment about address reuse. The bug was in exactly that code. The new typeReaderOrderholds it once, and both helpers use it.🤖 Generated with Claude Code