Enforce half-split layout for cos/sin in RoPE challenge test data#271
Enforce half-split layout for cos/sin in RoPE challenge test data#271baqizhaobenshan wants to merge 1 commit into
Conversation
|
Hi maintainers, gentle ping on this PR. I verified the change locally with:
All checks passed locally. The Checks tab currently shows “completed with no jobs”, so I am not sure whether CI was skipped because of path filters or fork permissions. The intended invariant here is that RoPE uses rotate_half / half-split layout, so dimensions j and j + D/2 form a pair and should share the same cos/sin values. The current random test generation samples all D dimensions independently, which breaks this invariant. This PR only fixes the test data generation and documents the invariant; it does not change the solve signature or the expected output formula. @kunal-mansukhani Sorry for the ping — when you have time, could you take a look at whether this matches the intended RoPE layout for this challenge? |
Summary
Fixes the RoPE challenge test data so
cosandsinfollow the half-split layout described by the problem.For RoPE with
rotate_half, paired dimensionsjandj + D/2should use the same cosine and sine values. Previously, several generated test cases used fully independent random values for allDdimensions, socos[:, j] != cos[:, j + D/2]andsin[:, j] != sin[:, j + D/2]in general.This PR keeps the existing random data generation style unchanged and only enforces:
Changes
cosandsintables.cos/sinvalues.mixed_valuestest case to satisfy the same layout.cos/sinrequirement in the challenge description.Motivation
The current random
cos/sintest data prevents implementations from using the standard half-split RoPE assumption that paired dimensions share the same rotation values. This makes the test data inconsistent with the expected RoPE layout and forces extracos/sinloads that should not be necessary for this formulation.Testing
python3 -m py_compile challenges/medium/61_rope_embedding/challenge.pygit diff --check -- challenges/medium/61_rope_embedding/challenge.py challenges/medium/61_rope_embedding/challenge.html