[MODEL] Nanochat implementation (#41634)
* first draft on modelling
* add modelling to auto
* add to init
* [WIP] add scripts for conversion
* hack at attention and rotary using logit comparison unitl it works
* update conversion script
* fix test
* tody up decoding inputs
* fix all naming nanogpt >> nanochat
* add return as tensors
* use batch encoding
* include tokenizer conversion in the conversion script
* add repo revision to vocab pull
* move attention into func and add kward to all signatures (for vllm)
* rename everything NanoGPT >> NanoChat
* improve docstrings in modelling code
* run ruff
* delete working test file
* remove custom tokenizer
* protect imports with lazy
* removed unused variables
* format config
* sort auto model configs
* make sure nanochat config is in all (fixes vllm)
* integrate tests
* remove custom tokenizer from autos
* formate tests
* add documentation for nanochat
* update toc with nanochat
* lose some attention notes
* remove excess configuration
* move init
* move script into modeling dir
* switch to modular and inheret llama
* add causal flag
* remove excess and just set params in model config
* liscence
* update model flags
* re use init weights
* lose functionals from the MLP
* use rmsnorm module instead of functional
* inherit rms from NanoChatRMSNorm
* run modular convert and update modeling
* update docs
* remove excess changes in auto
* Update src/transformers/models/nanochat/configuration_nanochat.py
Co-authored-by: Joshua Lochner <admin@xenova.com>
* add a basic tp/pp plan
* use cleanup util for tests
* update conversion script
* add docstring to nanochat config
* update auto config with NanoChatForCausalLM
* remove forward snippet
* fix auto modeling
* delete excess modelling file
* delete excess modelling file and regenerate modeling
* revert changes and use less llama modules
* use llama rope not custom
* cut down on notes and docstrings
* revert again to custom rope but this time using Qwen3 attention
* tidy notes in attention module
* update cache kwargs with sin and cos
* inheret from CLIPMLP and overwrite projections
* inheret llama decode layer
* re use more from LlamaPreTrainedModel
* inherit LlamaModel and copy forward except for initial_norm
* inheret more from LlamaForCausalLM
* more modular friendly
* adjust to changes in main
* last nits
* apparently we do this now lol
* mustve been a blank smthn smthn
* update conversion script to use original config
* fix attetion_bias everywhere
* resolve todos in config
* todos: layer names and repo id in modular
* last todos in config and modelling
* usng karapthy repo
* inherit from gemma instead
* fix vaultgemma
* ci common
* do rope config after super init
* update logit values in tests
* update logit tests one last time
* update and format conversion script
* update all logits again
* update test tollerence
* fix tests
* auto tokenizer
* fix test, to be updated upstream on the hub
* fix
* update conversion script to deal with new d34 model
* fix eval in docs
* Apply suggestions from code review
Co-authored-by: Cyril Vallez <cyril.vallez@huggingface.co>
* no separate initial_norm and do not iter over module
* update _tp_plan
* update modeling with changes
* style
* fix tp_plan
* oupppss this one almost slipped through nice I checked
---------
Co-authored-by: Joshua Lochner <admin@xenova.com>
Co-authored-by: Vasqu <antonprogamer@gmail.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
Co-authored-by: Cyril Vallez <cyril.vallez@huggingface.co>
Co-authored-by: Cyril Vallez <cyril.vallez@gmail.com>