Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core][Frontend] Support Passing Multimodal Processor Kwargs #8657

Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
550378b
Allow for processor kwarg overrides
alex-jw-brooks Sep 16, 2024
190606f
Pass processor through to partial
alex-jw-brooks Sep 17, 2024
b1ca041
Add default & processor kwarg override tests
alex-jw-brooks Sep 17, 2024
195e31c
Don't allow ctx or inputs as kwargs
alex-jw-brooks Sep 17, 2024
1472d04
Add kwarg override for processor to dummy data factories
alex-jw-brooks Sep 17, 2024
f10601f
Add kwarg override forr processor to max token calc
alex-jw-brooks Sep 19, 2024
429097a
Move kwarg only override func to utils
alex-jw-brooks Sep 19, 2024
159cfc2
Force processor kwargs to be keyword-only
alex-jw-brooks Sep 19, 2024
af91930
Pass unfiltered processor kwargs to default mapper
alex-jw-brooks Sep 19, 2024
9adad10
Add hack for mapper preprocessor kwargs
alex-jw-brooks Sep 19, 2024
9f7aed8
Simplify dummy data processor kwarg & add tests
alex-jw-brooks Sep 19, 2024
ff59e44
Add tests for max multimodal token kwarg overrides
alex-jw-brooks Sep 19, 2024
6b26454
Format registry
alex-jw-brooks Sep 20, 2024
0e2d53d
Fix default mapper comparison
alex-jw-brooks Sep 20, 2024
5a3341b
Move kwarg filtering into hf processor getter
alex-jw-brooks Sep 20, 2024
3e1fe54
Enable processor_kwargs in video processor
alex-jw-brooks Sep 20, 2024
feccfd7
Add tests for mapper processor_kwargs
alex-jw-brooks Sep 20, 2024
3ada64d
Update mapper not on multimodal processor kwargs
alex-jw-brooks Sep 20, 2024
58dcc63
processor kwarg test cleanup
alex-jw-brooks Sep 20, 2024
1cee215
Move context builder to test utils
alex-jw-brooks Sep 19, 2024
d5f9efa
Use common context builder in processor kwarg tests
alex-jw-brooks Sep 20, 2024
b5d434b
Update vllm/entrypoints/llm.py
alex-jw-brooks Sep 22, 2024
a096301
Update vllm/inputs/registry.py
alex-jw-brooks Sep 22, 2024
79962e0
Update vllm/inputs/registry.py
alex-jw-brooks Sep 22, 2024
2cb1f72
Update vllm/inputs/registry.py
alex-jw-brooks Sep 22, 2024
37eb532
Update vllm/inputs/registry.py
alex-jw-brooks Sep 22, 2024
a4c7c3d
Update vllm/inputs/registry.py
alex-jw-brooks Sep 22, 2024
36dd2cb
Fix formatting
alex-jw-brooks Sep 22, 2024
f95c86f
Rename processor kwargs to mm processor kwargs
alex-jw-brooks Sep 22, 2024
229604f
Update docstring
DarkLight1337 Sep 22, 2024
2a48452
Merge branch 'main' into support_processor_kwargs
DarkLight1337 Sep 22, 2024
b732d72
Try to fix CUDA reinitialization error
DarkLight1337 Sep 22, 2024
844524a
Consolidate processor loading
DarkLight1337 Sep 23, 2024
2dd742b
Fix CUDA reinitialization error
DarkLight1337 Sep 23, 2024
ebc1c02
Simplify code
DarkLight1337 Sep 23, 2024
a7f32f5
Fix tests
DarkLight1337 Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add kwarg override for processor to dummy data factories
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
  • Loading branch information
alex-jw-brooks committed Sep 20, 2024
commit 1472d0438edc6ddebfc7fc8991c8504598d49718
26 changes: 26 additions & 0 deletions vllm/inputs/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ def __call__(
ctx: InputContext,
seq_len: int,
mm_counts: Mapping[str, int],
**processor_kwargs: Any,
) -> Tuple["SequenceData", Optional["MultiModalDataDict"]]:
"""
Create dummy data to be inputted into the model.

Note:
:data:`InputProcessor` is not applied to the dummy data.
The processor_kwargs are overrides provided at initialization
time to values in the config whose values may affect the number
of tokens per instance.
alex-jw-brooks marked this conversation as resolved.
Show resolved Hide resolved
"""
...

Expand Down Expand Up @@ -185,10 +189,17 @@ def dummy_data_for_profiling(
.get(model_cls, self._default_dummy_data_factory)
mm_counts = mm_registry.get_mm_limits_per_prompt(model_config)

# Check to see if this model expects additional processor kwargs;
# even though the processor isn't used on the dummy data, values
# passed to it that override the config may have implications on
# the number dummy data, e.g., the number of image tokens per instance.
df_kwargs = self._get_dummy_factory_processor_kwargs(
model_config, dummy_factory)
seq_data, mm_data = dummy_factory(
InputContext(model_config),
seq_len,
_MultiModalCounts(mm_counts),
**df_kwargs,
)

# Having more tokens is over-conservative but otherwise fine
Expand All @@ -207,6 +218,21 @@ def dummy_data_for_profiling(

return seq_data, mm_data

def _get_dummy_factory_processor_kwargs(
self, model_config: "ModelConfig",
dummy_factory: Callable) -> Dict[str, Any]:
# Dummy factory takes no additional kwargs; presumably this means that
# image processor kwargs have either not been implemented, or they have
# no affect on the token counts.
if len(inspect.signature(dummy_factory).parameters) < 4:
return {}
# Otherwise we may have overrides; filter them in the
# same way we filter the input processor overrides
return self._get_allowed_kwarg_overrides(
callable=dummy_factory,
overrides=model_config.processor_kwargs,
immutable_kwargs=("ctx", "seq_len", "mm_counts"))

def _default_input_processor(self, ctx: InputContext,
inputs: LLMInputs) -> LLMInputs:
"""The default input processor is a no-op."""
Expand Down