Repository: transformers
Issue: Andromeda
Labels: New model

### Model description

## **Andromeda Specs**: Unveiling Mastery

**Overview**
Elegantly marrying craftsmanship and technology, Andromeda is not just another step in AI evolution. It's a giant leap. Driven by precision, powered by innovation, and defined by excellence, Andromeda is the epitome of intelligence realized. Here, we detail the marvel that is Andromeda, in numbers, facts, and logic.

---

### **Specifications**

| **Feature**                                  | **Specification**                             |
|----------------------------------------------|-----------------------------------------------|
| **Sequence Handling**                        | Ultra Long (32,000 - 200,000+ context lengths)|
| **Processing Speed**                         | Ultra Fast (32,000+ tokens in < 100ms)        |
| **Reasoning Abilities**                      | Creativity, Quantitative                                      |
| **Attention Mechanism**                      | Flash Attention 2.0 Triton                    |
| **Memory Consumption** (compared to GPT-3)   | 100x Less                                      |
| **Memory Consumption** (compared to LLAMA)   | 30x Less                                      |
| **Max Sequence Processing Speed**            | 100,000+ sequences in < 300ms                 |
| **Dataset Strategy**                         | Books, Falcon, Redpajama, Math, Code                              |
| **Functionality**                            | FSDP, HF Accelerate,  Poetry Composition, API Calls, and more       |

---

### **Benchmarks**
**Speed**: At the heart of Andromeda's unparalleled capabilities is its raw speed. Leveraging the prowess of Flash Attention 2.0 Triton, it doesn't merely process data; it blazes through it. This power allows it to consume 50x less memory than its predecessor, GPT-3, and 10x less than LLAMA.

---

### **Why Andromeda?**
- **Performance**: Andromeda isn't about doing things faster; it's about doing them the best. Reliable processing of sequences, even as extensive as 100,000+ lengths, is realized in the blink of an eye, under 300ms.
  
- **Precision and Creativity**: The dataset strategy is no mere algorithm. It's a symphony, meticulously crafted to offer both creativity and quantitative reasoning.
  
- **Versatility**: Andromeda doesn't just compute; it contemplates. Whether you need the flair of a poet or the precision of an API call, Andromeda delivers, seamlessly.

---

### **Andromeda Principles**
- **Efficiency**: It's not just about doing more; it's about doing better. Techniques like attention flashing, rotary position encodings, and deep normalization ensure every cycle, every operation, every byte is optimized for performance.
  
- **Flexibility**: In the ever-evolving world of technology, adaptability is king. Andromeda is designed to mold, adapt, and excel, irrespective of the task or domain.
  
- **Scalability**: Grow with you, for you. Andromeda isn't static. It's dynamic, designed to scale, accommodating growing resources and expanding data sizes.
  
- **Community-Driven**: Behind Andromeda's machine brain is the human heart of the community. It doesn't just utilize open source; it thrives on it, constantly evolving, learning, and improving with contributions from around the world.


For enthusiasts, developers, and thinkers looking to dive deeper, the Model Architecture documentation offers an exhaustive, detailed view into the intricate marvel that is Andromeda. Dive in, and witness engineering and artistry in harmony.

---

### **Andromeda: A Detailed Technical Overview**

At the intersection of technological ingenuity and groundbreaking design principles, Andromeda emerges. Representing the zenith of years of research and development, it promises a transformative leap in AI performance, efficiency, and versatility. In this technical specifications document, we deconstruct the intricacies of Andromeda, presenting a meticulous overview of its structure, performance metrics, and underlying methodologies.

## **Feature Insights**

### **Alibi Positional Bias**
Empowering Andromeda to discern relative positions between tokens, this feature accentuates its ability to grasp intricate relationships within a sequence.

### **Rotary Position Encodings (xpos)**
This is a revolutionary means of encoding positions, shrinking the model's memory demands and propelling training speeds.

### **Flash Attention**
This is the linchpin of Andromeda's speed prowess, minimizing attention computations, thus boosting training and inference phases.

### **Deep Normalization (deepnorm)**
By normalizing activations, deep normalization shores up training stability, allowing Andromeda to identify intricate patterns with finesse.

## **Feature Insights (Contd.)**

### **Attn One KV Head (Multiquery Attention)**
A breakthrough in attention mechanism design, this feature allows for simultaneous computation of multiple queries against the same set of key-values, fostering speed and efficiency.

### **QK Norm & Attention QK Norm**
These two features introduce a normalization step in the query and key matrices. This step facilitates stabilization in the attention mechanism, rendering it more robust and enabling it to scale with larger input sizes.

### **Attention QK Norm Dimension Scale**
A sophisticated adjustment to the attention mechanism, it modulates the normalization scale in accordance to the dimensions of the model. The result is a more adaptive and responsive attention framework.

### **Embedding Provider**
At the foundation of Andromeda, this module facilitates the embedding process, converting token sequences into dense vectors. Tailored for Andromeda, it ensures rapid and efficient embedding processes.

---

## **Deeper Dive: Model Parameters**

Unpacking Andromeda means diving deep into the parameters that shape its capabilities. Here's a granular view:

