Skip to content

feat: update granite library examples to use Granite 4.1 3B adapters.#981

Merged
nrfulton merged 13 commits intogenerative-computing:mainfrom
nrfulton:nathan/intrinsic_examples_version_bump
May 1, 2026
Merged

feat: update granite library examples to use Granite 4.1 3B adapters.#981
nrfulton merged 13 commits intogenerative-computing:mainfrom
nrfulton:nathan/intrinsic_examples_version_bump

Conversation

@nrfulton
Copy link
Copy Markdown
Member

@nrfulton nrfulton commented Apr 30, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

The commented-out code in intrinsics.py still needs to be changed.

Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
@nrfulton nrfulton requested a review from a team as a code owner April 30, 2026 20:44
@github-actions
Copy link
Copy Markdown
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

Comment thread docs/examples/intrinsics/intrinsics.py Outdated
# model. See docs/examples/granite-switch/ for a full runnable example.
# from mellea.backends.openai import OpenAIBackend
# from mellea.backends.model_ids import IBM_GRANITE_SWITCH_4_1_3B
# from mellea.backends.model_ids import IBM_GRANITE_4_1_3B
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented out one is supposed to be a SWITCH alternative. I'm thinking this was a search/replace mistake.

If you intentionally did rename switch -> 4.1 3B, then the other commented references below were missed. Also the alternative would probably not be needed anymore or at least need different comments that explain.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the commented-out code in intrinsics.py still needs to be changed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted that line thanks for catching.

@nrfulton nrfulton changed the title Update granite library examples to use Granite 4.1 3B adapters. feat: update granite library examples to use Granite 4.1 3B adapters. Apr 30, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Apr 30, 2026
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
@nrfulton
Copy link
Copy Markdown
Member Author

We're waiting to merge this one until all of the 4.1 library models are in the HF ibm-granite granite library collection repos.

@planetf1
Copy link
Copy Markdown
Contributor

planetf1 commented May 1, 2026

uncertainty.py and requirement_check.py haven't had the same change? Omission?

@planetf1
Copy link
Copy Markdown
Contributor

planetf1 commented May 1, 2026

For factuality-detection.py and factuality-correction.py there isn't get a granite-4.1-3b intrinsic in the repo -- is this expected to be there soon -- before the PR merges?

Copy link
Copy Markdown
Contributor

@planetf1 planetf1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few other things I noticed - unsure if this is out of scope of this pr and/or will be addressed on another issue/pr ?

  • AGENTS.md still refers to the granite-4.0-micro model
  • similar in various places in our published docs
  • does the start_backend default need updating ? (it's granite 4 for now)
  • I don't see granite-4.1:3b in the BASE_MODEL_TO_CANONICAL_NAME - no sign of granite-4.1-3b there yet?

nrfulton added 5 commits May 1, 2026 11:36
 * context_relevance: use 4.0 and leave comment explaining why.
 * requirement check: switch to 4.1
 * uncertainty: switch to 4.1

Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
long-term it probably makes sense to add another column to the
intrinsics list.

Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
@nrfulton nrfulton requested a review from a team as a code owner May 1, 2026 15:48
@nrfulton
Copy link
Copy Markdown
Member Author

nrfulton commented May 1, 2026

Thanks, @planetf1 !

uncertainty.py and requirement_check.py haven't had the same change? Omission?

Yes; fixed.

For factuality-detection.py and factuality-correction.py there isn't get a granite-4.1-3b intrinsic in the repo -- is this expected to be there soon -- before the PR merges?

They're being staged; those will exist for 4.1 prior to release. The context_relevance intrinsic will not exist for 4.1, so I reverted that example to 4.0.

AGENTS.md still refers to the granite-4.0-micro model

Fixed.

similar in various places in our published docs

Doing a sweep now. A bit more annoying to find everything :) Update: did a sweep of the docs and tests, and changed everything that I thought made sense. The 4.0 models still get mentioned in certain places, and I think those remaining mentions are okay:

  1. design docs that were written at 4.0 vintage -- preserving the model ids that were used at the time those decisions were made is best practice.
  2. some docs that are specifically about h vs non-h (we don't have h in 4.1 so arguably those could be removed entirely, but I'll leave that for later because the 4.0 models will remain in common use for a while)
  3. some other misc places where I judged keeping the 4.0 reference is reasonable.

@planetf1 what repos should I be sweeping (in addition to this one)?

does the start_backend default need updating ? (it's granite 4 for now)

This was already done by #964; I just hadn't merged main in a minute.

I don't see granite-4.1:3b in the BASE_MODEL_TO_CANONICAL_NAME - no sign of granite-4.1-3b there yet?

Done.

nrfulton added 2 commits May 1, 2026 11:54
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
@nrfulton
Copy link
Copy Markdown
Member Author

nrfulton commented May 1, 2026

Current status: there are three examples still failing:

  • fact correction: no worries so far; still staging looks good.
  • fact detection: no worries so far; still staging looks good.
  • context_relevance: need to investigate. this is the transformations vs parameters bug in the io.yaml for that intrinsic. It's also the reason tests are failing on this PR. Fix is in-flight over on HF. Fix is in on HF; should be good here now.

@nrfulton
Copy link
Copy Markdown
Member Author

nrfulton commented May 1, 2026

Saving a helper script here for the next release. Drop in the intrinsics dir; runs all of the local examples. Gives a tighter ooda than waiting on nightlies.

#!/usr/bin/env bash
set -uo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
entries="["
first=true

for py_file in "$SCRIPT_DIR"/*.py; do
    echo $py_file;
    filename="$(basename "$py_file")"
    stdout="$(uv run python "$py_file" 2>/tmp/_intrinsic_stderr)"
    exit_code=$?
    stderr="$(cat /tmp/_intrinsic_stderr)"
    entry="$(python3 -c "
import json, sys
print(json.dumps({
    'file': sys.argv[1],
    'exit_code': int(sys.argv[2]),
    'stdout': sys.argv[3],
    'stderr': sys.argv[4],
}))" "$filename" "$exit_code" "$stdout" "$stderr")"
    if [ "$first" = true ]; then
        first=false
    else
        entries+=", "
    fi
    entries+="$entry"
done

entries+="]"
echo "$entries" > "$SCRIPT_DIR/run_outputs.json"

one-liner to get failed tests:

python3 -c "import json
print('Failures:\n *','\n * '.join([failed['file'] for failed in json.load(open('run_outputs.json', 'r')) if failed['exit_code'] != 0]))"

nrfulton added 2 commits May 1, 2026 13:48
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
Signed-off-by: Nathan Fulton <gitcommit@nfulton.org>
Signed-off-by: Jake LoRocco <jake.lorocco@ibm.com>
@jakelorocco jakelorocco enabled auto-merge May 1, 2026 21:41
@jakelorocco jakelorocco added this pull request to the merge queue May 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 1, 2026
@nrfulton nrfulton added this pull request to the merge queue May 1, 2026
Merged via the queue into generative-computing:main with commit 753371b May 1, 2026
7 checks passed
@nrfulton nrfulton deleted the nathan/intrinsic_examples_version_bump branch May 1, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use Granite 4.1 in intrinsics examples.

4 participants