Skip to content

Fix/issue#490#491

Merged
HenryNdubuaku merged 3 commits intocactus-compute:mainfrom
lennartvoelz:fix/issue#490
Mar 4, 2026
Merged

Fix/issue#490#491
HenryNdubuaku merged 3 commits intocactus-compute:mainfrom
lennartvoelz:fix/issue#490

Conversation

@lennartvoelz
Copy link
Copy Markdown
Contributor

@lennartvoelz lennartvoelz commented Mar 4, 2026

This merge request fixes issue #490

The cactus convert pipeline broke in two related ways when working with merged LoRA models:

Tokenizer detection failed: The tokenizer lookup relied on model_id being a Hugging Face repo identifier (e.g. google/functiongemma-270m-it). When merging a LoRA adapter, model_id is set to a local filesystem path, which poisoned name-based detection logic (e.g. special token handling for Gemma models) and caused the sentence piece model lookup to fail entirely.

Merged model treated as HF repo: After merging, the merged weights are written to a temporary directory. The conversion pipeline then attempted to "download" this temp directory as if it were a remote Hugging Face repo ID.

Fix

Tokenizer (fix: tokenizer detection failed for LoRA merged models)

  • Introduced a separate name variable for model-name-based detection, decoupled from model_id (which may be a local path)
  • The sentence piece model is now copied from the LoRA directory directly, with a fallback to the base model in the HF cache
  • Tokenizer config is read locally when available

LoRA merge path handling (fix: treat merged LoRA temp dir as local model path)

  • Added a check whether model_id is a local directory before invoking the download/conversion step
  • If it is a local path (i.e. the merged temp directory), the path is passed directly into weight conversion, skipping the HF download logic entirely

Impact of the fixes

Before:
Bildschirmfoto 2026-03-04 um 15 10 32

After:
Bildschirmfoto 2026-03-04 um 15 12 44

-> The output also shows the special gemma tokens now

I ran the test suite and everything works fine

When `cactus convert` merges a LoRA adapter, it saves the merged model to a temp
directory and tries to “download” it as if it were a Hugging Face repo id.
The fix checks if the model_id is a local directory and passes the temp path directly into weight conversion by skipping the HF path

Signed-off-by: Lennart <[email protected]>
- copy sentence piece model from LoRA directory (or base model in the HF cache as a fallback) and read the tokenizer config locally if possible
- the model_id is a path in the merging case, which poisend the whole conversion chain -> replaced with a name variable for name-based detection (e.g. gemma special tokens)

Signed-off-by: Lennart <[email protected]>
@lennartvoelz
Copy link
Copy Markdown
Contributor Author

I added one more fix, so that the tokenizer config is also copied from the LoRA directory if present
Bildschirmfoto 2026-03-04 um 15 32 14

@HenryNdubuaku
Copy link
Copy Markdown
Collaborator

thanks for this @lennartvoelz !!!

@HenryNdubuaku HenryNdubuaku merged commit f2307c7 into cactus-compute:main Mar 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants