Skip to content

fix(infer): skip invalid dataset samples - #9848

Open
RerankerGuo wants to merge 1 commit into
modelscope:mainfrom
RerankerGuo:fix/skip-invalid-infer-samples
Open

fix(infer): skip invalid dataset samples#9848
RerankerGuo wants to merge 1 commit into
modelscope:mainfrom
RerankerGuo:fix/skip-invalid-infer-samples

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Fixes #7045.

Background

InferArguments.strict defaults to False, but SwiftInfer did not
propagate that setting to its inference engine. Template encoding
therefore still raised on the first invalid image, audio, or other
sample instead of allowing the remaining dataset to continue.

There was a second failure path when strict mode was disabled manually:
the engine returned the per-sample exception in its aligned response
list, and _batch_infer() attempted to access resp.choices, raising
AttributeError.

Changes

  • Propagate args.strict to the inference engine created by
    SwiftInfer.
  • Skip exception responses while assembling dataset inference results,
    with a warning that preserves the original error message.
  • Add CPU regression tests for strict-setting propagation and mixed
    valid/invalid batch results.

Verification

  • PYTHONPATH=. .venv/bin/python -m unittest tests.infer.test_infer_pipeline
  • PYTHONPATH=. .venv/bin/python tests/run.py --pattern test_infer_pipeline.py
  • PYTHONPATH=. .venv/bin/python -m unittest tests.infer.test_infer_pipeline tests.general.test_data_preprocess.TestProviderMessagesPreprocess tests.general.test_data_preprocess.TestRejectedMessagesPreprocess
  • .venv/bin/pre-commit run --all-files
  • git diff --check

Impact

The change affects dataset inference when strict=False. Valid samples
retain their existing outputs and labels; invalid samples are logged and
omitted from the result list. Strict inference and deployment behavior
remain unchanged.

Experiment results

Before the fix, the regression tests failed because the engine had no
propagated strict value and because an exception response was treated
as a normal completion. After the fix, both cases pass and valid samples
before and after the failed entry are preserved.

Propagate the inference strict setting to the engine and skip failed responses while preserving valid batch results.

Fixes modelscope#7045

Test: python -m unittest tests.infer.test_infer_pipeline
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

使用swift推理,当某个样本数据加载报错会直接中断其他的推理

1 participant