Instructions to use ibm-granite/granite-4.2-8b-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ibm-granite/granite-4.2-8b-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Use Docker
docker model run hf.co/ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use ibm-granite/granite-4.2-8b-GGUF with Ollama:
ollama run hf.co/ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
- Unsloth Desktop
- Pi
How to use ibm-granite/granite-4.2-8b-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ibm-granite/granite-4.2-8b-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use ibm-granite/granite-4.2-8b-GGUF with Docker Model Runner:
docker model run hf.co/ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
- Lemonade
How to use ibm-granite/granite-4.2-8b-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.granite-4.2-8b-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use ibm-granite/granite-4.2-8b-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ibm-granite/granite-4.2-8b-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ibm-granite/granite-4.2-8b-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "ibm-granite/granite-4.2-8b-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
| from typing import Sequence | |
| import vllm | |
| from vllm.reasoning.abs_reasoning_parsers import ReasoningParserManager | |
| from vllm.reasoning.deepseek_r1_reasoning_parser import DeepSeekR1ReasoningParser | |
| _VLLM_VERSION = tuple(int(x) for x in vllm.__version__.split(".")[:2]) | |
| # --- Monkeypatch for vLLM >= 0.20 (no upstream hook exists) --- | |
| # Patches DelegatingParser.parse_delta to strip leading \n from content | |
| # at the reasoning->content boundary. | |
| if _VLLM_VERSION >= (0, 20): | |
| try: | |
| from vllm.parser.abstract_parser import DelegatingParser | |
| _original_parse_delta = DelegatingParser.parse_delta | |
| # v0.20-0.22: parse_delta(self, delta_text, delta_token_ids, request, prompt_token_ids=None) | |
| # v0.23+: parse_delta(..., *, finished: bool) | |
| # Use **kwargs to accept both signatures. | |
| # | |
| # State is tracked on the DelegatingParser instance (self), not in a | |
| # global dict. This is safe because vLLM creates a new DelegatingParser | |
| # per streaming request (confirmed in serving.py for v0.20 through v0.28). | |
| # This avoids the id(request) reuse bug on v0.20-0.22 where Python | |
| # recycles memory addresses and stale flags cause intermittent leaks. | |
| def _patched_parse_delta(self, delta_text, delta_token_ids, request, | |
| prompt_token_ids=None, **kwargs): | |
| result = _original_parse_delta( | |
| self, delta_text, delta_token_ids, request, | |
| prompt_token_ids, **kwargs) | |
| if result is not None and getattr(result, "content", None) is not None: | |
| if not getattr(self, "_granite_content_started", False): | |
| stripped = result.content.lstrip("\n") | |
| if not stripped: | |
| result.content = None | |
| else: | |
| self._granite_content_started = True | |
| result.content = stripped | |
| return result | |
| DelegatingParser.parse_delta = _patched_parse_delta | |
| except (ImportError, AttributeError): | |
| pass | |
| class GraniteThinkingParser(DeepSeekR1ReasoningParser): | |
| def extract_reasoning(self, model_output, request): | |
| reasoning_content, final_content = super().extract_reasoning( | |
| model_output, request | |
| ) | |
| if final_content is not None: | |
| final_content = final_content.lstrip("\n") | |
| if ( | |
| hasattr(request, "chat_template_kwargs") | |
| and request.chat_template_kwargs | |
| and ( | |
| request.chat_template_kwargs.get("enable_thinking") is False | |
| or request.chat_template_kwargs.get("force_nonempty_content") is True | |
| ) | |
| and final_content is None | |
| ): | |
| reasoning_content, final_content = None, reasoning_content | |
| return reasoning_content, final_content | |
| # --- vLLM < 0.20: use extract_reasoning_streaming --- | |
| if _VLLM_VERSION < (0, 20): | |
| def extract_reasoning_streaming( | |
| self, | |
| previous_text: str, | |
| current_text: str, | |
| delta_text: str, | |
| previous_token_ids: Sequence[int], | |
| current_token_ids: Sequence[int], | |
| delta_token_ids: Sequence[int], | |
| ): | |
| """Strip leading newlines from streaming content deltas.""" | |
| result = super().extract_reasoning_streaming( | |
| previous_text, | |
| current_text, | |
| delta_text, | |
| previous_token_ids, | |
| current_token_ids, | |
| delta_token_ids, | |
| ) | |
| if result is None: | |
| return None | |
| if result.content is not None and self.end_token_id in previous_token_ids: | |
| end_pos = None | |
| for i in range(len(previous_token_ids) - 1, -1, -1): | |
| if previous_token_ids[i] == self.end_token_id: | |
| end_pos = i | |
| break | |
| if end_pos is not None: | |
| content_token_ids_so_far = previous_token_ids[end_pos + 1:] | |
| if len(content_token_ids_so_far) == 0 or all( | |
| self.model_tokenizer.decode([tid]).strip("\n") == "" | |
| for tid in content_token_ids_so_far | |
| ): | |
| stripped = result.content.lstrip("\n") | |
| if not stripped: | |
| return None | |
| return type(result)(content=stripped) | |
| return result | |