Model reference · open weights

granite-code-2k

LLMs ibm-granite Text gen 1 build Open weights 39k dl/mo

granite-code-2k is an open-weight language model from IBM. granite-3b-code-base-2k (BF16) weighs 7.0 GB; the smallest configuration that runs it is RTX 3060 12 GB.

  • Granite-3B-Code-Base-2K is a 3.5B parameter decoder-only model developed by IBM for code generation, explanation, and fixing tasks.
  • It was trained on 4 trillion tokens covering 116 programming languages and has a context length of 2048 tokens.
  • The model is released under the Apache 2.0 license and is currently deprecated for new projects.

Summary of the ibm-granite/granite-3b-code-base-2k model card, 2026-10-01

What it is

Released byIBM
Released2024-04-23
Parameters3.5B
VRAM7.0 GB for the weights

What it runs on

Memory and cards for granite-3b-code-base-2k (BF16)

7.0 GBweights, file size
328 MBcache per 1K tokens
606 MBruntime overhead, at least
2,048 tokenscontext max
CardRequests at onceContext maxMemory
2K each
RTX 3060 12 GB6all 2K11.6 GB
RTX 4060 Ti 16 GB11all 2K15.4 GB
RTX 3090 24 GB23all 2K23.4 GB
RTX 4090 24 GB23all 2K23.4 GB
RTX 5090 32 GB34all 2K31.0 GB
L40S 48 GB54all 2K44.0 GB
A100 80 GB105all 2K78.2 GB
H100 80 GB100all 2K78.1 GB
RTX PRO 6000 Blackwell 96 GB123all 2K93.8 GB
DGX Spark (GB10) 128 GB unified144all 2K107 GB
H200 141 GB189all 2K138 GB
B200 180 GB245all 2K176 GB
2× RTX 3060 12 GB
tensor parallel
22all 2K11.6 GB a card
Memory needed at each load
Requests at once2K tokens each
18.2 GB
510.9 GB
812.9 GB
1618.3 GB
3229.0 GB
6450.5 GB

One card, with vLLM's small-card settings.

From the model card

What IBM says about granite-code-2k

Read the model card

⚠️ DEPRECATION WARNING ⚠️

⚠️ NOT RECOMMENDED FOR USE IN NEW PROJECTS ⚠️

New applications/projects should use the latest mainline Granite language model family, whose code capabilities supercede this model. This model is being made available strictly for historical/scientific purposes. Please see our Granite Collections for the latest Granite releases.


Granite-3B-Code-Base-2K

Model Summary

Granite-3B-Code-Base-2K is a decoder-only code model designed for code generative tasks (e.g., code generation, code explanation, code fixing, etc.). It is trained from scratch with a two-phase training strategy. In phase 1, our model is trained on 4 trillion tokens sourced from 116 programming languages, ensuring a comprehensive understanding of programming languages and syntax. In phase 2, our model is trained on 500 billion tokens with a carefully designed mixture of high-quality data from code and natural language domains to improve the models’ ability to reason and follow instructions.

Usage

Intended use

Prominent enterprise use cases of LLMs in software engineering productivity include code generation, code explanation, code fixing, generating unit tests, generating documentation, addressing technical debt issues, vulnerability detection, code translation, and more. All Granite Code Base models, including the 3B parameter model, are able to handle these tasks as they were trained on a large amount of code data from 116 programming languages.

Generation

This is a simple example of how to use Granite-3B-Code-Base-2K model.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # or "cpu"
model_path = "ibm-granite/granite-3b-code-base-2k"
tokenizer = AutoTokenizer.from_pretrained(model_path)
# drop device_map if running on CPU
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()
# change input text as desired
input_text = "def generate():"
# tokenize the text
input_tokens = tokenizer(input_text, return_tensors="pt")
# transfer tokenized inputs to the device
for i in input_tokens:
    input_tokens[i] = input_tokens[i].to(device)
