Padding free transformer
Author: mayank31398
Pull request: yes

Serves as code for the [blog](https://huggingface.co/blog/mayank-mishra/padding-free-transformer), also adds support for some new models trained on Slim-Pajama.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## 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.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Hi @mayank31398, thanks a lot for opening a PR and contributing to the HF ecosystem! 🤗

Is there an associated issue (feature or new model request) linked to this? 

Just skimming over the files - the first thing to note is that all of the models layers should be under one file - the modeling file i.e. `modeling_granite.py`. 

We have recently been trying to push for `model on the hub` and have as much support as we can there. It will also be easier to integrate it! Here is a [tutorial](https://huggingface.co/docs/transformers/custom_models) if that sound good to you!

hi @amyeroberts currently there is no issue associated with this.
The code is for the [blog](https://huggingface.co/blog/mayank-mishra/padding-free-transformer).
This also adds support for a lot of models that we use at IBM.

Also, 4 associated models that support this:
1. https://huggingface.co/mayank-mishra/slim-pajama-1b-gqa
2. https://huggingface.co/mayank-mishra/slim-pajama-1b-mha
3. https://huggingface.co/mayank-mishra/slim-pajama-1b-mqa
4. https://huggingface.co/mayank-mishra/slim-pajama-1b-gqa-swiglu

I will refactor everything under one file once I am done.
Currently, this is WIP. 🤗 

@mayank31398 What I would suggest is adding the model as code on the hub - there shouldn't be any difference in discoverability, usability and integration into the transformers eco system. This is the best and fastest way to make your code available, as well as the method we encourage. 

The bar to add models into the library is high, as each model added introduces its own maintenance burden. We find that this means PRs are often open for a long time particularly if it's the contributor's first model PR. 

What I would suggest is adding the modeling code on the hub first. If we see a lot of interest and usage in the community, then we can integrate it into the transformers repo. 

@amyeroberts thanks, the suggested solution makes sense.
However, we are inclined to keep a separate repo which is consistent across all our models and just use HF for uploading the weights (without code).

If we see interest in the community as you suggested, we can open a PR again to push our code for the models.

Closing this for now. 🤗