Add dots3-note Preview model support - #47844
Conversation
7af5a25 to
fe87862
Compare
|
hey @miraclezqc , thanks for the PR! Most of the team currently is off on summer vacations so the reviews are taking longer. We'll review it soon :) |
b70c2d9 to
d8e147f
Compare
@zucchini-nlp |
84acd71 to
9daa866
Compare
|
Hey! Happy to review, can you update the branch to fix the latest |
Thanks! The branch has been updated for the latest mlinter rules. It seems that the new CI run is blocked by the security gate. Could you please approve it? |
|
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. |
|
@ArthurZucker Hi. The branch is now up to date with main and all local checks pass. |
CI recapDashboard: View test results in Grafana |
|
Thanks for approving the workflow! All regular CI checks are now green, and the branch is ready for review. |
|
Hi @ArthurZucker @Rocketknight1 , the branch is now up to date with main, and all relevant local tests pass. We’d appreciate your review and an early merge if everything looks good. Thank you! |
|
Sorry for the delays @miraclezqc but I noticed that we are not using modular as intended at all, please check out https://huggingface.co/docs/transformers/modular_transformers The goal is to reuse existing modules as much as we can, this includes the rms norm, indexer, etc |
|
@vasqu Thanks! We’ve refactored the model to reuse existing DeepSeek, GLM DSA, and Qwen2-VL components, including RMSNorm and the indexer. Only Dots-specific logic remains custom, and all relevant tests pass. Could you please take another look and let us know if it is ready to merge? |
vasqu
left a comment
There was a problem hiding this comment.
I tried to go a bit more into details but this is still not super modular friendly: There are a lot of custom implementations where we could just reuse ours - e.g. the dsa is handled completely custom, the attn backend is also completely custom which would disallow any usage via vllm, etc.
What I want to tell with this: Custom implementations are very much still implemented in transformers oftentimes but they need to be aligned - imo the biggest example is RoPE in this case
| > [!NOTE] | ||
| > Loading encoded audio or video sources requires the optional `torchcodec` dependency. Native video preprocessing | ||
| > follows the training-time sampling pipeline and expands each video into timestamped image blocks with interleaved | ||
| > audio blocks. The `<|video_pad|>` marker is only an external prompt placeholder and is removed before tokenization; | ||
| > it is never passed to the model. Decoded frame arrays are supported as visual-only inputs because their original | ||
| > audio track is absent. |
There was a problem hiding this comment.
I think this is fairly common across all of our models so I think we can delete it but no strong opinion
| > it is never passed to the model. Decoded frame arrays are supported as visual-only inputs because their original | ||
| > audio track is absent. | ||
|
|
||
| ```python |
| { | ||
| "role": "user", | ||
| "content": [ | ||
| {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/cats.png"}, |
There was a problem hiding this comment.
Also might be nice to show each modality wdyt?
| return model | ||
|
|
||
|
|
||
| def _resolve_weight_block_size(hf_quantizer, value: torch.Tensor) -> tuple[int, int]: |
There was a problem hiding this comment.
this looks unnecessary no? Can we revert to keep it inline and not a separate fn?
There was a problem hiding this comment.
cc @IlyasMoutawwakil when you have time to check this over
can you share the motivation here? Ig there is some (new) fp4 handling we need?
| pass | ||
|
|
||
|
|
||
| class Dots3NoteVisionRotaryEmbedding(nn.Module): |
| return attention_output, attention_weights | ||
|
|
||
|
|
||
| class Dots3NoteVisionAttention(nn.Module): |
There was a problem hiding this comment.
same here a lot of custom stuff we should not use and try to align with existing models
| # Unified multimodal model | ||
| # ----------------------------------------------------------------------------- | ||
| @auto_docstring | ||
| class Dots3NoteForCausalLM(Dots3NoteTextForCausalLM): |
There was a problem hiding this comment.
ForConditional - pls check the pattern in qwen vl
There was a problem hiding this comment.
or gemma4 and the like (omni)
|
|
||
|
|
||
| @auto_docstring | ||
| class Dots3NoteForConditionalGeneration(Dots3NoteForCausalLM): |
There was a problem hiding this comment.
Doesnt make much sense to make for causal lm and for conditional
Is the goal to have a text only variation, then pls check out qwen3_5 which does that
There was a problem hiding this comment.
Modular can also be applied for all processor related things
Didnt go through these but we have a lot of custom things we shouldnt need
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto, dots3_note, finegrained_fp8 |
Thanks @vasqu for the detailed review and all the helpful suggestions. We’ve gone through the comments and refactored the text, audio, vision, and preprocessing code to reuse existing Transformers components, removing redundant implementations along the way. We believe most suggestions are addressed. The remaining differences and follow-ups are:
We may still have missed a comment or a simpler reuse opportunity. Could you take another look and let us know what else needs to change before merging? Thanks again for your time and guidance. |
|
Checking tomorrow! 🤗 |
What does this PR do?
This PR is submitted by the official Dots-Studio team.
This PR adds native Transformers support for Dots 3 Note Preview, an inference-only mixture-of-experts multimodal causal language model supporting text, image, video, and audio inputs.
The implementation follows the modular Transformers workflow and includes the model configuration, processor, image processor, audio feature extractor, modeling implementation, auto-class registrations, documentation, conversion utilities, and model tests required for native integration.
The implementation includes:
128 x 128weight block size;This integration currently targets inference. Training-specific features such as gradient checkpointing are outside the scope of this PR.
No additional runtime dependency is introduced by this integration.
Validation
The following checks were run against the implementation in this PR:
tests/models/dots3_notetest directory;AutoModelForMultimodalLM;Both the BF16 and FP8 checkpoints passed the end-to-end text, image, video, and audio validation cases with finite outputs and successful greedy generation.
The corresponding public checkpoint links and finalized model organization metadata will be added after this PR is merged.
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. These often are low-quality, or fix extremely minor issues that occur rarely or never in practice.
As a result, we're instituting a rule that first-time contributors should not use code agents to submit PRs or issues.
We'd also ask autonomous "OpenClaw"-like agents not to open any PRs or issues.
Issues/PRs from first-time contributors that violate this rule will probably just be closed without review, and we
might block you, especially if you open more than one or appear to be deliberately ignoring this. We especially do not
want new contributors to jump in on random issues to contribute an agent-written fix. This creates lots of noise
for reviewers and other users and will almost certainly get you blocked.
For more information, please read
CONTRIBUTING.md.Before submitting
Who can review?
Anyone in the community is free to review the PR once the tests have passed.
cc @zucchini-nlp @vasqu