Skip to content

fix: defer bitsandbytes import until use - #441

Open
motodriver wants to merge 1 commit into
p-e-w:masterfrom
motodriver:fix/429-lazy-bitsandbytes-import
Open

fix: defer bitsandbytes import until use#441
motodriver wants to merge 1 commit into
p-e-w:masterfrom
motodriver:fix/429-lazy-bitsandbytes-import

Conversation

@motodriver

Copy link
Copy Markdown

Summary

  • remove the unconditional module-level bitsandbytes import
  • import bitsandbytes only when a quantized weight actually requires 4-bit dequantization
  • add a subprocess regression test that rejects any bitsandbytes import while loading heretic.model

This prevents an unrelated bitsandbytes native-library traceback from being emitted at startup for non-BNB use while preserving the existing failure behavior when 4-bit dequantization is actually required.

Fixes #429.

Verification

  • uv run --frozen python -m unittest discover -s tests -p "test_*.py" — 5 passed
  • uv run --frozen ruff format --check .
  • uv run --frozen ruff check --output-format=github --extend-select I .
  • uv run --frozen ty check --output-format=github --error-on-warning .
  • git diff --check

AI assistance from TRAE was used for repository analysis, test drafting, and review. I reviewed the complete diff and ran the verification above.

import unittest


class ModelImportTests(unittest.TestCase):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Get rid of this test, it doesn't tell us anything. It simply asserts that the import line that has been moved has indeed been moved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants