Repository navigation
Description
Problem
m alora add-readme always generates usage code that loads the trained
adapter via LocalFileBinding (or, before #1144, the deprecated
IntrinsicAdapter/CustomIntrinsicAdapter shims) — which only finds weights
at <name>/<base-model>/<lora|alora>/ inside the Hugging Face repo (see
adapter_subpath() in mellea/formatters/granite/intrinsics/util.py). But
m alora upload defaults to --intrinsic=False, which pushes weights flat
to the repo root instead (cli/alora/upload.py, path_in_repo=".").
A user following the CLI in the "obvious" order — train → upload →
add-readme (or add-readme → upload) — gets a broken pairing by default:
the generated README's own code fails with
ValueError: Intrinsic '<name>' as aLoRA adapter on base model '<base-model>'
not found in <repo> repository on Hugging Face Hub. Searched for path
<name>/<base-model>/alora/*
The fix already exists and works — m alora upload ... --intrinsic --io-yaml ./io.yaml pushes into the correct nested layout (upload_intrinsic() in
cli/alora/intrinsic_uploader.py) — but nothing in the CLI's own flow
surfaces that requirement until the user hits this error.
Reproducer
m alora train ./data.jsonl --base-model ibm-granite/granite-4.1-3b --output ./adapter
m alora upload ./adapter --name your-org/my-adapter # no --intrinsic
m alora add-readme ./adapter --name your-org/my-adapter --dataset ./data.jsonlThen run the generated INTRINSIC_README.md's own example code — it raises
the ValueError above.
Expected behavior
Some combination of:
add-readmedetects (or is told) whether the target repo actually has the
intrinsic-style layout, and warns/refuses if not, rather than generating
code that's guaranteed to fail.uploadmakes the intrinsic path harder to miss — e.g. a clearer error
whenadd-readme's generated usage pattern won't work against a flat
upload, or defaulting--intrinsictoTrue(a breaking CLI change,
needs its own deprecation consideration — plain, non-intrinsic adapter
publishing viam alora uploadwith no flags is also a legitimate,
intentional use case, so this isn't a clear-cut default flip).
Filed as needs-design rather than proposing a specific fix — the right
tradeoff between the two workflows (plain PEFT publishing vs.
intrinsic/adapter-function publishing) needs discussion before implementation.
Context
Found while verifying
#1619 (part of
#1144)'s new "Adding a custom adapter function" tutorial end-to-end against
real hardware. That PR adds an explicit caveat to the tutorial and to the
CLI-generated README template pointing at --intrinsic --io-yaml as a
stopgap, but the underlying CLI ergonomics gap is unrelated to the
shim-vs-composed-Adapter change #1619 makes, and predates it — the
deprecated IntrinsicAdapter/CustomIntrinsicAdapter shims have the exact
same layout requirement, so this isn't a regression from that work.
Activity
fix(backends): fix Qwen-review findings on composed-Adapter path (gen…
feat(backends): accept composed Adapter directly (Epic generative-com…
markstur commentedon Nov 12, 2026
Design proposal: make
m alora add-readmematch the repository layout (#1620)Status: proposal for discussion — no PR yet
Prototype:
fix/issue-1620@f13d382on the forkCompatibility: non-breaking; no defaults flipped
Problem
m alora uploadwrites weights to the repository root unless--intrinsic --io-yamlis passed. That is the default and a legitimate way to publish a plain PEFT adapter.
m alora add-readmealways rendered exactly one sample: compose anAdapterwithLocalFileBinding, which searches<name>/<base-model>/<lora|alora>/. Against a flatupload, the generated README's own example fails with:
The problem is not that two layouts exist. It is that nothing in the CLI flow surfaces
which layout the README is documenting, so the failure lands on whoever runs the
generated code later.
Goals
train → upload → add-readme— produces a README whose sampleruns, for either upload layout.
Non-goals
upload's--intrinsicdefault.io.yaml.Proposed behavior
Resolution order
--layout intrinsicor--layout flatwins; no network call.HfApi.list_repo_files.which layout you intend to upload.
Detection rule
Every intrinsic-layout file is nested under the intrinsic name; a flat upload leaves
weights at the root. This holds for both the current
<name>/<model>/<type>/layout andthe older
<name>/<type>/<model>/ordering, and needs no base-model normalization.State matrix
--layout autointrinsicAdapter+LocalFileBinding+IntrinsicflatAutoPeftModelForCausalLM+ tokenizerWhat each branch documents
Intrinsic layout (unchanged):
Flat layout (new):
Upload warning
A flat upload prints one warning naming the expected intrinsic path and the flags that
produce it. The upload still succeeds; plain PEFT publishing stays supported, it just
stops being silent about what it cannot be used for.
CLI surface
Decision log
D1 — Keep
upload --intrinsicdefaulting to false--intrinsic=True.io.yaml, and the CLI has no generator forone. Flipping the default would block anyone without an
io.yamlat the upload step,then make them discover
--no-intrinsicto get plain PEFT. It moves the failureearlier and adds a mandatory artifact; it does not make the workflow work.
choice now yields a README whose code runs, and the flat choice is no longer silent.
D2 — Detect by default, with an explicit override
--intrinsicflag onadd-readmewith no detection.add-readmealready requires auth, network, and an LLM backend; one read-onlylisting is cheap. A flag-only design helps only users who already know the
requirement, which is the gap the issue reports.
never a hard stop. The flag remains for scripted or offline use.
D3 — Ask when the layout is unknown
it; assuming intrinsic recreates the bug. Asking is one question in a command that
already prompts before uploading.
autoshould fail fast in anon-TTY is Q1.
D4 — Render a PEFT sample for flat repos
makes the README less useful; refusing leaves flat users with no README path.
output is compiled by the test suite.
D5 — Keep the token optional until upload
logging in; the token was only checked after the upload confirmation. Detection should
not remove that.
autowarns that it cannot inspect the repo and asksfor the layout. The token is still required at the upload step.
D6 — Put the classifier in its own module
prefix, intrinsic-over-root precedence. A pure function tests without Hub mocks.
cli/alora/layout.py, 44 lines including docstrings.D7 — Keep adjacent defects out of this change
__main__block hardcodesIBM_GRANITE_4_1_3B; the samplehardcodes
AdapterType.ALORAeven for LoRA training;add-readmeaccepts--io-yamlbut never uses it.
plumbing, whether
io.yamlfeeds generation or is removed — and bundling them makesthe layout change harder to review.
Open questions
automode with an unknown layout, should anon-TTY run fail with guidance instead of waiting for input? The existing upload
confirmation already assumes interactivity, but CI users deserve a defined answer.
<name>/asintrinsic. Validating the full
<name>/<model>/<type>/path would be stricter butwould reject the older layout and require base-model normalization. Is the tolerant
prefix the right trade?
--layout auto|intrinsic|flatthe right surface, or should itbe
--repo-layout, or values named after the loader (peftrather thanflat)?add-readme-before-upload order but requires an explicit
--layoutwhen nothing can bedetected. Which does the team prefer for scriptability?
changes the heading to "Adapter" but keeps the template's intrinsic-oriented
description and
melleatag. Should flat mode drop that framing entirely?one follow-up PR (they share the template's sample) and the dead
--io-yamlanother,or separate issues?
Validation of the prototype
test/clisuiteruffandmypyclean oncli/alora/Separately, the locked
huggingface-hub1.16.1 removedHfFolder, som alora uploadand
add-readmecurrently fail on import with a misleading "install mellea[hf]" message.That is tracked as #1791 and
is unrelated; the new tests stub the symbol so they exercise layout resolution only.
Discussion wanted
The prototype exists to make this concrete, not to pre-empt the decision. Nothing is
filed upstream until the approach and Q1–Q6 are settled.
markstur commentedon Nov 12, 2026
Alternatives considered (short version)
upload --intrinsicto default true. Rejected: intrinsic upload requires anio.yaml, and the CLI has no generator for one. It would block plain-PEFT users at the upload step, add a mandatory artifact, and require a deprecation cycle — it moves the failure earlier rather than fixing it.--intrinsicflag toadd-readmeonly. Rejected: it only helps users who already know the requirement, which is the gap m alora upload's default layout is incompatible with add-readme's generated usage code #1620 reports. It survives as the--layoutoverride for scripted use.add-readmedoes not accept a weights path, so this is a larger signature change. The--layoutoverride covers the same need without it.--io-yaml). Deferred to keep the layout change reviewable.planetf1 commentedon Nov 16, 2026
Thanks Mark, this is the right shape: detect, allow an override, leave
upload's default alone, and give flat repos a README that works. Agree with D1 to D5. A couple of things beyond your questions first, then answers.Sequencing with #1798. #1798 fixes #1791 by replacing
HfFolder.get_token()incommands.py,upload.pyandintrinsic_uploader.py. Your prototype moves that same lookup inalora_add_readme, so the two will conflict. I'd let #1798 merge first and rebase onto it. The new tests then exercise the real token path and theHfFolderstubs can go.The flat sample doesn't exercise the adapter. It stops after
from_pretrained, so it runs but shows nothing. There's a subtler problem for aLoRA: the adapter only activates once the invocation tokens appear in the input, and training used a specific prompt shape (train.py:89):f"{item}\nRequirement: <|end_of_text|>\n{invocation_prompt}"A reader who calls
generate()on plain text gets base-model output and thinks the adapter is broken. The sample should build that prompt and decode the reply, roughly:add-readmealready takes--promptfile, so the invocation string is known (default<|start_of_role|>check_requirement<|end_of_role|>), and the first dataset sample can fillitemthe same wayexample_call_kwargsdoes for the intrinsic branch.Q2, prefix vs full path. The prefix check is right for classifying, but it can say "intrinsic" for a repo the sample still can't load. The loader resolves
<name>/<canonical base model>/<type>/from the backend's base model, so a nested upload trained on a different base model, or with a base-model name that normalizes differently, passes your check and still fails. The reasons given for not checking the full path don't hold, becauseadapter_subpath()inmellea/formatters/granite/intrinsics/util.pyalready does both jobs:BASE_MODEL_TO_CANONICAL_NAME, so no normalization to reimplement;OLD_LAYOUT_REPOS(the IBM collections), andupload --intrinsicnever writes it, so user repos can't hit it anyway.--basemodelis already required, so after the prefix check:No match means warn: the README will be generated but its code won't find the weights for that base model. One match also tells us the adapter type, which fixes the hardcoded
AdapterType.ALORAin auto mode for free. Explicit--layout intrinsicwould still need the type from somewhere; that can stay a follow-up.Q1 / Q4, non-interactive runs. Same answer for both. If stdin is a TTY, prompt as the prototype does. Otherwise exit non-zero with a message naming
--layout intrinsic|flat. Waiting oninput()in CI either hangs or dies withEOFError, which is what the existing upload confirmation already does, so an early, explicit failure is strictly better. Scripted users pass--layoutand never see the prompt.Q3, flag naming.
--layout auto|intrinsic|flatreads fine. I'd avoidpeftas a value: both layouts hold PEFT adapters, the difference is where the files sit.flatalso matches the wording in the newuploadwarning.Q5, framing in flat mode. Drop it fully. A flat repo isn't usable as an intrinsic, so the README shouldn't describe it as one: the heading (already done), the "intrinsic adapter" wording in the generator prompt (
readme_generator.py:217and:228), which steers the LLM's description, and the "Upload intrinsic README." commit message. Keep themelleatag, since it marks where the adapter came from rather than how it loads.Q6, follow-ups. I'd fold the base-model hardcode into this change.
__main__buildsLocalHFBackend(IBM_GRANITE_4_1_3B), and the loader looks for weights under the backend's base model, so for an adapter trained on anything else the README's own code fails with the samenot founderror this issue is about.base_modelis already a template variable andLocalHFBackendtakes a plain string, so it's a one-line change. The adapter-type hardcode is mostly covered by Q2 above. The unused--io-yamlonadd-readmeis unrelated to layout; a separate small issue is fine.fix(cli): match add-readme usage code to the repository's adapter layout
markstur commentedon Nov 20, 2026
Thanks. Agreed on these, nothing to add. The plan would be:
--layout intrinsic|flat.--layout auto|intrinsic|flat.melleatag stays.--basemodel, detection would cover the adapter-type hardcode, and--io-yamlis tracked in bug: m alora add-readme accepts --io-yaml but never uses it #1860.--promptfile) and decode only the reply.--layout intrinsicwould keep documentingalora. A way to state the type stays a follow-up, as you suggested.Q2 and one small addition are in separate comments.
markstur commentedon Nov 20, 2026
Q2
Agreed: the prefix would classify the layout, the exact directory would decide, a miss would warn but still generate the README, and the matching directory would give the adapter type.
One adjustment to the
adapter_subpath()call: look up the base model by its last path component, asLocalHFBackend.base_model_nameandupload --intrinsicalready do.adapter_subpath()only shortens the IDs inBASE_MODEL_TO_CANONICAL_NAME. Passingmyorg/my-finetunestraight through would look in<name>/myorg/my-finetune/…, while the loader and uploader use<name>/my-finetune/….That derivation would then exist in three places (backend, uploader, this check). I'd leave them as they are unless you'd prefer a shared helper.
markstur commentedon Nov 20, 2026
Hub reads in
--layout auto--layout autowould make read-only Hub requests with the user's token before anything is generated or confirmed. It would skip them without a token, and nothing would be written before the existing upload confirmation.adapter_config.json, one small file, to say LoRA vs aLoRA. A flat repo has no directory to read the type from. The type would come from whetheralora_invocation_tokenshas a value, because PEFT 0.19.1 writes the key asnullfor a plain LoRA. If the file couldn't be read, the README would say nothing about the type.To keep these visible, I'd:
--layouthelp thatintrinsicandflatmake no requestsAre the extra read and this handling acceptable?
planetf1 commentedon Nov 24, 2026
Happy with this overall. One change I'd ask for, then answers to your questions and two small doc points.
Please add a timeout to the file listing
list_repo_fileshas no timeout, and the Hub client has none either. If the connection accepts and then goes quiet (a dead proxy, a captive portal),add-readmejust sits there before it generates anything. I checked this against a local server that never replies: still blocked after 20 seconds. The config download is fine, since it already has a 10 second limit by default.HfApi().model_info(name, token=token, timeout=5).siblingstakes a timeout, and it gave the same file list aslist_repo_fileson the two public repos I compared. If it times out, the existingexcept Exceptionalready treats the layout as unknown and asks, the same as when there's no token. A message that says it timed out would help, plus a test that makesmodel_inforaisehttpx.TimeoutExceptionand checks the question gets asked (and that the no-terminal error fires when it can't ask).Your questions
m alora uploadalways creates private repos, so in the normal flow an anonymous listing would just say "not found".hf_hub_download(..., cache_dir=<tmp>)on a small public adapter repo and nothing appeared in~/.cache/huggingface. I haven't tried a Xet-backed file.--layouthelp and the not-found wording: all good. The code in fix(cli): match m alora add-readme to the repository's adapter layout #1861 does what you describe.Docs
The docstring,
--layouthelp and example README match the code. Two gaps:autoskips the requests and asks instead, and "Prerequisites" reads as if a token is needed from the start. One sentence in the docstring would cover both.docs/docs/advanced/lora-and-alora-adapters.mdsays to pass--intrinsic"if you intend to use the adapter as a Mellea adapter function", but never says a plain upload can't be loaded that way. That's the original gap in this issue. Two lines would fix it, here or in a follow-up, your call.One separate bug
m alora upload --intrinsicpicks lora or alora with"alora_invocation_tokens" in config(inalora_upload,cli/alora/commands.py). PEFT 0.19.1 always writes that key, withnullfor a plain LoRA (I saved both kinds to check), so a plain LoRA goes up underalora/. Youradapter_type_from_configtests the value, which is the right check. I'd fix the upload side with the same helper as its own small change, since it alters whatuploaddoes.