Skip to content

[Fix/Feature] Fix code for huggingface bitsandbites and auto GPTQ #40

Description

@b-re-w

Issue 1: AutoGPTQ backend remains a script and isn’t integrated as a runtime

  • api/src/main/backend/gptq.py still contains installation commands and example code instead of a CoreRuntime subclass, so it cannot be used like the other backends.

Implement and register AutoGPTQ runtime

  1. Remove script-style content from api/src/main/backend/gptq.py and introduce a GPTQRuntime class inheriting from CoreRuntime.

    • Load models via AutoGPTQForCausalLM.from_quantized and implement a __call__ method that provides both streaming and non-streaming generation similar to BinRuntime.
  2. Register the backend at the bottom of the file with CoreRuntime.register_backend("GPTQRuntime", GPTQRuntime).

  3. Update api/src/main/backend/__init__.py:

    • Add GPTQ = "GPTQRuntime" to the BackendType enum.
    • Import GPTQRuntime with from .gptq import GPTQRuntime.
  4. Modify GPTQ-capable model classes (e.g., api/src/main/models/qwen3/model.py) to include BackendType.GPTQ in supported_backends and handle it in _get_runtime.

Issue 2: BinRuntime lacks consistent cache handling and flexible quantization settings

  • Although BinRuntime defines a local cache path, it uses None for cache_dir in from_pretrained, causing inconsistent cache usage, and it doesn’t save the tokenizer locally.

Improve BinRuntime caching and quantization options

  1. In api/src/main/backend/bin.py, pass cache_dir or self.__cache_dir to both AutoModelForCausalLM.from_pretrained and AutoTokenizer.from_pretrained, and include trust_remote_code=True.
  2. Save the tokenizer to the same cache path with tokenizer.save_pretrained(save_path) whenever downloading a model.
  3. Expose quantization_config as an optional constructor argument and document how to adjust BitsAndBytesConfig settings.

Issue 3: AutoGPTQ dependency missing from pyproject.toml

  • pyproject.toml lists bitsandbytes but not auto-gptq, so installations fail when the AutoGPTQ backend is used.

Add AutoGPTQ dependency

  1. Add "auto-gptq>=0.x" to the [project] dependencies section in pyproject.toml.
  2. Update documentation (e.g., README) to mention AutoGPTQ requirements and GPU/CUDA compatibility notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions