Skip to content

inconsistent logits for identical inputs in batch (metal) #1941

Closed
@josharian

Description

@josharian

Summary

Given a beam search that contains two decoders with identical inputs (encoded state, past tokens), the same token is getting slightly different logits across those two beam searches.

This matters because (a) it hints that there's a bug somewhere and (b) the beam search de-dup logic assumes that logprobs will be identical for identical sequences.

It happens with metal, but not with cpu-only, suggesting a bug in the metal graph evaluation.

Reproduce

Run:

./main -m models/ggml-large-v2.bin sid5s.wav

Result:

<snip>
whisper_full_with_state: prompt[0] = [_SOT_]
whisper_full_with_state: prompt[1] = [_LANG_en]
whisper_full_with_state: prompt[2] = [_TRANSCRIBE_]

whisper_full_with_state: beam search: decoder 0: from decoder 0: token =    [_BEG_], plog = -0.11073, sum_logprobs = -0.11073
whisper_full_with_state: beam search: decoder 1: from decoder 0: token =    [_BEG_], plog = -0.11073, sum_logprobs = -0.11073
whisper_full_with_state: beam search: decoder 2: from decoder 0: token =    [_BEG_], plog = -0.11073, sum_logprobs = -0.11073
whisper_full_with_state: beam search: decoder 3: from decoder 0: token =    [_BEG_], plog = -0.11073, sum_logprobs = -0.11073
whisper_full_with_state: beam search: decoder 4: from decoder 0: token =    [_BEG_], plog = -0.11073, sum_logprobs = -0.11073
whisper_full_with_state: id =   0, decoder = 0, token =  50364, p =  0.895, ts =    [_BEG_],  0.895, result_len =    0 '[_BEG_]'
whisper_full_with_state: id =   0, decoder = 1, token =  50364, p =  0.895, ts =    [_BEG_],  0.895, result_len =    0 '[_BEG_]'
whisper_full_with_state: id =   0, decoder = 2, token =  50364, p =  0.895, ts =    [_BEG_],  0.895, result_len =    0 '[_BEG_]'
whisper_full_with_state: id =   0, decoder = 3, token =  50364, p =  0.895, ts =    [_BEG_],  0.895, result_len =    0 '[_BEG_]'
whisper_full_with_state: id =   0, decoder = 4, token =  50364, p =  0.895, ts =    [_BEG_],  0.895, result_len =    0 '[_BEG_]'
whisper_full_with_state: beam search: decoder 0: from decoder 0: token =      Great, plog = -0.66754, sum_logprobs = -0.77828
whisper_full_with_state: beam search: decoder 1: from decoder 4: token =      Great, plog = -0.66756, sum_logprobs = -0.77830
whisper_full_with_state: beam search: decoder 2: from decoder 4: token =      Thank, plog = -4.03217, sum_logprobs = -4.14290
whisper_full_with_state: beam search: decoder 3: from decoder 0: token =      Thank, plog = -4.03220, sum_logprobs = -4.14294
whisper_full_with_state: beam search: decoder 4: from decoder 2: token =          -, plog = -4.22957, sum_logprobs = -4.34030
<snip>

The lines of interest are

whisper_full_with_state: beam search: decoder 0: from decoder 0: token =      Great, plog = -0.66754, sum_logprobs = -0.77828
whisper_full_with_state: beam search: decoder 1: from decoder 4: token =      Great, plog = -0.66756, sum_logprobs = -0.77830

Observe that plog and sum_logprobs are slightly different. They should be identical; the sequences leading up to them are identical ([_SOT_], [_LANG_en], [_TRANSCRIBE_], [_BEG_]).

It does not reproduce when running with cpu only:

./main -m models/ggml-large-v2.bin -ng sid5s.wav

Relevant lines are:

whisper_full_with_state: beam search: decoder 0: from decoder 0: token =      Great, plog = -0.66892, sum_logprobs = -0.77950
whisper_full_with_state: beam search: decoder 4: from decoder 0: token =      Great, plog = -0.66892, sum_logprobs = -0.77950

The absolute values also differ across metal and cpu; I assume that this is expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions