lllyasviel/Fooocus · error · ValueError
You have to specify either input_ids or inputs_embeds or enc
Error message
You have to specify either input_ids or inputs_embeds or encoder_embeds
What it means
NLVR encoder's forward requires one of input_ids, inputs_embeds, or encoder_embeds to infer input shape, batch size, and device; if all are None it raises this ValueError before any computation.
Source
Thrown at extras/BLIP/models/nlvr_encoder.py:767
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
if attention_mask is None:
attention_mask = torch.ones(((batch_size, seq_length + past_key_values_length)), device=device)
# We can provide a self-attention mask of dimensions [batch_size, from_seq_length, to_seq_length]
# ourselves in which case we just need to make it broadcastable to all heads.
extended_attention_mask: torch.Tensor = self.get_extended_attention_mask(attention_mask, input_shape,
device, is_decoder)
# If a 2D or 3D attention mask is provided for the cross-attention
# we need to make broadcastable to [batch_size, num_heads, seq_length, seq_length]
if encoder_hidden_states is not None:
if type(encoder_hidden_states) == list:
encoder_batch_size, encoder_sequence_length, _ = encoder_hidden_states[0].size()
else:View on GitHub (pinned to ae05379cc9)
Solutions
- Pass input_ids (or inputs_embeds / encoder_embeds) explicitly
- Assert the input tensor is not None right before the forward call
- Log which input source your pipeline chose in debug builds to catch silent None
Example fix
// before outputs = encoder(attention_mask=mask) // after assert ids is not None, 'input_ids missing from batch' outputs = encoder(input_ids=ids, attention_mask=mask)
Defensive patterns
Strategy: validation
Validate before calling
assert input_ids is not None or inputs_embeds is not None or encoder_embeds is not None
Prevention
- Check batch tensors for None before forward
- Keep one clear input-selection code path
- Name the chosen input source in debug logs
When it happens
Trigger: Calling the encoder with only auxiliary args (attention_mask, past_key_values, labels), or with an input tensor that a preprocessing step set to None.
Common situations: None tensors from a failing dataloader or tokenizer; refactors where encoder_embeds was renamed; wrapper code that conditionally builds inputs but all branches were skipped.
Related errors
- You cannot specify both input_ids and inputs_embeds at the s
- checkpoint url or path is invalid
- You cannot specify both input_ids and inputs_embeds at the s
- You have to specify either input_ids or inputs_embeds or enc
- 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/80f2505fa96b7207.
Report an issue: GitHub.