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

Fix Transformers + Cuda Context bug in NeMo Curator #591

Merged
Merged
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
6 changes: 5 additions & 1 deletion nemo_curator/classifiers/aegis.py
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@
from crossfit import op
from crossfit.backend.torch.hf.model import HFModel
from huggingface_hub import PyTorchModelHubMixin
from peft import PeftModel
from torch.nn import Dropout, Linear
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer

@@ -116,6 +115,11 @@ def __init__(
base_model = AutoModelForCausalLM.from_pretrained(
pretrained_model_name_or_path, torch_dtype=dtype, token=token
)
# Importing PeftModel here to prevent cuda context issues
# that seem to happen on Transformers 4.48.3
# See related: https://github.com/rapidsai/crossfit/pull/113
from peft import PeftModel

self.model = PeftModel.from_pretrained(base_model, peft_model_name_or_path)
self.autocast = autocast
self.add_instruction_data_guard = add_instruction_data_guard
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ dependencies = [
"beautifulsoup4",
"charset_normalizer>=3.1.0",
"comment_parser",
"crossfit>=0.0.8",
"crossfit>=0.0.8.post1",
"dask-mpi>=2021.11.0",
"dask[complete]>=2021.7.1",
"datasets",