fix(infer): align adapter names with batch size - #9847
Open
RerankerGuo wants to merge 1 commit into
Open
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Replicate the selected LoRA adapter name, or the base adapter marker, for every sample in a TransformersEngine batch. Fixes modelscope#5285 Test: python -m unittest tests.infer.test_transformers_engine_adapters
RerankerGuo
force-pushed
the
fix/batch-adapter-names
branch
from
August 4, 2026 08:32
9b3a925 to
77fc950
Compare
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.
PR type
PR information
Fixes #5285.
Background
TransformersEngineaccepted oneAdapterRequestfor a batch, but_get_adapter_names()always returned a one-element list. PEFT requiresone adapter name per input, so batches larger than one failed with:
The same mismatch affected base-model inference after an adapter had
already been loaded because the
__base__marker was also returned onlyonce.
Changes
inference paths to
_get_adapter_names().__base__marker when running the base model after loadingan adapter.
Verification
PYTHONPATH=. .venv/bin/python -m unittest tests.infer.test_transformers_engine_adaptersPYTHONPATH=. .venv/bin/python tests/run.py --pattern test_transformers_engine_adapters.py.venv/bin/pre-commit run --all-filesgit diff --checkImpact
The change is limited to per-batch adapter-name construction in
TransformersEngine. Single-sample inference is unchanged, and theexisting API still applies one
AdapterRequestto the whole batch.Experiment results
Before the fix, both regression cases failed because
_get_adapter_names()could not produce batch-aligned names. After thefix, the selected adapter and
__base__paths return lists whose lengthsmatch the batch size; both tests pass.