| **Parameter**                           | **Description**                                                                                                                                                                           | **Default Value** |
|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| **num_tokens**                          | Total number of tokens in the vocabulary.                                                                                                                                                | 50432             |
| **max_seq_len**                         | Maximum sequence length the model can process.                                                                                                                                           | 8192              |
| **dim**                                 | Dimension size of the model. It represents the size of embeddings and general depth in neural layers.                                                                                    | 2560              |
| **depth**                               | Represents the number of transformer layers in the architecture.                                                                                                                         | 32                |
| **dim_head**                            | Dimension size of each head in multi-head attention mechanism.                                                                                                                           | 128               |
| **heads**                               | Total number of heads in multi-head attention.                                                                                                                                           | 24                |
| **use_abs_pos_emb**                     | Boolean flag to determine if absolute positional embeddings are used.                                                                                                                     | False             |
| **alibi_pos_bias**                      | Enables the alibi positional bias in attention mechanisms.                                                                                                                               | True              |
| **alibi_num_heads**                     | Specifies the number of heads for the alibi positional bias.                                                                                                                             | 12                |
| **rotary_xpos**                         | Determines if rotary positional encodings are utilized.                                                                                                                                  | True              |
| **attn_flash**                          | Flag to activate the Flash Attention mechanism, minimizing computations in the attention phase.                                                                                          | True              |
| **shift_tokens**                        | The number of tokens by which input sequences are shifted. Essential for certain sequence-to-sequence tasks.                                                                             | 1                 |
| **attn_one_kv_head**                    | Activates multiquery attention by computing multiple queries against a singular key-value pair.                                                                                          | True              |
| **qk_norm**                             | Enables the query-key normalization mechanism in the attention phase.                                                                                                                    | True              |
| **attn_qk_norm**                        | A more advanced version of query-key normalization that scales according to the model's dimensions.                                                                                      | True              |
| **attn_qk_norm_dim_scale**              | Modulates the scale of the aforementioned attention normalization based on the model's dimensionality.                                                                                  | True              |
| **embedding_provider**                  | The module responsible for providing embeddings. Custom providers can be passed for tailored embedding processes.                                                                       | AndromedaEmbedding|

---


## **Insights and Techniques**

#### **1. Floating-Point Operations (FLOPs)**
Considering the number of FLOPs is paramount. It provides a metric to gauge the computational intensity and, by extension, the potential speed of the model.

#### **2. Flash Attention 2.0 Triton**
Enhanced with CUDA, this method offers a significant surge in the number of FLOPs the model can handle, amplifying its overall efficiency.

#### **3. Mixed Precision Training**
By embracing mixed precision, Andromeda realizes a noteworthy uptick in training speed while achieving commendable memory efficiency.

#### **4. Deepspeed 3 with NVMe Integration**
This powerful combination paves the way for superlative optimization during the training phase.

#### **5. 8-bit Optimizer**
Further pushing the boundaries of speed, the 8-bit optimizer boosts processing times without compromising the integrity of results.

#### **6. Gradient Clipping**
This technique has been integrated into the training regimen, achieving a massive speedup and preventing undesirable spikes during the process.

#### **7. Advanced Techniques: XPOS, ALIBI, QK Layernorm**
These sophisticated techniques are harnessed for superior extrapolation, interpolation, and stabilization during training.

#### **8. Multi Query Attention**
This approach has been adopted to supercharge decoding speeds.

#### **9. Parallelized Transformer Blocks**
Ensuring that the model's performance is consistently high, these blocks run in tandem to provide a smooth and efficient operational experience.

#### **10. Shifted Tokens**
In a strategic move, Andromeda sidesteps traditional positional embeddings, relying instead on shifted tokens for sequence length progression.

#### **11. Positional Interpolation**
This innovative technique augments the model's ability to manage sequences more effectively.

#### **12. Optimized CUDA Embedding Function**
This function is tailored for peak performance, ensuring rapid and accurate computations.

#### **13. Nebula Loss Function**
Integrated into Andromeda, this polymorphic loss function is adept at handling multi-task training scenarios.

## **A Word on Optimization and Future Iterations**

As with any state-of-the-art model, Andromeda's design is an ever-evolving tapestry. This means iterative refinement. As feedback streams in and technology progresses, expect advancements in:

- **Model Pruning**: Trimming redundancies, bolstering efficiency.
- **Knowledge Distillation**: Harnessing the wisdom of larger models in smaller, more agile architectures.
- **Zero-Shot and Few-Shot Learning**: Broadening adaptability horizons.
- **Enhanced Data Augmentation**: Fortifying the model's grasp on varied, nuanced contexts.
- **Decentralized Training**: Tapping into the global hive-mind, harnessing the collaborative power of the community.


## **Potential Other Future Trajectories**

#### **1. Clearer Metrics**
There's always room to elevate the benchmarking rigor, especially concerning reasoning abilities.

#### **2. Robust Validation and Testing Environment**
Further fine-tuning of the testing environment can offer even more reliable validations of Andromeda's capabilities.

#### **3. Comprehensive Documentation**
To bolster transparency and replicability, detailed documentation covering every facet of Andromeda is on the horizon.

#### **4. Benchmarking Against Peers**
By juxtaposing Andromeda against its counterparts, its distinctive advantages can be spotlighted more effectively.

#### **5. Spotlight on Real-World Applications**
By highlighting tangible use-cases, the versatility and prowess of Andromeda can be showcased in palpable contexts.

#### **6. Model Interpretability**
Future iterations might delve deeper into model interpretability, especially for critical applications.

#### **7. Niche Customizations**
By tailoring Andromeda to meet specific niche needs, its adaptability and value proposition can be further enhanced.

#### **8. Collaborative Endeavors**
Engaging more intimately with the global research community could spawn collaborative projects, bringing diverse insights to the fore.


As we voyage further into the AI frontier, Andromeda stands as a beacon, illuminating the path forward, promising marvels yet to come. It's not just about machine intelligence; it's about the dance between human curiosity and machine capability.

---

Join us on this journey. Dive deeper, ask questions, innovate, and let's redefine what's possible, together.

### Open source status

- [X] The model implementation is available
- [ ] The model weights are available

### Provide useful links for the implementation

https://github.com/kyegomez/Andromeda