# generate output tokens
output = model.generate(**input_tokens)
# decode output tokens into text
output = tokenizer.batch_decode(output)
# loop over the batch to print, in this example the batch size is 1
for i in output:
    print(i)

Training Data

  • Data Collection and Filtering: Pretraining code data is sourced from a combination of publicly available datasets (e.g., GitHub Code Clean, Starcoder data), and additional public code repositories and issues from GitHub. We filter raw data to retain a list of 116 programming languages. After language filtering, we also filter out low-quality code.
  • Exact and Fuzzy Deduplication: We adopt an aggressive deduplication strategy that includes both exact and fuzzy deduplication to remove documents having (near) identical code content.
  • HAP, PII, Malware Filtering: We apply a HAP content filter that reduces models' likelihood of generating hateful, abusive, or profane language. We also make sure to redact Personally Identifiable Information (PII) by replacing PII content (e.g., names, email addresses, keys, passwords) with corresponding tokens (e.g., ⟨NAME⟩, ⟨EMAIL⟩, ⟨KEY⟩, ⟨PASSWORD⟩). Moreover, we scan all datasets using ClamAV to identify and remove instances of malware in the source code.
  • Natural Language Datasets: In addition to collecting code data for model training, we curate several publicly available high-quality natural language datasets to improve models' proficiency in language understanding and mathematical reasoning. Unlike the code data, we do not deduplicate these datasets.

Infrastructure

We train the Granite Code models using two of IBM's super computing clusters, namely Vela and Blue Vela, both outfitted with NVIDIA A100 and H100 GPUs respectively. These clusters provide a scalable and efficient infrastructure for training our models over thousands of GPUs.

Ethical Considerations and Limitations

The use of Large Language Models involves risks and ethical considerations people must be aware of. Regarding code generation, caution is urged against complete reliance on specific code models for crucial decisions or impactful information as the generated code is not guaranteed to work as intended. Granite-3B-Code-Base-2K model is not the exception in this regard. Even though this model is suited for multiple code-related tasks, it has not undergone any safety alignment, there it may produce problematic outputs. Additionally, it remains uncertain whether smaller models might exhibit increased susceptibility to hallucination in generation scenarios by copying source code verbatim from the training dataset due to their reduced sizes and memorization capacities. This aspect is currently an active area of research, and we anticipate more rigorous exploration, comprehension, and mitigations in this domain. Regarding ethics, a latent risk associated with all Large Language Models is their malicious utilization. We urge the community to use Granite-3B-Code-Base-2K model with ethical intentions and in a responsible way.

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

Benchmarks

Reported results

As published on the model card: the maker's own numbers, not measured by AxForge.

TaskDatasetMetricScore
text-generationMBPPpass@136
text-generationMBPP+pass@145.100
text-generationHumanEvalSynthesis(Python)pass@136.600
text-generationHumanEvalSynthesis(JavaScript)pass@137.200
text-generationHumanEvalSynthesis(Java)pass@140.900
text-generationHumanEvalSynthesis(Go)pass@126.200
text-generationHumanEvalSynthesis(C++)pass@135.400
text-generationHumanEvalSynthesis(Rust)pass@122
text-generationHumanEvalExplain(Python)pass@125
text-generationHumanEvalExplain(JavaScript)pass@118.900
text-generationHumanEvalExplain(Java)pass@129.900
text-generationHumanEvalExplain(Go)pass@117.100
text-generationHumanEvalExplain(C++)pass@126.800
text-generationHumanEvalExplain(Rust)pass@114
text-generationHumanEvalFix(Python)pass@118.300
text-generationHumanEvalFix(JavaScript)pass@123.200
text-generationHumanEvalFix(Java)pass@129.900
text-generationHumanEvalFix(Go)pass@124.400
text-generationHumanEvalFix(C++)pass@116.500
text-generationHumanEvalFix(Rust)pass@13.700
© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms