Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove landmark attn and xpos rope implementations #1010

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,6 @@ flash_attn_fuse_mlp: # Whether to fuse part of the MLP into a single operation
# Whether to use scaled-dot-product attention
# https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html
sdp_attention:
# Landmark attention (only llama)
landmark_attention:
# xpos RoPE see https://github.com/kaiokendev/cutoff-len-is-context-len/blob/main/util/xpos_rope_llama_monkey_patch.py
# LLaMA only
xpos_rope:

# Resume from a specific checkpoint dir
resume_from_checkpoint:
Expand Down
16 changes: 0 additions & 16 deletions src/axolotl/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ def do_inference(
importlib.import_module("axolotl.prompters"), prompter
)

if cfg.landmark_attention:
from axolotl.monkeypatch.llama_landmark_attn import set_model_mem_id

set_model_mem_id(model, tokenizer)
model.set_mem_cache_args(
max_seq_len=255, mem_freq=50, top_k=5, max_cache_size=None
)

model = model.to(cfg.device)

while True:
Expand Down Expand Up @@ -176,14 +168,6 @@ def do_inference_gradio(
importlib.import_module("axolotl.prompters"), prompter
)

if cfg.landmark_attention:
from axolotl.monkeypatch.llama_landmark_attn import set_model_mem_id

set_model_mem_id(model, tokenizer)
model.set_mem_cache_args(
max_seq_len=255, mem_freq=50, top_k=5, max_cache_size=None
)

model = model.to(cfg.device)

def generate(instruction):
Expand Down
22 changes: 1 addition & 21 deletions src/axolotl/core/trainer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
from abc import abstractmethod
from dataclasses import dataclass, field
from functools import partial, wraps
from functools import wraps
from pathlib import Path
from typing import Optional

Expand Down Expand Up @@ -780,26 +780,6 @@ def build(self, total_num_steps):
# https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html
data_collator_kwargs["pad_to_multiple_of"] = 64

if self.cfg.is_llama_derived_model and self.cfg.landmark_attention:
from axolotl.monkeypatch.llama_landmark_attn import (
add_mem_tokens,
get_mem_id,
set_model_mem_id,
)

set_model_mem_id(self.model, self.tokenizer)

LOG.info("Adding landmark attention tokens to dataset")

for dataset in [self.train_dataset, self.eval_dataset]:
dataset = dataset.map(
partial(
add_mem_tokens, mem_freq=50, mem_id=get_mem_id(self.tokenizer)
),
batched=False,
num_proc=32,
)

trainer_cls = self._get_trainer_cls()
trainer_kwargs, trainer_cls = self.hook_pre_create_trainer(
trainer_kwargs, trainer_cls
Expand Down
Loading