ibm-research / granite-7b-lab-accelerator

huggingface.co
Total runs: 20
24-hour runs: 0
7-day runs: 0
30-day runs: 11
Model's Last Updated: May 15 2024

Introduction of granite-7b-lab-accelerator

Model Details of granite-7b-lab-accelerator

Installation from source
git clone https://github.com/foundation-model-stack/fms-extras
cd fms-extras
pip install -e .
Description

This model is intended to be used as an accelerator for granite 7B (instruct lab) and takes inspiration from the Medusa speculative decoding architecture. This accelerator modifies the MLP into a multi-stage MLP, where each stage predicts a single token in the draft based on both a state vector and sampled token from the prior stage (the base model can be considered stage 0). The state vector from the base model provides contextual information to the accelerator, while conditioning on prior sampled tokens allows it to produce higher-quality draft n-grams.

Note: The underlying MLP speculator is a generic architecture that can be trained with any generative model to accelerate inference. Training is light-weight and can be completed in only a few days depending on base model size and speed.

Repository Links
  1. Paged Attention KV-Cache / Speculator
  2. Production Server with speculative decoding
  3. Speculator training
Samples

Note: For all samples, your environment must have access to cuda

Use in IBM Production TGIS

To try this out running in a production-like environment, please use the pre-built docker image:

Setup
HF_HUB_CACHE=/hf_hub_cache
chmod a+w $HF_HUB_CACHE
HF_HUB_TOKEN="your huggingface hub token"
TGIS_IMAGE=quay.io/wxpe/text-gen-server:main.ddc56ee

docker pull $TGIS_IMAGE

# optionally download granite-7b-lab if the weights do not already exist
docker run --rm \
    -v $HF_HUB_CACHE:/models \
    -e HF_HUB_CACHE=/models \
    -e TRANSFORMERS_CACHE=/models \
    $TGIS_IMAGE \
    text-generation-server download-weights \
    instructlab/granite-7b-lab \
    --token $HF_HUB_TOKEN

# optionally download the speculator model if the weights do not already exist
docker run --rm \
    -v $HF_HUB_CACHE:/models \
    -e HF_HUB_CACHE=/models \
    -e TRANSFORMERS_CACHE=/models \
    $TGIS_IMAGE \
    text-generation-server download-weights \
    ibm/granite-7b-lab-accelerator \
    --token $HF_HUB_TOKEN

# note: if the weights were downloaded separately (not with the above commands), please place them in the HF_HUB_CACHE directory and refer to them with /models/<model_name>
docker run -d --rm --gpus all \
    --name my-tgis-server \
    -p 8033:8033 \
    -v $HF_HUB_CACHE:/models \
    -e HF_HUB_CACHE=/models \
    -e TRANSFORMERS_CACHE=/models \
    -e MODEL_NAME=instructlab/granite-7b-lab \
    -e SPECULATOR_NAME=ibm/granite-7b-lab-accelerator \
    -e FLASH_ATTENTION=true \
    -e PAGED_ATTENTION=true \
    -e DTYPE=float16 \
    $TGIS_IMAGE

# check logs and wait for "gRPC server started on port 8033" and "HTTP server started on port 3000"
docker logs my-tgis-server -f

# get the client sample (Note: The first prompt will take longer as there is a warmup time)
conda create -n tgis-client-env python=3.11
conda activate tgis-client-env
git clone --branch main --single-branch https://github.com/IBM/text-generation-inference.git
cd text-generation-inference/integration_tests
make gen-client
pip install . --no-cache-dir
Run Sample
python sample_client.py

Note: first prompt may be slower as there is a slight warmup time

Use in Huggingface TGI
start the server
model=ibm/granite-7b-lab-accelerator
volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:latest --model-id $model

note: for tensor parallel, add --num-shard

make a request
curl 127.0.0.1:8080/generate_stream \
    -X POST \
    -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":20}}' \
    -H 'Content-Type: application/json'
Minimal Sample

To try this out with the fms-native compiled model, please execute the following:

