Skip to main content

RopeLayers

Enum RopeLayers 

Source
pub enum RopeLayers {
    All,
    SlidingOnly,
    NoRopeEvery {
        step: NonZeroUsize,
        phase: NoRopePhase,
    },
}
Expand description

llama.cpp’s per-layer use_rope, as a value a ModelConfig can carry.

The default is RopeLayers::All and it is what every audited architecture but four gets. A variant is only ever added by reading a use_rope in src/models/.

Variants§

§

All

Every layer rotates: llama.cpp writes no gate at all.

§

SlidingOnly

Only the SLIDING-WINDOW layers rotate; the full-attention layers get no rotation. exaone4 (when its SWA is on) and exaone-moe.

Note what this means when a model’s SWA pattern windows nothing (llama.cpp’s degenerate set_swa_pattern(1)): NO layer rotates. That is upstream’s answer too – is_swa(il) is false everywhere while swa_type is still STANDARD – and it is why this is not written as “sliding layers, or everything if nothing slides”.

§

NoRopeEvery

One layer in every step does not rotate, hparams.n_no_rope_layer_step.

Fields

§step: NonZeroUsize

llama.cpp’s n_no_rope_layer_step. Never zero here: the two architectures that guard on step > 0 inherit the llama-hparams.h:203 default of 4 and never assign it.

§phase: NoRopePhase

Which layer of the period is skipped.

Implementations§

Source§

impl RopeLayers

Source

pub fn rotates(self, layer_idx: usize, layer_slides: bool) -> bool

Does layer layer_idx rotate?

layer_slides is ModelConfig::layer_sliding_window(il).is_some(), i.e. llama.cpp’s hparams.is_swa(il). It is a parameter rather than something this enum works out, because the SWA layout is the ModelConfig’s answer and restating it here would be two structures that must agree about one thing.

Source

pub fn any_layer_unrotated( self, n_layers: usize, slides: impl Fn(usize) -> bool, ) -> bool

True when this rule leaves at least one layer of an n_layers model unrotated, i.e. when it is anything other than “rotate everything” IN PRACTICE rather than in name.

The distinction matters: NoRopeEvery { step: 64, .. } on a 30-layer model is Self::All by any observable test, and a caller asking “must I implement this?” wants the observable answer.

Trait Implementations§

Source§

impl Clone for RopeLayers

Source§

fn clone(&self) -> RopeLayers

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RopeLayers

Source§

impl Debug for RopeLayers

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RopeLayers

Source§

fn default() -> RopeLayers

Returns the “default value” for a type. Read more
Source§

impl Eq for RopeLayers

Source§

impl PartialEq for RopeLayers

Source§

fn eq(&self, other: &RopeLayers) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RopeLayers

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.