Repository navigation
fix(auto): generate independent keys for unkeyed batch inputs - #3772
Merged
LauraGPT merged 1 commit intoOct 13, 2026
Merged
Conversation
Remember whether the caller supplied a key before iterating over batch items. Generate an automatic key for each non-path item instead of reusing the key generated for an earlier item or the preceding path basename. Preserve explicit keys and existing path-basename behavior. Add weights-free iterator and AutoModel.generate regressions for arrays, PCM bytes, mixed batches, and result dictionaries indexed by key.
hulkbig
marked this pull request as ready for review
October 12, 2026 16:28
LauraGPT
approved these changes
Oct 13, 2026
LauraGPT
left a comment
Collaborator
There was a problem hiding this comment.
Verified exact head 2e4eab4c531b45e14aac22e366dafd04b487d8d3 against base e7e61293d308f4342ab9307895e710e4b51b949c.
Independent weights-free validation reproduced the bug with the submitted regression tests on base (9 failed, 73 passed), then passed on this head (82 passed). The adjacent AutoModel/device/byte-loading selection passed 50 tests with 1 model-download test deselected, and compileall passed. The extracted source files matched the PR's Git blob IDs.
The change is limited to automatic result-key routing; it does not alter audio samples, decoding, model computation, or GPU runtime. Explicit keys and the existing path-basename behavior remain unchanged. I found no blocking issue in the patch.
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
Generate a fresh automatic key for each non-path item in a batch when no explicit
keywas supplied.prepare_data_iteratorcurrently assigns the first generated key to the loop'skeyvariable. Later array/byte items reuse it becausekeyis no longerNone. A path followed by an array similarly gives the array the preceding path's basename.Minimal reproduction at
e7e61293d308f4342ab9307895e710e4b51b949c:The same duplicate keys propagate through the real
AutoModel.generatewrapper with bothbatch_size=1andbatch_size=2. The result list still has two entries, but indexing it with{result["key"]: result for result in results}retains only the last entry. The regression tests exercise this using the repository's existing recording model.The fix captures whether a key was supplied before the loop, rather than checking a value that the loop mutates.
Type of change
Validation
python -m pytest -q tests/test_pcm_input_format.py tests/test_auto_model.py \ tests/test_auto_model_ncpu.py tests/test_submodel_device.py \ -k 'not test_merge_thr_in_cb_model' python -m compileall funasr examples tests git diff --checkBase production code with the new regression tests: 9 failed, 109 passed, 1 deselected, 2 subtests passed. All nine failures are the new automatic-key regressions.
Fixed code with the same selection: 118 passed, 1 deselected, 2 subtests passed.
Independent review repeated the selection in separate base/fixed checkouts and added
tests/test_load_audio_bytes.pywith outbound networking blocked: 9 failed, 123 passed, 1 deselected, 4 subtests passed on base; 132 passed, 1 deselected, 4 subtests passed after the fix. Another 70 boundary checks passed on both versions, and both checkouts passedcompileall.The deselected test downloads real model weights; it was not run.
Existing NumPy copy-keyword warnings also occur on the base checkout.
Linux x86_64, Python 3.12.14, PyTorch/torchaudio 2.8.0+cpu, NumPy 2.5.4.
Separately compared 26 unaffected input/key cases on base and fixed source with identical results, including explicit mixed-input keys and manifests. The URL dispatch control used a fake downloader, with no network request.
python -m compileall funasr examples testsDocs or links checked
Runtime/deployment command tested
User impact
Applications passing batches of NumPy waveforms or explicit PCM bytes receive independently generated sample identifiers. Converting those results to a key-indexed mapping no longer deterministically collapses the batch to one entry.
Notes for reviewers
key="session"producing repeated"session"keys and explicit empty strings.AutoModel.generaterouting for both batch sizes._RecordingModelreturns synthetic"ok"text; no ASR weights, recognition-quality benchmark, or GPU workload were run.DatadirWriterwarns and appends duplicate-key rows; the failure described here is downstream dictionary indexing, not overwriting by that writer.