lllyasviel/Fooocus · error · ValueError
You cannot specify both input_ids and inputs_embeds at the s
Error message
You cannot specify both input_ids and inputs_embeds at the same time
What it means
NLVR encoder's BertModel forward rejects calls that provide both input_ids and inputs_embeds, because they are mutually exclusive ways of specifying the input sequence; supplying both is ambiguous.
Source
Thrown at extras/BLIP/models/nlvr_encoder.py:753
(those that don't have their past key value states given to this model) of shape :obj:`(batch_size, 1)`
instead of all :obj:`decoder_input_ids` of shape :obj:`(batch_size, sequence_length)`.
use_cache (:obj:`bool`, `optional`):
If set to :obj:`True`, :obj:`past_key_values` key value states are returned and can be used to speed up
decoding (see :obj:`past_key_values`).
"""
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
output_hidden_states = (
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
)
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
if is_decoder:
use_cache = use_cache if use_cache is not None else self.config.use_cache
else:
use_cache = False
if input_ids is not None and inputs_embeds is not None:
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
elif input_ids is not None:
input_shape = input_ids.size()
batch_size, seq_length = input_shape
device = input_ids.device
elif inputs_embeds is not None:
input_shape = inputs_embeds.size()[:-1]
batch_size, seq_length = input_shape
device = inputs_embeds.device
elif encoder_embeds is not None:
input_shape = encoder_embeds.size()[:-1]
batch_size, seq_length = input_shape
device = encoder_embeds.device
else:
raise ValueError("You have to specify either input_ids or inputs_embeds or encoder_embeds")
# past_key_values_length
past_key_values_length = past_key_values[0][0].shape[2] if past_key_values is not None else 0
View on GitHub (pinned to ae05379cc9)
Solutions
- Remove one of the two arguments from the call
- Sanitize kwargs in wrappers: kwargs.pop('input_ids', None) before forwarding embeddings
- Add a unit test asserting exactly one input source is passed
Example fix
// before loss = model(input_ids=ids, inputs_embeds=emb) // after loss = model(inputs_embeds=emb)
Defensive patterns
Strategy: validation
Validate before calling
sources = [k for k in ('input_ids', 'inputs_embeds') if locals().get(k) is not None]
assert len(sources) <= 1, f'conflicting inputs: {sources}' Prevention
- Pass inputs explicitly, not via kwargs dictionaries
- Pop unused input keys in wrapper layers
- Static-search codebases for calls with both arguments
When it happens
Trigger: encoder(input_ids=ids, inputs_embeds=emb) with both non-None, usually via **kwargs forwarding or incomplete refactors from ID-based to embedding-based inputs.
Common situations: Porting NLVR training code between BLIP repo versions; collators that always emit input_ids while the model code adds inputs_embeds.
Related errors
- You cannot specify both input_ids and inputs_embeds at the s
- You have to specify either input_ids or inputs_embeds or enc
- You have to specify either input_ids or inputs_embeds or enc
- checkpoint url or path is invalid
- The hidden size (%d) is not a multiple of the number of atte
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/07e59ec3bbbaf451.
Report an issue: GitHub.