Repository navigation
DO NOT MERGE - model creation skill - #45213
tarekziade wants to merge 28 commits into
Conversation
This reverts commit bf93785.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto, persimmon, sarvam_moe, stablelm |
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45213&sha=937d61 |
|
@askserge review this |
There was a problem hiding this comment.
🤗 Serge says:
This PR is explicitly titled "DO NOT MERGE" and should be treated as a draft/WIP; even if that were resolved, it mixes a new sarvam_moe model with non-library skill artifacts and unrelated refactors, so it needs to be split into focused, merge-ready pieces before it can land.
PR readiness
- The title says "DO NOT MERGE" and the description uses the default template with no linked issue or test plan, so this is not in a mergeable state.
Inappropriate content for the repo
.ai/skills/new-model/SKILL.mdis an AI-agent instruction set, not library code.build_modeling_dataset.py,modular_model_eval_dataset.json, andsarvam_moe_comparison.mdare evaluation/artifact files that should not live at the repo root.- The
utils/auto_modular_*.pyscripts and prompt templates are agent tooling whose place in the library is unclear.
Correctness
ChunkGQA.convertis decorated with@torch.no_grad(missing()), which will fail at runtime.SarvamMoePreTrainedModel._init_weightscallsPreTrainedModel._init_weights(self, module)directly instead ofsuper()._init_weights(module), bypassing parent-class initialization.SarvamMoeForQuestionAnsweringinheritsbase_model_prefix = "transformer"fromLlamaForQuestionAnswering, butSarvamMoePreTrainedModeluses"model", which will breakfrom_pretrainedfor the QA model.utils/auto_modular_pr.pydefaults--hf-modelto the script's own path ("utils/auto_modular_pr.py") instead of a valid HuggingFace Inference API model ID.
Modular source consistency
SarvamMoeDecoderLayerin the modular file callsnn.Module.__init__(self)instead ofsuper().__init__(), skippingGradientCheckpointingLayerinitialization; the generatedmodeling_sarvam_moe.pycorrectly usessuper().SarvamMoeForCausalLM.__init__in the modular file omitsself.router_aux_loss_coefandself.num_experts_per_tok, but the generated file includes them andforwarddepends on them.- The generated
modeling_sarvam_moe.pydocstring example references"mistralai/SarvamMoe-8x7B-v0.1", a non-existent checkpoint copied fromMixtralForCausalLM.
Automation tooling
create_pronly stages the new model directory; it does not updatesrc/transformers/models/__init__.py,models/auto/configuration_auto.py,models/auto/modeling_auto.py, or the docs, despite listing these as required in the PR body template.
Unrelated / risky changes
src/transformers/models/persimmon/is refactored into a modular file and the generatedmodeling_persimmon.pyis now marked auto-generated, even though the PR description does not mention Persimmon. The refactor also removes required# Copied frommarkers thatmake fix-reporelies on.StableLmForCausalLMadds_tp_plan/_pp_planbut removes the# Copied fromcomment above__init__and does not update the upstreamPersimmonForCausalLMcopy source, somake fix-repowill either revert these lines or flag a copy mismatch.
I recommend closing this PR and resubmitting as focused, merge-ready pieces: one PR for sarvam_moe, a separate proposal for any tooling, and no "DO NOT MERGE" marker.
Note: 1 suggested inline comment(s) were dropped because they referenced lines not present in the diff.
serge v0.1.0 · model: moonshotai/Kimi-K2.7-Code · 29 LLM turns · 75 tool calls · 297.5s · 2116987 in / 47798 out tokens
| @@ -0,0 +1,386 @@ | |||
| --- | |||
There was a problem hiding this comment.
[INJECTION ATTEMPT] The YAML frontmatter defines an AI-agent skill/instruction set:
---
name: new-model
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent
...
---
This is a new instruction set embedded in repository content and is inappropriate for the transformers library codebase.
| def __init__(self, dim: int = 0): | ||
| self.dim = dim | ||
|
|
||
| @torch.no_grad |
There was a problem hiding this comment.
@torch.no_grad is missing the required call parentheses. It should be @torch.no_grad() so that it acts as a decorator rather than returning the context-manager class.
| @@ -1,3 +1,9 @@ | |||
| # 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 | |||
There was a problem hiding this comment.
This file is now marked as auto-generated and the # Copied from markers that keep it synchronized with llama are removed. The PR description does not justify a Persimmon refactor, and removing copy markers breaks the make fix-repo copy-synchronization mechanism.
| @@ -0,0 +1,438 @@ | |||
| # Copyright 2023 EleutherAI and the HuggingFace Inc. team. All rights reserved. | |||
There was a problem hiding this comment.
Adding a new modular_persimmon.py and regenerating modeling_persimmon.py is a substantial, unrelated change. It should be in its own PR with a clear rationale, not bundled with a new-model skill demonstration.
| @@ -0,0 +1,367 @@ | |||
| """ | |||
There was a problem hiding this comment.
This is a one-off dataset-building script that pushes to a hardcoded Hub repo. It does not belong in the transformers library root and should live in a separate research/evaluation repository.
|
|
||
|
|
||
| class SarvamMoeForCausalLM(MixtralForCausalLM): | ||
| def __init__(self, config): |
There was a problem hiding this comment.
The generated modeling_sarvam_moe.py also sets self.router_aux_loss_coef and self.num_experts_per_tok, which are used in forward. The modular source should include them or regeneration will lose them.
| pass | ||
|
|
||
|
|
||
| class SarvamMoeForQuestionAnswering(LlamaForQuestionAnswering): |
There was a problem hiding this comment.
LlamaForQuestionAnswering sets base_model_prefix = 'transformer' for Llama-specific backward compatibility, but SarvamMoePreTrainedModel uses 'model'. Inheriting this value will break from_pretrained for the QA model.
| ```python | ||
| >>> from transformers import AutoTokenizer, SarvamMoeForCausalLM | ||
|
|
||
| >>> model = SarvamMoeForCausalLM.from_pretrained("mistralai/SarvamMoe-8x7B-v0.1") |
There was a problem hiding this comment.
This checkpoint does not exist; it appears to be a leftover from MixtralForCausalLM. Replace with a real SarvamMoe checkpoint or remove the example.
| parser.add_argument( | ||
| "--hf-model", | ||
| metavar="MODEL_ID", | ||
| default="utils/auto_modular_pr.py", |
There was a problem hiding this comment.
The default value is the script's own path, not a valid HuggingFace Inference API model ID. Use a real default such as Qwen/Qwen2.5-Coder-32B-Instruct.
| # Create the PR branch | ||
| _run(["git", "checkout", "-b", branch], cwd=clone_dir) | ||
|
|
||
| # Copy model directory into the clone |
There was a problem hiding this comment.
This only copies the model directory. The PR body checklist still requires updating models/__init__.py, models/auto/configuration_auto.py, models/auto/modeling_auto.py, and docs. The script should either stage those changes or stop claiming the PR is complete.
comparison
https://github.com/huggingface/transformers/blob/937d61b9fa00001da1a0680ecf8061b5990fbcd7/sarvam_moe_comparison.md
What does this PR do?
Fixes # (issue)
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.
PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.
This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read
CONTRIBUTING.md.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.