[axolotl] transformers 5.3.0 / TRL 0.29.0 업그레이드: API 변경 대응과 deprecated 설정 처리
PR 링크: axolotl-ai-cloud/axolotl#3459 상태: Merged | 변경: +81 / -49
들어가며
ML 프레임워크의 메이저 버전 업그레이드는 항상 breaking change와의 전쟁입니다. 이 PR은 axolotl의 핵심 의존성인 transformers를 5.2.0에서 5.3.0으로, TRL을 0.28.0에서 0.29.0으로 업그레이드하면서 발생하는 API 변경을 체계적으로 처리합니다.
핵심 코드 분석
1. TRL 내부 모듈 경로 변경 대응
Before:
from trl.trainer.utils import pad_to_length
After:
from trl.experimental.utils import pad_to_length
TRL 0.29.0에서 유틸리티 함수들이 trl.experimental로 이동했습니다.
2. DPO Trainer API 변경
TRL 0.29.0에서 loss_type이 string에서 list로 변경되었습니다:
Before:
loss_type: str = self.loss_type
self.loss_type = "ipo"
After:
loss_type: list[str] = self.loss_type
self.loss_type = ["ipo"]
또한 max_completion_length, generate_during_eval, use_logits_to_keep가 deprecated되어 제거하고, 적절한 deprecation warning을 추가했습니다:
@field_validator("dpo_use_logits_to_keep")
@classmethod
def validate_dpo_use_logits_to_keep(cls, dpo_use_logits_to_keep):
if dpo_use_logits_to_keep is not None:
raise DeprecationWarning(
"`dpo_use_logits_to_keep` is no longer supported, "
"it has been removed in TRL >= 0.29.0"
)
3. Liger Kernel 호환성 패치
def pre_model_load(self, cfg):
# shim: liger-kernel 0.7.0 imports ORPOTrainer from old trl path
import trl.trainer
from trl.experimental.orpo import ORPOTrainer
trl.trainer.ORPOTrainer = ORPOTrainer
liger-kernel이 아직 TRL 0.29.0의 새 경로를 반영하지 않았으므로, 이전 경로에 shim을 설정하여 호환성을 유지합니다.
4. create_optimizer 시그니처 변경
Before:
def create_optimizer(self):
opt_model = self.model_wrapped if is_sagemaker_mp_enabled() else self.model
After:
def create_optimizer(self, model=None):
opt_model = self.model if model is None else model
transformers 5.3.0에서 create_optimizer에 model 파라미터가 추가되었습니다.
왜 이게 좋은가
이 PR은 의존성 업그레이드의 모범 사례를 보여줍니다. deprecated 설정을 단순히 제거하지 않고 DeprecationWarning으로 사용자에게 안내하며, liger-kernel처럼 아직 업데이트되지 않은 third-party 라이브러리를 위한 shim도 제공합니다. 또한 TRL_EXPERIMENTAL_SILENCE=1 환경변수로 TRL의 experimental 경고를 억제하여 사용자 경험을 유지합니다.
정리
| 항목 | Before | After |
|---|---|---|
| transformers | 5.2.0 | 5.3.0 |
| TRL | 0.28.0 | 0.29.0 |
| accelerate | 1.12.0 | 1.13.0 |
| kernels | 0.12.1 | 0.12.2 |
참고 자료
알림: 이 분석은 AI가 실제 코드 diff를 기반으로 작성했습니다.
관련 포스트
PR Analysis 의 다른글
- 이전글 [Ultralytics] TensorRT 문서에서 더 이상 유효하지 않은 INT8 배치 2배 참조 제거
- 현재글 : [axolotl] transformers 5.3.0 / TRL 0.29.0 업그레이드: API 변경 대응과 deprecated 설정 처리
- 다음글 [pytest] request.getfixturevalue()의 dirty optimization 제거
댓글