Install
git clone --branch ibm_7b_instruct_lab_variant --single-branch https://github.com/JRosenkranz/fms-extras.git
(cd fms-extras && pip install -e .)
pip install transformers==4.35.0 sentencepiece numpy
Run Sample
batch_size=1 (compile + cudagraphs)
MODEL_PATH=/path/to/instructlab/granite-7b-lab
python fms-extras/scripts/paged_speculative_inference.py \
    --variant=7b.ibm_instruct_lab \
    --model_path=$MODEL_PATH \
    --model_source=hf \
    --tokenizer=$MODEL_PATH \
    --speculator_path=ibm/granite-7b-lab-accelerator \
    --speculator_source=hf \
    --speculator_variant=1_4b \
    --top_k_tokens_per_head=4,3,2,2,2 \
    --compile \
    --compile_mode=reduce-overhead
batch_size=1 (compile)
MODEL_PATH=/path/to/instructlab/granite-7b-lab
python fms-extras/scripts/paged_speculative_inference.py \
    --variant=7b.ibm_instruct_lab \
    --model_path=$MODEL_PATH \
    --model_source=hf \
    --tokenizer=$MODEL_PATH \
    --speculator_path=ibm/granite-7b-lab-accelerator \
    --speculator_source=hf \
    --speculator_variant=1_4b \
    --top_k_tokens_per_head=4,3,2,2,2 \
    --compile
batch_size=4 (compile)
MODEL_PATH=/path/to/instructlab/granite-7b-lab
python fms-extras/scripts/paged_speculative_inference.py \
    --variant=7b.ibm_instruct_lab \
    --model_path=$MODEL_PATH \
    --model_source=hf \
    --tokenizer=$MODEL_PATH \
    --speculator_path=ibm/granite-7b-lab-accelerator \
    --speculator_source=hf \
    --speculator_variant=1_4b \
    --top_k_tokens_per_head=4,3,2,2,2 \
    --batch_input \
    --compile

Runs of ibm-research granite-7b-lab-accelerator on huggingface.co

20
Total runs
0
24-hour runs
2
3-day runs
0
7-day runs
11
30-day runs

More Information About granite-7b-lab-accelerator huggingface.co Model

More granite-7b-lab-accelerator license Visit here:

https://choosealicense.com/licenses/llama2

granite-7b-lab-accelerator huggingface.co

granite-7b-lab-accelerator huggingface.co is an AI model on huggingface.co that provides granite-7b-lab-accelerator's model effect (), which can be used instantly with this ibm-research granite-7b-lab-accelerator model. huggingface.co supports a free trial of the granite-7b-lab-accelerator model, and also provides paid use of the granite-7b-lab-accelerator. Support call granite-7b-lab-accelerator model through api, including Node.js, Python, http.

granite-7b-lab-accelerator huggingface.co Url

https://huggingface.co/ibm-research/granite-7b-lab-accelerator

ibm-research granite-7b-lab-accelerator online free

granite-7b-lab-accelerator huggingface.co is an online trial and call api platform, which integrates granite-7b-lab-accelerator's modeling effects, including api services, and provides a free online trial of granite-7b-lab-accelerator, you can try granite-7b-lab-accelerator online for free by clicking the link below.

ibm-research granite-7b-lab-accelerator online free url in huggingface.co:

https://huggingface.co/ibm-research/granite-7b-lab-accelerator

granite-7b-lab-accelerator install

granite-7b-lab-accelerator is an open source model from GitHub that offers a free installation service, and any user can find granite-7b-lab-accelerator on GitHub to install. At the same time, huggingface.co provides the effect of granite-7b-lab-accelerator install, users can directly use granite-7b-lab-accelerator installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

granite-7b-lab-accelerator install url in huggingface.co:

https://huggingface.co/ibm-research/granite-7b-lab-accelerator

Url of granite-7b-lab-accelerator

granite-7b-lab-accelerator huggingface.co Url

Provider of granite-7b-lab-accelerator huggingface.co

ibm-research
ORGANIZATIONS

Other API from ibm-research

huggingface.co

Total runs: 38.3K
Run Growth: -38.5K
Growth Rate: -114.23%
Updated:March 20 2026
huggingface.co

Total runs: 19.5K
Run Growth: -25.7K
Growth Rate: -106.27%
Updated:September 16 2024
huggingface.co

Total runs: 4.3K
Run Growth: 296
Growth Rate: 5.05%
Updated:March 24 2026
huggingface.co

Total runs: 4.0K
Run Growth: -7.8K
Growth Rate: -187.57%
Updated:January 18 2025
huggingface.co

Total runs: 1.4K
Run Growth: -832
Growth Rate: -54.88%
Updated:October 12 2022