Skip to content

Name the method on the uploaded model card - #10816

Open
vineethsaivs wants to merge 2 commits into
unslothai:mainfrom
vineethsaivs:fix/model-card-method
Open

Name the method on the uploaded model card#10816
vineethsaivs wants to merge 2 commits into
unslothai:mainfrom
vineethsaivs:fix/model-card-method

Conversation

@vineethsaivs

Copy link
Copy Markdown
Contributor

What breaks

upload_to_huggingface takes method as a required positional argument and then throws it away:

content = MODEL_CARD.format(
    username = username,
    base_model = model.config._name_or_path,
    model_type = model.config.model_type,
    method = "",
    extra = extra,
)

MODEL_CARD's heading is # Uploaded {method} model, so every card this pushes comes out as:

# Uploaded  model

with the gap still in it. All four call sites in save.py pass "finetuned", so that is what should be there.

Why it is a bug and not a choice

Studio carries the same template and fills the placeholder in: method = compressed_alias or format_type in studio/backend/core/export/export.py. Its heading is # Uploaded finetuned {method} model. The placeholder is meant to carry a value.

What changed

One line: pass method through. The heading now reads # Uploaded finetuned model.

Tests

tests/test_upload_model_card_method.py lifts MODEL_CARD and upload_to_huggingface out with ast and runs them against a recording ModelCard, the way tests/test_merged_hub_destination.py does, because save.py cannot be imported without an accelerator.

  • the heading names the method, and is not # Uploaded model
  • the username, the extra tag and datasets still reach the card
2 passed in 0.32s

The first fails on main:

assert '# Uploaded finetuned model' in '---\nbase_model: base/model\n...'

Left alone

create_huggingface_repo and _push_merged_to_hub_revision also format the card with method = "", and both print the same double space. Neither has a method to name, so fixing that means deciding what those two flows should be called. Happy to do it in a follow-up if you want a value there.

upload_to_huggingface takes `method` as a required positional argument and then
formats the card with method = "". MODEL_CARD's heading is

    # Uploaded {method} model

so every card it pushes reads "Uploaded  model", with the gap where the method
should be. All four call sites in save.py pass "finetuned".

Pass the argument through. Studio's copy of the same template already does this,
with `method = compressed_alias or format_type`.

Test: tests/test_upload_model_card_method.py lifts MODEL_CARD and
upload_to_huggingface out with ast and runs them against a recording ModelCard,
the way tests/test_merged_hub_destination.py does, since save.py cannot be
imported without an accelerator. It asserts the heading names the method, and a
second test pins that the username, extra tag and datasets still come through.
The first fails on main.
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the heading in unsloth/save.py:2579 still gets an empty method at line 2687, so uploaded cards come out with the gap in them. Will get this reviewed, and please take a look at the Repo tests (CPU) job on your branch.

@vineethsaivs

Copy link
Copy Markdown
Contributor Author

Looked at it. The failure is not from this PR: tests/studio/test_desktop_reliability_frontend_contract.py::test_tauri_collapse_removes_the_icon_rail_but_web_keeps_it fails on main too, and this diff only touches the model card string in unsloth/save.py plus its own test file. The run was 1 failed, 18500 passed.

The test asserts the old inlined expression:

assert "aria-hidden={(hasPinMode && !pinned && collapseToZero) || undefined}" in primitive

studio/frontend/src/components/ui/sidebar.tsx has since pulled that into a named condition and added a peek case:

const holdsOut = hasPinMode && !pinned && collapseToZero
const heldOut = holdsOut && peeking
...
aria-hidden={(holdsOut && !heldOut) || undefined}
inert={(holdsOut && !heldOut) || undefined}

So the behaviour the test is guarding is still there, the string it greps for is not. Held out, the sidebar is on screen and must answer the pointer, which is the && !heldOut part.

Happy to send a one-line update to that assertion as its own PR if you want it, since it is blocking the CPU job on every open PR right now. Keeping it out of this one.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants