vllm - ✅(Solved) Fix [Bug]: JAIS: ALiBi is applied even when position_embedding_type="learned" [2 pull requests, 3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#37400Fetched 2026-04-08 00:57:42
View on GitHub
Comments
3
Participants
3
Timeline
21
Reactions
0
Author
Timeline (top)
referenced ×7cross-referenced ×5commented ×3labeled ×2

Fix Action

Fixed

PR fix notes

PR #37411: fix(jais): only apply ALiBi when position_embedding_type is 'alibi'

Description (problem / solution / changelog)

Summary

Fixes #37400

In JAISAttention.__init__, ALiBi slopes were computed and passed to Attention unconditionally, regardless of position_embedding_type. This caused models with position_embedding_type="learned" to apply both learned positional embeddings (wpe) and ALiBi simultaneously.

Changes

Added a conditional check in JAISAttention.__init__:

if config.position_embedding_type == "alibi":
    alibi_slopes = _get_alibi_slopes(total_num_heads)
    alibi_slopes = alibi_slopes[head_start:head_end]
else:
    alibi_slopes = None

This is consistent with how JAISModel already handles wpe — only creating learned position embeddings when position_embedding_type != "alibi".

Testing

  • Verified the fix is consistent with the existing wpe guard in JAISModel
  • No functional tests added as this requires a JAIS model checkpoint to test

Changed files

  • vllm/model_executor/models/jais.py (modified, +5/-2)

PR #37474: jais: only enable ALiBi when position_embedding_type == "alibi"

Description (problem / solution / changelog)

Summary This change fixes a correctness issue in the JAIS model implementation where the ALiBi positional bias was unconditionally constructed and applied even when the model configuration used learned positional embeddings. Applying both learned positional embeddings and an ALiBi bias results in double positional encoding, which can lead to incorrect attention behavior for JAIS variants configured with learned positional embeddings.

What I changed File: vllm/model_executor/models/jais.py Change: ALiBi slopes are now only computed and passed to the Attention layer when the HF config explicitly sets position_embedding_type == "alibi". When position_embedding_type is other values (e.g., "learned"), alibi_slopes is set to None so no ALiBi bias is applied.

Code excerpt (conceptual)

Before: alibi_slopes = _get_alibi_slopes(total_num_heads) alibi_slopes = alibi_slopes[head_start:head_end] self.attn = Attention(..., alibi_slopes=alibi_slopes, ...)

After: use_alibi = getattr(config, "position_embedding_type", "") == "alibi" alibi_slopes = _get_alibi_slopes(...) if use_alibi else None self.attn = Attention(..., alibi_slopes=alibi_slopes, ...)

Why this fixes the issue The JAISModel already conditionally creates the learned positional embedding (wpe) when position_embedding_type != "alibi", but the attention code was still enabling ALiBi unconditionally. This patch makes the attention implementation consistent with the model’s positional embedding config and prevents applying two forms of positional encoding simultaneously.

Testing & validation I created a working branch (agent/37400-fix) with the change and pushed it to a fork (ahmedabbas104/vllm). Recommended tests to run upstream or CI: Unit tests covering attention behavior (existing attention tests exercise alibi paths; ensure none fail). Model initialization checks for JAIS configs with position_embedding_type == "learned" and "alibi". Minimal forward pass smoke test for a JAIS config using learned embeddings to confirm outputs run without ALiBi.

Backward compatibility No behavior change for models configured with position_embedding_type == "alibi". Models that rely on learned embeddings will no longer see redundant ALiBi bias.

Related issue Fixes / addresses: vllm-project/vllm#37400

Changed files

  • vllm/model_executor/models/jais.py (modified, +10/-2)

Code Example

alibi_slopes = _get_alibi_slopes(total_num_heads)
  self.attn = Attention(..., alibi_slopes=alibi_slopes)
RAW_BUFFERClick to expand / collapse

Your current environment

None

🐛 Describe the bug

Bug description

In vllm/model_executor/models/jais.py, ALiBi appears to be constructed and passed into Attention(...) unconditionally:

alibi_slopes = _get_alibi_slopes(total_num_heads)
self.attn = Attention(..., alibi_slopes=alibi_slopes)

At the same time, JAISModel still uses learned positional embeddings (wpe) when config.position_embedding_type == "learned".

This means that for JAIS configs/checkpoints using learned positional embeddings, vLLM applies both:

  1. learned positional embeddings via wpe
  2. ALiBi bias in attention

That looks like double positional encoding.

Expected behavior

ALiBi and learned positional embeddings should be mutually exclusive, following config.position_embedding_type.

If position_embedding_type == "alibi", passing alibi_slopes is correct.

If position_embedding_type == "learned", ALiBi should not be enabled in attention.

Why this matters

This likely produces incorrect attention behavior for JAIS variants configured with learned positional embeddings.

From what I checked, standard public JAIS checkpoints seem to use position_embedding_type="alibi", so this may not affect the common released checkpoints. But it does appear to be a correctness issue for any JAIS config/checkpoint using position_embedding_type="learned".

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To fix the issue of double positional encoding, we need to conditionally apply ALiBi bias in attention based on the position_embedding_type config.

Here are the steps:

  • Check the position_embedding_type in the config
  • If it's "alibi", pass alibi_slopes to Attention
  • If it's "learned", do not pass alibi_slopes to Attention

Example code:

if config.position_embedding_type == "alibi":
    alibi_slopes = _get_alibi_slopes(total_num_heads)
    self.attn = Attention(..., alibi_slopes=alibi_slopes)
elif config.position_embedding_type == "learned":
    self.attn = Attention(..., alibi_slopes=None)

Alternatively, you can simplify the code by using a conditional expression:

alibi_slopes = _get_alibi_slopes(total_num_heads) if config.position_embedding_type == "alibi" else None
self.attn = Attention(..., alibi_slopes=alibi_slopes)

Verification

To verify the fix, you can:

  • Test the model with both "alibi" and "learned" position_embedding_type configs
  • Check the attention behavior and ensure it's correct for both cases

Extra Tips

  • Make sure to update the documentation and tests to reflect the changed behavior
  • Consider adding a check to ensure that position_embedding_type is either "alibi" or "learned" to prevent unexpected behavior with other values.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Bug]: JAIS: ALiBi is applied even when position_embedding_type="learned" [2 pull requests, 3 comments, 3 participants]