Skip to content

wgpu forward hardcodes rope_theta=1e6 (wgsl_forward.rs:970): Llama/Mistral wrong on wgpu (R12-1) #4832

Closed as not planned

Description

@noahgift

Parent: #3999 (E6 0.73 epic). Ref: la-0.73 R12-1.

Defect

crates/aprender-compute/src/backends/gpu/device/linalg/wgsl_forward.rs:970 (main @ 67e7518):

let rope_theta = 1_000_000.0f64; // Qwen2 rope_theta

The wgpu forward path hardcodes RoPE base 1e6 (Qwen2) for both the Q (:977) and K (:993) rotations. Models with another base, e.g. Llama (10 000 / 500 000) and Mistral (10 000 / 1e6 per version), get the wrong rotary angles on wgpu, and the output is wrong. No error is raised.

Fix

Read rope_theta from the model config, as the CPU/CUDA paths do, and pass it into the wgsl forward. If it is missing, fail loudly instead of falling back to 1e6.

Acceptance

  • No literal rope base remains in the wgsl forward path.
  • A unit test drives the wgpu forward with two configs whose rope_theta differ and asserts the rotations differ, so the test fails if the constant comes back.
  • A parity row (Llama or Mistral, wgpu vs CPU) reports argmax/logit agreement.

Owner: aprender-cd.

Activity

  1. added this to the 0.73.0 milestone on Oct 8, 2026
  2. noahgift commented on Oct 13, 2026

    @noahgift
    MemberAuthor

    park proposal: parked, defect confirmed still present on main @7f9a15a52b (wgsl_forward.rs:970 still reads let rope_theta = 1_000_000.0f64); it is scheduled under the 0.73 epic #3999 with an owner, so it waits there.

  3. noahgift commented on Oct 14, 2026

    @noahgift
    MemberAuthor

    merged into #5313 (master ticket for epic #3999; triage rule 7b, 2026-10-14). It is a checklist row there; reopen this issue when work on it starts or its PR opens.

  4. noahgift commented on Oct 14, 2026

    @noahgift
    MemberAuthor

    Moved: this sub-ticket is now a row in #5338 (Backend portability: correct kernels and config on every CPU, wgpu and CUDA target), split out of #5313 by theme.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions