Skip to content

[Bugfix][Model] Fix CohereASR FP16 attention bias dtype - #54399

Open
ActiveSky wants to merge 2 commits into
vllm-project:mainfrom
ActiveSky:codex/fix-54377-cohere-transcribe-fp16-bias
Open

ActiveSky wants to merge 2 commits into
vllm-project:mainfrom
ActiveSky:codex/fix-54377-cohere-transcribe-fp16-bias

Conversation

@ActiveSky

@ActiveSky ActiveSky commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #54377.

When Cohere Transcribe runs with --dtype float16 on Turing GPUs, the
relative-position biases can remain in torch.float32 while the query is in
torch.float16. Adding the bias promotes the query to FP32, and the following
matmul with the FP16 positional projection fails during engine initialization.

Cast both relative-position biases to the query dtype before the addition, and
add a CPU regression test for the mixed-dtype forward path.

Duplicate-work check

Testing

  • .venv/bin/python -m pytest tests/model_executor/test_cohere_asr.py -v (1
    passed)
  • pre-commit run --files vllm/model_executor/models/cohere_asr.py tests/model_executor/test_cohere_asr.py
    (passed)
  • pre-commit run mypy-3.12 --files vllm/model_executor/models/cohere_asr.py tests/model_executor/test_cohere_asr.py --hook-stage manual
    (passed)

AI assistance

AI assistance from OpenAI Codex was used to investigate the issue, implement the
change, and run the validation above. The human submitter must review every
changed line and be able to explain and defend the change end-to-end.

Cohere Transcribe can keep relative-position biases in fp32 while the query is fp16. Cast both biases to the query dtype before the attention matmuls so Turing GPU inference does not fail with a mixed dtype error.

Fixes vllm-project#54377

Co-authored-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: jikuixie <jikuixie@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added cohere Related to Cohere models bug Something isn't working labels Aug 30, 2026
@ekagra-ranjan

Copy link
Copy Markdown
Contributor

Hi @ActiveSky - thanks for the PR!

The issue was that the pos_bias variables were being casted to the dtype of the original weight rather than the runtime type decided by --dtype. A direct fix would be to remove this block of code during weight loading. I removed it and tried on H100 and it worked and the existing tests WER tests passed for cohere ASR.

Can you do that instead in this PR and confirm it works on your Turing GPU?

Keep relative-position bias buffers in the configured runtime dtype when loading checkpoint values. This prevents mixed-dtype attention matmuls on Turing GPUs and adds a regression test for the loading path.

Fixes vllm-project#54377

Co-authored-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: jikuixie <jikuixie@gmail.com>
@ActiveSky

ActiveSky commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ekagra-ranjan, thank you for the detailed diagnosis and for testing the alternative on H100. We checked the loading path and confirmed that the custom pos_bias conversion changes the shared relative-position bias buffers to the checkpoint dtype, overriding the runtime dtype. We updated this PR to remove that conversion and restored the original attention additions. We also added a regression test covering FP32 checkpoint values loaded into FP16 runtime buffers and a corresponding attention forward pass.

The focused test, .venv/bin/python -m pytest tests/model_executor/test_cohere_asr.py -v, passed, and the project pre-commit checks passed. The update is in commit fee8e03. Could you please take another look when convenient? Thank you again for your guidance.

@ekagra-ranjan ekagra-ranjan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - LGTM!

@ekagra-ranjan

Copy link
Copy Markdown
Contributor

@ActiveSky - after #55190 is merged, could you move the testfile you created in this PR to tests/models/multimodal/test_cohere_asr.py before we merge this PR?

@ActiveSky

Copy link
Copy Markdown
Contributor Author

Hi @ekagra-ranjan, thank you for the follow-up suggestion. We’ve noted it and will keep an eye on #55190. Once #55190 is merged, we’ll update this PR to move the test file to tests/models/multimodal/test_cohere_asr.py as recommended, before proceeding with the merge. Thank you again for your guidance.

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

Labels

bug Something isn't working cohere Related to Cohere models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Model] Cohere Transcribe fails to initialize on Turing (fp16): expected scalar type Float but found Half in RelPositionMultiHeadAttention

2 participants