Add ruff, remove black, isort, flake8, pylint (#3092)
* black, isort, flake8 -> ruff * remove unused * add back needed import * fix
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
"""Integration tests for LoRA activation and attention kernels."""
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -88,7 +86,7 @@ def test_attention_patching_integration(model_name, attention_cls):
|
||||
cfg = DictDefault({"base_model": model_name})
|
||||
|
||||
# Store the original implementation
|
||||
original_forward = getattr(attention_cls, "forward")
|
||||
original_forward = attention_cls.forward
|
||||
|
||||
# Apply patch
|
||||
patch_self_attn_lora(cfg)
|
||||
@@ -104,7 +102,7 @@ def test_attention_patching_integration(model_name, attention_cls):
|
||||
assert hasattr(attention_cls, "_original_forward")
|
||||
|
||||
# Clean up
|
||||
setattr(attention_cls, "forward", original_forward)
|
||||
attention_cls.forward = original_forward
|
||||
delattr(attention_cls, "_original_forward")
|
||||
|
||||
|
||||
@@ -379,9 +377,9 @@ def test_model_architecture(model_config):
|
||||
|
||||
# Verify correct activation function
|
||||
layer = patched_model.model.model.layers[0]
|
||||
assert (
|
||||
layer.mlp.forward.__func__ is model_config["expected_activation"]
|
||||
), f"Wrong activation for {model_config['name']}"
|
||||
assert layer.mlp.forward.__func__ is model_config["expected_activation"], (
|
||||
f"Wrong activation for {model_config['name']}"
|
||||
)
|
||||
|
||||
# Test forward pass
|
||||
inputs = get_test_inputs(model)
|
||||
@@ -390,12 +388,11 @@ def test_model_architecture(model_config):
|
||||
patched_output = patched_model(inputs).logits
|
||||
|
||||
# Check outputs match
|
||||
assert torch.allclose(
|
||||
original_output, patched_output, rtol=1e-4
|
||||
), f"Outputs don't match for {model_config['name']}"
|
||||
assert torch.allclose(original_output, patched_output, rtol=1e-4), (
|
||||
f"Outputs don't match for {model_config['name']}"
|
||||
)
|
||||
|
||||
|
||||
# pylint: disable=duplicate-code
|
||||
def test_kernel_training_integration(temp_dir):
|
||||
"""Test model loading with kernel patches enabled."""
|
||||
from axolotl.cli.utils import load_model_and_tokenizer
|
||||
@@ -563,15 +560,13 @@ def test_kernel_training_integration_dropout_non_zero(temp_dir):
|
||||
model_loader = ModelLoader(cfg, tokenizer)
|
||||
|
||||
# Apply patch
|
||||
model_loader.patch_manager._apply_self_attention_lora_patch() # pylint: disable=protected-access
|
||||
model_loader.patch_manager._apply_self_attention_lora_patch()
|
||||
|
||||
# Verify patch was not applied
|
||||
assert attention_cls.forward == original_forward_method
|
||||
|
||||
# Apply apply_lora_kernel_patches
|
||||
model_loader.patch_manager._apply_lora_kernel_patch( # pylint: disable=protected-access
|
||||
model
|
||||
)
|
||||
model_loader.patch_manager._apply_lora_kernel_patch(model)
|
||||
|
||||
# Verify patch was not applied
|
||||
layers = get_layers(model)
|
||||
|
||||
Reference in New Issue
Block a user