pub struct Rope {
pub dims: usize,
pub theta: f64,
pub neox: bool,
pub scaling: RopeScaling,
pub sections: Option<[usize; 4]>,
}Expand description
The rotary position embedding.
Fields§
§dims: usizeHow many of each head’s dimensions rotate (the rest pass through).
theta: f64§neox: boolNEOX pairs dimension i with i + dims/2; the original form pairs 2i with 2i+1.
scaling: RopeScaling§sections: Option<[usize; 4]>Interleaved multi-section rotation (rope.dimension_sections, Qwen3.5): frequency i reads position stream
i mod Σsections as llama.cpp’s IMROPE assigns it. A text token’s streams are [p, p, p, 0], so a frequency
assigned to the fourth stream does not turn.
Implementations§
Source§impl Rope
impl Rope
Sourcepub fn rotation(&self, i: usize, pos: usize, factor: Option<f64>) -> (f64, f64)
pub fn rotation(&self, i: usize, pos: usize, factor: Option<f64>) -> (f64, f64)
(cos, sin) of frequency i at text position pos, each scaled by the rotation’s magnitude, as ggml’s CPU
rope computes them (rope_yarn): the angle is pos·θ^(−2i/dims), divided by the checkpoint’s frequency
factor factor when it stores one; linear scaling divides it by its factor; YaRN blends the divided and the
undivided angle by a ramp over the correction dimensions and scales the pair by its magnitude.
Sourcepub fn text_position(&self, i: usize, pos: usize) -> usize
pub fn text_position(&self, i: usize, pos: usize) -> usize
The position frequency i turns by for a text token at pos.
Trait Implementations§
impl StructuralPartialEq for Rope
Auto Trait Implementations§
impl Freeze for Rope
impl RefUnwindSafe for Rope
impl Send for Rope
impl Sync for Rope
impl Unpin for Rope
impl UnsafeUnpin for Rope
impl UnwindSafe for Rope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.