Skip to content

fix(formatters): pass input_ids to model.generate() so peft can compute aLoRA offsets - #1294

Closed
planetf1 wants to merge 1 commit into
generative-computing:mainfrom
planetf1:issue-1286
Closed

fix(formatters): pass input_ids to model.generate() so peft can compute aLoRA offsets#1294
planetf1 wants to merge 1 commit into
generative-computing:mainfrom
planetf1:issue-1286

Conversation

@planetf1

@planetf1 planetf1 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Problem

context_relevance_alora and uncertainty_alora intrinsic tests fail on CPU (and GPU) because PEFT cannot compute aLoRA prefix offsets. The warning confirms the root cause:

Cannot calculate aLoRA offsets during generate as input_ids are not available. Disabling aLoRA.

When aLoRA fails, PEFT silently falls back to standard LoRA. Most intrinsics tolerate this, but context_relevance and uncertainty produce wrong or truncated JSON output.

Root Cause

mellea/formatters/granite/base/util.py:396 — the call to model.generate() uses inputs= instead of the canonical input_ids=:

generate_result = model.generate(inputs=input_tokens, **generate_input)

PEFTs aLoRA hook inspects the input_ids kwarg at runtime. Missing it → aLoRA disabled.

Fix

One-line change: inputs=input_ids= in generate_with_transformers().

Testing

  • All 4 aLoRA formatter tests pass with the fix: context_relevance_alora, uncertainty_alora, answerability_answerable_alora, requirement_check_alora
  • Full test suite: 1237+ tests pass, 0 regressions (the only other failure was a pre-existing timeout in query_clarification which was confirmed by reverting this change and re-running that test with the same result)
  • Pre-commit checks (ruff format, ruff check, mypy, codespell) all pass
  • Confirmed against upstream/main: branch rebased on 317d5d9d

Closes #1286

@github-actions github-actions Bot added the bug Something isn't working label Jun 18, 2026
…te aLoRA offsets

generate_with_transformers() used inputs= instead of input_ids= when
calling model.generate(), causing pefts aLoRA hook to silently fall back
to standard LoRA. This affected context_relevance and uncertainty
intrinsics which produce wrong or truncated output without aLoRA.

Closes generative-computing#1286

Assisted-by: opencode
Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
@planetf1

Copy link
Copy Markdown
Contributor Author

Just to be explicit on the broader impact: generate_with_transformers() is the core inference utility for the LocalHFBackend. This is not just a test failure—it means any user running these intrinsics via the HF backend silently gets degraded output (truncated JSON or wrong scores) because PEFT transparently disables aLoRA and falls back to standard LoRA.

@planetf1
planetf1 marked this pull request as ready for review June 19, 2026 04:06
@planetf1
planetf1 requested a review from a team as a code owner June 19, 2026 04:06
@planetf1 planetf1 closed this Jun 19, 2026
@planetf1

Copy link
Copy Markdown
Contributor Author

Closed, as it is easy to test/validate that the full set of adapter functions.
Superceeded by 1292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: context_relevance_alora and uncertainty_alora fail on CPU — peft cannot compute aLoRA offsets without input_ids

1 participant