1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[PR #22] [CLOSED] Added: Notebook compatibility, Multimodal support (InternVL/QwenVL/Gemma), and trust_remote_code #241

Closed
opened 2026-11-01 04:19:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/p-e-w/heretic/pull/22
Author: @Vinay-Umrethe
Created: 11/19/2025
Status: ❌ Closed

Base: master ← Head: master


📝 Commits (10+)

  • b48bc29 feat: Notebook compatibility, Multimodal support (InternVL/Qwen/Omni/VL), and trust_remote_code
  • b3bb83f fix: Applied upstream fixes (multi-GPU support, memory optimization, KeyError fix) TO THE ENHANCED EDITION
  • b54e726 fix: Restore accidentally deleted MPS support and GPU fallback logic
  • 43a1c25 fix: Complete upstream sync (restore missing import gc and PYTORCH_CUDA_ALLOC_CONF)
  • e568901 chore: Revert metadata changes (name, version, readme) to match upstream
  • 955e6cb Updated README
  • 8d8727f Merge branch 'master' into master
  • c73689b fix: Resolve CI failures (formatting, missing imports, package name)
  • 1abcf8e Merge branch 'master' of https://github.com/Vinayyyy7/heretic
  • 1d47b35 style: Fix formatting in utils.py to pass CI

📊 Changes

6 files changed (+241 additions, -34 deletions)

View changed files

📝 pyproject.toml (+1 -1)
📝 src/heretic/config.py (+1 -0)
📝 src/heretic/main.py (+16 -15)
📝 src/heretic/model.py (+115 -17)
📝 src/heretic/utils.py (+107 -0)
📝 uv.lock (+1 -1)

📄 Description

This PR significantly enhances Heretic's compatibility with notebook environments (Colab/Kaggle) and extends support to modern multimodal models.

Key Changes

  1. Notebook Compatibility:

    • Replaced questionary arrow-key menus with robust numeric input loops. This fixes "CPR" warnings and usability issues in non-TUI environments like Google Colab.
    • Added a /exit command to the chat loop for graceful termination. Returing to the menu.
  2. Multimodal Model Support:

    • Implemented dynamic model class loading in model.py.
    • Added support for:
Model Family Example Models (Hugging Face ID)
Qwen 2.5 VL Qwen/Qwen2.5-VL-7B-Instruct, Qwen/Qwen2.5-VL-3B-Instruct
Qwen 3 VL Qwen/Qwen3-VL-4B-Instruct, Qwen/Qwen3-VL-2B-Instruct
Qwen 3 VL MoE Qwen/Qwen3-VL-235B-A22B-Instruct, Qwen/Qwen3-VL-30B-A3B-Instruct
Qwen 2.5 Omni Qwen/Qwen2.5-Omni-7B, Qwen/Qwen2.5-Omni-3B
Qwen 3 Omni Qwen/Qwen3-Omni-30B-A3B-Instruct, Qwen/Qwen3-Omni-30B-A3B-Thinking
InternVL 3.5 OpenGVLab/InternVL3_5-8B-HF, OpenGVLab/InternVL3_5-2B-HF
Gemma 3 / 3n google/gemma-3-4b-it, google/gemma-3n-4b-it
  • Expanded get_layers() to handle nested structures in VL models.
  1. Custom Code Support:

    • Added --trust-remote-code flag (default: False) to allow loading models with custom modeling code (required for InternVL, etc.).
  2. Robustness:

    • Added bfloat16 to the default dtype list.
    • Implemented generation fallbacks: retries with pixel_values=None or dummy tensors to handle picky VL models that crash on text-only inputs.
  3. Upstream Sync:

    • Manually applied recent upstream fixes for multi-GPU support, memory optimization, and the Hugging Face profile KeyError.
    • Needed a Manual update for this, since these fixes from your side, were implmented Today (Nov 19, 2025, 5:32 AM GMT+5:30) just 1-2 hours after I enhanced it. DONE ✅

Tested successfully on Google Colab with OpenGVLab/InternVL3_5-2B-HF , Qwen/Qwen2.5-Omni-3B, Qwen3-VL-2B-Insturct and Qwen/Qwen2.5-VL-3B-Instruct.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/p-e-w/heretic/pull/22 **Author:** [@Vinay-Umrethe](https://github.com/Vinay-Umrethe) **Created:** 11/19/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (10+) - [`b48bc29`](https://github.com/p-e-w/heretic/commit/b48bc29c8394dbc7705e5267dc9c01c6f66e5b88) feat: Notebook compatibility, Multimodal support (InternVL/Qwen/Omni/VL), and trust_remote_code - [`b3bb83f`](https://github.com/p-e-w/heretic/commit/b3bb83fd5f9a557b3ba97d7ccb3b7f7e839adc19) fix: Applied upstream fixes (multi-GPU support, memory optimization, KeyError fix) TO THE ENHANCED EDITION - [`b54e726`](https://github.com/p-e-w/heretic/commit/b54e72644d708bc3da493c21efe3cd048b807b2e) fix: Restore accidentally deleted MPS support and GPU fallback logic - [`43a1c25`](https://github.com/p-e-w/heretic/commit/43a1c25a0b078904ca0e069dbb6d7a89e5bf591f) fix: Complete upstream sync (restore missing import gc and PYTORCH_CUDA_ALLOC_CONF) - [`e568901`](https://github.com/p-e-w/heretic/commit/e568901360820cadbe4fe9aff0377f2214012cb5) chore: Revert metadata changes (name, version, readme) to match upstream - [`955e6cb`](https://github.com/p-e-w/heretic/commit/955e6cb94a6cf5e3a910dce04bf5aed749daf6ea) Updated README - [`8d8727f`](https://github.com/p-e-w/heretic/commit/8d8727f120f795ff3c643228317bd8ea3eabf89c) Merge branch 'master' into master - [`c73689b`](https://github.com/p-e-w/heretic/commit/c73689b893f0a98de447ed3e2bb03ed17886c44b) fix: Resolve CI failures (formatting, missing imports, package name) - [`1abcf8e`](https://github.com/p-e-w/heretic/commit/1abcf8e2956b97fc36318a6bd86e0ca5e4da3e15) Merge branch 'master' of https://github.com/Vinayyyy7/heretic - [`1d47b35`](https://github.com/p-e-w/heretic/commit/1d47b35aa7a2c46a3b55b0098af141567b6668b6) style: Fix formatting in utils.py to pass CI ### 📊 Changes **6 files changed** (+241 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `pyproject.toml` (+1 -1) 📝 `src/heretic/config.py` (+1 -0) 📝 `src/heretic/main.py` (+16 -15) 📝 `src/heretic/model.py` (+115 -17) 📝 `src/heretic/utils.py` (+107 -0) 📝 `uv.lock` (+1 -1) </details> ### 📄 Description ## This PR significantly enhances Heretic's compatibility with notebook environments (Colab/Kaggle) and extends support to modern multimodal models. ### Key Changes 1. **Notebook Compatibility**: * Replaced `questionary` arrow-key menus with robust numeric input loops. This fixes "CPR" warnings and usability issues in non-TUI environments like Google Colab. * Added a `/exit` command to the chat loop for graceful termination. Returing to the menu. 2. **Multimodal Model Support**: * Implemented dynamic model class loading in `model.py`. * Added support for: | Model Family | Example Models (Hugging Face ID) | | :--- | :--- | | **Qwen 2.5 VL** | `Qwen/Qwen2.5-VL-7B-Instruct`, `Qwen/Qwen2.5-VL-3B-Instruct` | | **Qwen 3 VL** | `Qwen/Qwen3-VL-4B-Instruct`, `Qwen/Qwen3-VL-2B-Instruct` | | **Qwen 3 VL MoE** | `Qwen/Qwen3-VL-235B-A22B-Instruct`, `Qwen/Qwen3-VL-30B-A3B-Instruct` | | **Qwen 2.5 Omni** | `Qwen/Qwen2.5-Omni-7B`, `Qwen/Qwen2.5-Omni-3B` | | **Qwen 3 Omni** | `Qwen/Qwen3-Omni-30B-A3B-Instruct`, `Qwen/Qwen3-Omni-30B-A3B-Thinking` | | **InternVL 3.5** | `OpenGVLab/InternVL3_5-8B-HF`, `OpenGVLab/InternVL3_5-2B-HF` | | **Gemma 3 / 3n** | `google/gemma-3-4b-it`, `google/gemma-3n-4b-it` | - Expanded `get_layers()` to handle nested structures in VL models. 3. **Custom Code Support**: * Added `--trust-remote-code` flag (default: `False`) to allow loading models with custom modeling code (required for InternVL, etc.). 4. **Robustness**: * Added `bfloat16` to the default dtype list. * Implemented generation fallbacks: retries with `pixel_values=None` or dummy tensors to handle picky VL models that crash on text-only inputs. 5. **Upstream Sync**: * Manually applied recent upstream fixes for multi-GPU support, memory optimization, and the Hugging Face profile `KeyError`. * Needed a Manual update for this, since these fixes from your side, were implmented Today `(Nov 19, 2025, 5:32 AM GMT+5:30)` just 1-2 hours after I enhanced it. DONE ✅ Tested successfully on Google Colab with `OpenGVLab/InternVL3_5-2B-HF` , `Qwen/Qwen2.5-Omni-3B`, `Qwen3-VL-2B-Insturct` and `Qwen/Qwen2.5-VL-3B-Instruct`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 04:19:08 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#241
No description provided.