Answers for LLM inference engineers

ImportError: cannot import name 'X' from 'peft', 'trl' or 'accelerate' (or their submodules): which releases have it

The library named after "from" is too old for the name, or too new because the name was removed. The common ones: trl removed DataCollatorForCompletionOnlyLM in 0.20.0 (use SFTConfig(completion_only_loss=True)), setup_chat_format in 0.26.0 (use clone_chat_template), and 33 top-level names in 0.29.0, PPOTrainer and ORPOTrainer among them, most of which were then importable from trl.experimental. peft removed prepare_model_for_int8_training in 0.10.0 (use prepare_model_for_kbit_training). accelerate.utils has is_npu_available only from 0.21.0, which is why an older accelerate breaks import peft. For any other name, in any module of the three libraries, paste the error below.

Published 2026-11-18 · Data as of 2026-11-18 · peft 0.0.1 to 0.21.3 (23 releases); trl 0.2.0 to 1.18.1 (48 releases); accelerate 0.1.0 to 1.16.0 (51 releases), the first release of each minor version, with patch releases that differ noted · read from the source of each release tag, nothing was installed or run (how, limits) · Corrected 2026-12-05

Corrected on 2026-12-05: this page read only the first release of each minor version, so a name added or removed in a patch release was dated to the next minor. For example, from trl import SFTTrainer works from trl 0.4.2 (2023-06-07), not only from 0.5.0. Every release was then read once from PyPI: 36 top-level names of trl (1,123 module-and-name pairs), 0 of peft (90) and 0 of accelerate (14) differ in some patch release from the first release of the same minor. The lookup now gives those patch releases. The per-minor ranges are unchanged.

Examples:

Runs in your browser on peft.json, trl.json and accelerate.json (454 KB in all, loaded as needed); nothing you paste is sent anywhere. Understands cannot import name, No module named, module ... has no attribute, Failed to import and plain import lines. Covers 14,806 module-and-name pairs.

The import is inside another library. Which package do I change?

The one in quotes after "from". ImportError: cannot import name 'is_npu_available' from 'accelerate.utils' raised while running from peft import LoraConfig means peft needs a newer accelerate, not that peft is broken: upgrade accelerate to 0.21.0 or later. cannot import name 'PartialState' from 'accelerate' raised from inside transformers means the same for accelerate 0.17.0. Pinning the other library down to match is the other way out, and the lookup gives the range for that too.

What did each trl release remove from from trl import ...?

85 of the 146 names that from trl import has ever accepted are gone from 1.18.1; this is every one, by the release that dropped it. To keep old code running, pin below that release, for example pip install "trl<0.20.0" for DataCollatorForCompletionOnlyLM.

ReleaseDate (PyPI)ModuleNamesRemoved names
1.15.02026-10-08trl1prepare_multimodal_messages_vllm
1.14.02026-09-25trl1losses
1.11.02026-08-26trl1skills
1.8.02026-07-09trl1get_kbit_device_map
1.0.02026-03-30trl1truncate_dataset
0.29.02026-02-25trl33AllTrueJudge, AutoModelForCausalLMWithValueHead, AutoModelForSeq2SeqLMWithValueHead, BCOConfig, BCOTrainer, BaseBinaryJudge, BaseJudge, BasePairwiseJudge, BaseRankJudge, CPOConfig, CPOTrainer, FDivergenceConstants, FDivergenceType, GKDConfig, GKDTrainer, HfPairwiseJudge, NashMDConfig, NashMDTrainer, ORPOConfig, ORPOTrainer, OnlineDPOConfig, OnlineDPOTrainer, OpenAIPairwiseJudge, PPOConfig, PPOTrainer, PRMConfig, PRMTrainer, PairRMJudge, PreTrainedModelWrapper, WinRateCallback, XPOConfig, XPOTrainer, mergekit_utils
0.27.02026-01-16trl2MergeModelCallback, SUPPORTED_ARCHITECTURES
0.26.02025-12-09trl1setup_chat_format
0.25.02025-11-05trl2BestOfNSampler, core
0.24.02025-10-16trl10AlignPropConfig, AlignPropTrainer, DDPOConfig, DDPOPipelineOutput, DDPOSchedulerOutput, DDPOStableDiffusionPipeline, DDPOTrainer, DefaultDDPOStableDiffusionPipeline, IterativeSFTConfig, IterativeSFTTrainer
0.21.02025-08-05trl3TextEnvironment, TextHistory, environment
0.20.02025-07-29trl2DataCollatorForCompletionOnlyLM, pack_examples
0.17.02025-04-24trl7is_deepspeed_available, is_diffusers_available, is_llm_blender_available, is_mergekit_available, is_rich_available, is_unsloth_available, is_vllm_available
0.16.02025-03-22trl1compute_token_accuracy
0.14.02025-01-29trl1set_seed
0.13.02024-12-16trl9DPOScriptArguments, PPOv2Config, PPOv2Trainer, RandomPairwiseJudge, RandomRankJudge, SFTScriptArguments, commands, env_utils, utils
0.12.02024-11-01trl2is_liger_kernel_available, is_llmblender_available
0.11.02024-09-19trl7is_bitsandbytes_available, is_npu_available, is_openai_available, is_peft_available, is_pil_available, is_wandb_available, is_xpu_available

trl 0.29.0: where did PPOTrainer, ORPOTrainer and the rest go?

30 of the 33 names removed from the top level in 0.29.0 (2026-02-25) were importable from a module under trl.experimental in that release. trl 0.28.0 already pointed there: importing PPOTrainer from the old place warned that it "is now located in trl.experimental". Some experimental modules were removed later (trl.experimental.ppo is gone since 1.13.0); the lookup says which are still there in 1.18.1.

Removed from trl in 0.29.0Importable in 0.29.0 from
AllTrueJudgetrl.experimental.judges, trl.experimental.judges.judges
AutoModelForCausalLMWithValueHeadtrl.experimental.ppo, trl.experimental.ppo.modeling_value_head
AutoModelForSeq2SeqLMWithValueHeadtrl.experimental.ppo, trl.experimental.ppo.modeling_value_head
BCOConfigtrl.experimental.bco, trl.experimental.bco.bco_config, trl.experimental.bco.bco_trainer
BCOTrainertrl.experimental.bco, trl.experimental.bco.bco_trainer
BaseBinaryJudgetrl.experimental.judges, trl.experimental.judges.judges
BaseJudgetrl.experimental.judges, trl.experimental.judges.judges
BasePairwiseJudgetrl.experimental.judges, trl.experimental.judges.judges, trl.experimental.nash_md.nash_md_trainer, trl.experimental.online_dpo.online_dpo_trainer, trl.experimental.xpo.xpo_trainer
BaseRankJudgetrl.experimental.judges, trl.experimental.judges.judges
CPOConfigtrl.experimental.cpo, trl.experimental.cpo.cpo_config, trl.experimental.cpo.cpo_trainer
CPOTrainertrl.experimental.cpo, trl.experimental.cpo.cpo_trainer
FDivergenceConstantsnot in trl.experimental
FDivergenceTypenot in trl.experimental
GKDConfigtrl.experimental.gkd, trl.experimental.gkd.gkd_config, trl.experimental.gkd.gkd_trainer
GKDTrainertrl.experimental.gkd, trl.experimental.gkd.gkd_trainer
HfPairwiseJudgetrl.experimental.judges, trl.experimental.judges.judges
NashMDConfigtrl.experimental.nash_md, trl.experimental.nash_md.nash_md_config, trl.experimental.nash_md.nash_md_trainer
NashMDTrainertrl.experimental.nash_md, trl.experimental.nash_md.nash_md_trainer
ORPOConfigtrl.experimental.orpo, trl.experimental.orpo.orpo_config, trl.experimental.orpo.orpo_trainer
ORPOTrainertrl.experimental.orpo, trl.experimental.orpo.orpo_trainer
OnlineDPOConfigtrl.experimental.online_dpo, trl.experimental.nash_md.nash_md_config, trl.experimental.online_dpo.online_dpo_config, trl.experimental.online_dpo.online_dpo_trainer, trl.experimental.xpo.xpo_config
OnlineDPOTrainertrl.experimental.online_dpo, trl.experimental.nash_md.nash_md_trainer, trl.experimental.online_dpo.online_dpo_trainer, trl.experimental.xpo.xpo_trainer
OpenAIPairwiseJudgetrl.experimental.judges, trl.experimental.judges.judges
PPOConfigtrl.experimental.ppo, trl.experimental.ppo.ppo_config, trl.experimental.ppo.ppo_trainer
PPOTrainertrl.experimental.ppo, trl.experimental.ppo.ppo_trainer
PRMConfigtrl.experimental.prm, trl.experimental.prm.prm_config, trl.experimental.prm.prm_trainer
PRMTrainertrl.experimental.prm, trl.experimental.prm.prm_trainer
PairRMJudgetrl.experimental.judges, trl.experimental.judges.judges
PreTrainedModelWrappertrl.experimental.ppo, trl.experimental.ppo.modeling_value_head
WinRateCallbacktrl.experimental.winrate_callback
XPOConfigtrl.experimental.xpo, trl.experimental.xpo.xpo_config, trl.experimental.xpo.xpo_trainer
XPOTrainertrl.experimental.xpo, trl.experimental.xpo.xpo_trainer
mergekit_utilsnot in trl.experimental

What did peft remove?

peft removes few names: 17 from peft and peft.utils in all. The one people hit is prepare_model_for_int8_training, gone in 0.10.0 (2024-03-21).

ReleaseDate (PyPI)ModuleNamesRemoved names
0.19.02026-04-14peft2BoneConfig, BoneModel
0.19.02026-04-14peft.utils2TRANSFORMERS_MODELS_TO_BONE_TARGET_MODULES_MAPPING, get_auto_gptq_quant_linear
0.10.02024-03-21peft1prepare_model_for_int8_training
0.10.02024-03-21peft.utils1prepare_model_for_int8_training
0.8.02024-01-30peft.utils1COMMON_LAYERS_PATTERN
0.7.02023-12-06peft.utils2hub_file_exists, hub_utils
0.6.02023-11-03peft.utils1add_library_to_model_card
0.5.02023-08-22peft.utils4CLAMP_QUANTILE, PeftConfig, PromptLearningConfig, config
0.3.02023-05-03peft.utils1adapters_utils
0.1.02023-02-10peft1peft_model_load_and_dispatch
0.1.02023-02-10peft.utils1peft_model_load_and_dispatch

What did accelerate remove from accelerate and accelerate.utils?

57 names, most of them in 0.8.0, when accelerate.utils became a package and stopped re-exporting what it imported. The ones that still turn up in errors: is_safetensors_available (gone in 0.25.0) and is_tpu_available (gone from accelerate.utils in 0.28.0; use is_torch_xla_available).

ReleaseDate (PyPI)ModuleNamesRemoved names
1.16.02026-11-16accelerate2inference, prepare_pippy
1.16.02026-11-16accelerate.utils7FP8RecipeKwargs, MITA_PROFILING_AVAILABLE_PYTORCH_VERSION, MSAMPRecipeKwargs, XPU_PROFILING_AVAILABLE_PYTORCH_VERSION, is_msamp_available, is_pippy_available, is_weights_only_available
1.13.02026-03-04accelerate.utils3get_ccl_version, is_ccl_available, is_ipex_available
1.5.02025-03-12accelerate.utils1check_fp8_capability
1.0.02024-10-07accelerate.utils1shard_checkpoint
0.31.02024-06-07accelerate.utils1megatron_lm_prepare_model
0.28.02024-03-12accelerate.utils1is_tpu_available
0.25.02023-12-01accelerate.utils1is_safetensors_available
0.21.02023-07-13accelerate.utils1get_launch_prefix
0.20.02023-06-07accelerate.utils1IntelPyTorchExtensionPlugin
0.19.02023-05-08accelerate.utils1is_apex_available
0.10.02022-06-15accelerate.utils1is_tensorflow_available
0.8.02022-05-12accelerate2deepspeed_utils, kwargs_handlers
0.8.02022-05-12accelerate.utils34AcceleratorState, Any, BaseEnum, Callable, ConvertOutputsToFp32, DeepSpeedEngine, Enum, EnumMeta, EnumWithContains, Iterable, List, Mapping, Optional, ReduceOp, Union, _cpu_gather, _cpu_gather_object, _gpu_broadcast, _gpu_gather, _gpu_gather_object, _tpu_broadcast, _tpu_gather, contextmanager, dataclass, field, functools, importlib, np, os, torch, typing, update_wrapper, version, xm

Which trl names are listed but cannot be imported?

11 entries of trl's lazy import tables point at a file that is not there or that lacks the name. The name shows up in dir(trl) and in autocompletion, but importing it fails. For example, trl.trainer in 0.13.0 still lists PPOv2Trainer, but the file behind it was already gone.

ImportFails inWhy
from trl import DpoArgumentParser0.8.0 to 0.8.6the entry points to commands.utils, a file that is not there
from trl import MultitaskPromptEmbedding0.8.0 to 0.11.4the entry points to multitask_prompt_tuning, a file that is not there
from trl import MultitaskPromptTuningConfig0.8.0 to 0.11.4the entry points to multitask_prompt_tuning, a file that is not there
from trl import MultitaskPromptTuningInit0.8.0 to 0.11.4the entry points to multitask_prompt_tuning, a file that is not there
from trl import SftArgumentParser0.8.0 to 0.8.6the entry points to commands.utils, a file that is not there
from trl import TrlParser0.8.0 to 0.8.6the entry points to commands.utils, a file that is not there
from trl import init_zero_verbose0.8.0 to 0.8.6the entry points to commands.utils, a file that is not there
from trl.commands import SftArgumentParser0.8.0 to 0.8.6the entry points to cli_utils, which does not define the name
from trl.commands import YamlConfigParser0.8.0 to 0.8.6the entry points to config_parser, a file that is not there
from trl.trainer import PPOv2Config0.13.0 to 0.13.0the entry points to ppov2_config, a file that is not there
from trl.trainer import PPOv2Trainer0.13.0 to 0.13.0the entry points to ppov2_trainer, a file that is not there

How was this read, and how was it checked?

From the source of each release tag, with Python's ast module; no release was installed or imported. peft and accelerate import eagerly, so a module's names are everything it binds at module level (classes, functions, assignments, imports). trl replaces its packages with a lazy module from 0.8.0 on; for those, the names are the entries of the lazy table, each followed to the file it names. Code under if TYPE_CHECKING: is skipped. Dates and yanked releases come from PyPI.

Checks, all by a second reading: (1) trl's lazy packages repeat their names as plain imports for type checkers; 214 of 231 package-and-release pairs match exactly, and the rest differ by 9 names that trl lists in only one of the two places (the lookup follows the table, which is what runs). (2) Each of the 369 top-level names is found as plain text in __init__.py of every release in its range (7,221 name-and-release pairs), and is not imported there in the release on either side (353 edges). (3) A regular expression finds 30,884 definitions in 4,557 file versions; all are among the names read. (4) 18 known facts hold, among them the releases in the public error reports under Sources.

Limits

Questions

How do I fix "cannot import name 'DataCollatorForCompletionOnlyLM' from 'trl'"?

trl 0.20.0 (2025-07-29) removed it; 0.19.1 is the last release with it. Either pin pip install "trl<0.20.0", or drop the collator and set SFTConfig(completion_only_loss=True), which is what trl 0.19.0 told you to use.

Where did PPOTrainer, ORPOTrainer and the other trainers go in trl 0.29.0?

trl 0.29.0 (2026-02-25) removed 33 names from the top level. 30 of them were still importable from trl.experimental in 0.29.0, for example from trl.experimental.ppo import PPOTrainer; the full list is in the table on this page. Later releases removed some of the experimental modules as well, so the lookup also says whether each one is still there in 1.18.1.

How do I fix "cannot import name 'prepare_model_for_int8_training' from 'peft'"?

Use prepare_model_for_kbit_training, which peft has had since 0.4.0. peft 0.10.0 (2024-03-21) removed the int8 name; 0.9.0 is the last release with it.

I import from peft but the error says "cannot import name 'is_npu_available' from 'accelerate.utils'". Which package do I upgrade?

accelerate. The library in quotes after "from" is the one that lacks the name; the import that fails can sit inside another library. accelerate.utils has is_npu_available from 0.21.0 (2023-07-13), so pip install -U "accelerate>=0.21.0".

Does this page cover names below the top level, like trl.trainer.utils or accelerate.utils?

Yes. Every module of the three libraries is covered: 14,806 module-and-name pairs in all, read from peft 0.0.1 to 0.21.3 (23 releases); trl 0.2.0 to 1.18.1 (48 releases); accelerate 0.1.0 to 1.16.0 (51 releases).

Sources

The same data as JSON: peft.json, trl.json, accelerate.json, licensed CC BY 4.0.

Related: "cannot import name ... from 'transformers'" · "cannot import name ... from 'huggingface_hub'" · "cannot import name ... from 'diffusers'" · "got an unexpected keyword argument": PEFT, TRL and TrainingArguments.