docling-project / docling-project/docling
ChartExtractionModelGraniteVisionV4 crashes on init: ImportError for HybridMambaAttentionDynamicCache (removed from transformers 5.x)
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
## Summary
`ChartExtractionModelGraniteVisionV4` (added in docling 2.88.0) crashes during pipeline initialisation with an `ImportError` because the `ibm-granite/granite-4.0-3b-vision` model's remote `modeling.py` imports `HybridMambaAttentionDynamicCache` from `transformers.models.granitemoehybrid.modeling_granitemoehybrid` — a class that was removed from transformers during the 4.x → 5.x cache refactoring.
## Error
```
ImportError: cannot import name 'HybridMambaAttentionDynamicCache' from
'transformers.models.granitemoehybrid.modeling_granitemoehybrid'
(/path/to/transformers/models/granitemoehybrid/modeling_granitemoehybrid.py)
```
## Traceback (abridged)
```
File "docling/pipeline/base_pipeline.py", line 191, in __init__
ChartExtractionModelGraniteVisionV4(...)
File "docling/models/stages/chart_extraction/granite_vision.py", line 73, in __init__
self._load_model(artifacts_path)
File "docling/models/stages/chart_extraction/granite_vision.py", line 362, in _load_model
self._model = AutoModelForImageTextToText.from_pretrained(
artifacts_path, trust_remote_code=True, ...
)
File "transformers/models/auto/auto_factory.py", line 369, in from_pretrained
model_class = get_class_from_dynamic_module(...)
...
File "~/.cache/huggingface/modules/transformers_modules/f0d034897bae1cd438c961c8c170a3a3089ebf01/modeling.py", line 19
from transformers.models.granitemoehybrid.modeling_granitemoehybrid import (
HybridMambaAttentionDynamicCache,
)
ImportError: cannot import name 'HybridMambaAttentionDynamicCache'
```
## Root cause
`ibm-granite/granite-4.0-3b-vision`'s remote `modeling.py` (current `main`) depends on `HybridMambaAttentionDynamicCache` from `transformers.models.granitemoehybrid`. This class does not exist in any released version of transformers 5.x, and is also absent from the transformers `main` branch. It existed in the 4.40.x era (introduced with the Jamba model) but was removed when the cache abstraction was overhauled in transformers 5.x.
Verified:
- `grep -r HybridMambaAttentionDynamicCache` across the entire transformers 5.5.4 install: **zero results**
- Same grep on transformers `main` (GitHub): **zero results**
- The ibm-granite model's `modeling.py` at current `main` and all recent commits (going back ~21 days): **import is still present**
A parallel issue has been filed against [ibm-granite/granite-4.0-3b-vision](https://huggingface.co/ibm-granite/granite-4.0-3b-vision/discussions).
## Environment
| | |
|---|---|
| docling | 2.88.0 |
| docling-ibm-models | 3.13.0 |
| transformers | 5.5.4 (latest) |
| Python | 3.14.4 |
| PyTorch | 2.11.0 |
| Platform | macOS 26.4.1 arm64 |
## Expected behaviour
`ChartExtractionModelGraniteVisionV4` loads without error when `transformers>=5.x` is installed.
## Suggested fix
Either:
1. Pin the `ibm-granite/granite-4.0-3b-vision` model download to a `revision` that uses the current transformers 5.x cache API, once IBM Granite publishes a compatible `modeling.py`; or
2. Coordinate with IBM Granite / HuggingFace transformers PR [#44445](https://github.com/huggingface/transformers/pull/44445) to restore or replace the missing class before releasing docling versions that enable this model.
Contributor guide
Assessment
This issue has not been assessed yet.