Skip to content
Open
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
30 changes: 24 additions & 6 deletions src/diffusers/commands/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib.metadata
import platform
import subprocess
from argparse import ArgumentParser
Expand All @@ -23,16 +24,30 @@
is_accelerate_available,
is_bitsandbytes_available,
is_flax_available,
is_gguf_available,
is_google_colab,
is_nvidia_modelopt_available,
is_optimum_quanto_available,
is_peft_available,
is_safetensors_available,
is_torch_available,
is_torchao_available,
is_transformers_available,
is_xformers_available,
)
from . import BaseDiffusersCLICommand


# (display name, availability_fn, pypi distribution name for importlib.metadata.version)
_QUANTIZATION_BACKENDS = (
("bitsandbytes", is_bitsandbytes_available, "bitsandbytes"),
("gguf", is_gguf_available, "gguf"),
("optimum-quanto", is_optimum_quanto_available, "optimum-quanto"),
("torchao", is_torchao_available, "torchao"),
("nvidia-modelopt", is_nvidia_modelopt_available, "nvidia-modelopt"),
)


def info_command_factory(_):
return EnvironmentCommand()

Expand Down Expand Up @@ -92,11 +107,14 @@ def run(self) -> dict:

peft_version = peft.__version__

bitsandbytes_version = "not installed"
if is_bitsandbytes_available():
import bitsandbytes

bitsandbytes_version = bitsandbytes.__version__
quantization_versions = {}
Copy link
Copy Markdown
Collaborator

@DN6 DN6 May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the backend isn't available, I'd say it's better to skip adding it to the final message entirely. Keeps the logs less noisy.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

for backend_name, is_available_fn, dist_name in _QUANTIZATION_BACKENDS:
if not is_available_fn():
continue
try:
quantization_versions[backend_name] = importlib.metadata.version(dist_name)
except importlib.metadata.PackageNotFoundError:
quantization_versions[backend_name] = "N/A"

xformers_version = "not installed"
if is_xformers_available():
Expand Down Expand Up @@ -162,7 +180,7 @@ def run(self) -> dict:
"Transformers version": transformers_version,
"Accelerate version": accelerate_version,
"PEFT version": peft_version,
"Bitsandbytes version": bitsandbytes_version,
**{f"{name} version": ver for name, ver in quantization_versions.items()},
"Safetensors version": safetensors_version,
"xFormers version": xformers_version,
"Accelerator": accelerator,
Expand Down
Loading