File size: 5,478 Bytes
ce60168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import os
import sys
from huggingface_hub import HfApi, create_repo

def load_naman_token():
    env_file = "/home/adminuser/.env"
    token = None
    if os.path.exists(env_file):
        with open(env_file, "r", encoding="utf-8") as f:
            for line in f:
                line = line.strip()
                if line.startswith("NAMAN_HF_TOKEN="):
                    _, val = line.split("=", 1)
                    val = val.strip().strip("'").strip('"')
                    if val:
                        token = val
                        break
    return token

def create_readme_card(repo_id):
    return f"""---
license: apache-2.0
tags:
- mamba
- codestral-mamba
- qwen2.5
- state-space-model
- benchmark
- evaluation
---

# MAMBA_7B: Codestral Mamba 7B Installation, Benchmarks & Architectural Research

This repository contains the complete codebase, benchmark suite, evaluation datasets, research documents, and visual PowerPoint presentations for **MAMBA_7B**.

Published to **namanadep** Hugging Face profile using `NAMAN_HF_TOKEN`.

---

## 📊 Summary Benchmark Metrics (Codestral Mamba 7B vs. Qwen 2.5 7B)

| Metric | Codestral Mamba 7B | Qwen 2.5 7B Instruct | Takeaway |
| :--- | :---: | :---: | :--- |
| **Architecture** | **Selective State Space Model (SSM S6)** | **Multi-Head Self-Attention Transformer** | Mamba eliminates $O(N^2)$ quadratic KV-cache memory scaling. |
| **Average Latency** | **4.28s** | **7.40s** | **42.2% faster completion** for Codestral Mamba. |
| **Generation Speed** | **194.8 t/s** | **193.3 t/s** | Identical throughput on NVIDIA H200 GPUs. |
| **Memory Footprint** | **Constant $O(1)$ Memory State** | $O(N)$ Growth | Fixed VRAM up to 256k long-context reasoning. |

---

## 📂 Repository Layout & Uploaded Artifacts

- `docs/CODESTRAL_MAMBA_7B_VS_QWEN_7B_COMPARISON.md`: 71 KB Exhaustive 10-Prompt Benchmark Report.
- `docs/CODESTRAL_MAMBA_7B_VS_QWEN_7B_COMPARISON.pptx`: 9-Slide Visual Benchmark Comparison Deck.
- `docs/MAMBA_7B_INSTALLATION_AND_ARCHITECTURE_GUIDE.pptx`: 8-Slide Hands-on Installation & Architecture Journey Deck.
- `docs/MAMBA_MODELS_RESEARCH_OLLAMA_HUGGINGFACE.md`: State Space Models Architectural Research Document.
- `data/mamba_vs_qwen_results.json`: Raw Evaluation JSON transcripts across 10 technical categories.
- `src/`: Complete Python benchmark test harness and slide generation scripts.
"""

def main():
    base_dir = "/home/adminuser/aiops_pocs/MAMBA_7B"
    print("Loading NAMAN_HF_TOKEN from /home/adminuser/.env...")
    token = load_naman_token()
    if not token:
        print("Error: Could not find NAMAN_HF_TOKEN in /home/adminuser/.env")
        sys.exit(1)
        
    api = HfApi(token=token)
    user_info = api.whoami()
    username = user_info.get("name", "namanadep")
    repo_id = f"{username}/MAMBA_7B"
    
    print(f"Authenticated as '{username}'. Creating repository: https://huggingface.co/{repo_id}...")
    try:
        create_repo(repo_id, token=token, exist_ok=True, repo_type="model")
        print(f"Repository ready: https://huggingface.co/{repo_id}")
    except Exception as e:
        print(f"Repo creation status: {e}")

    # Write README.md locally
    readme_path = os.path.join(base_dir, "README.md")
    with open(readme_path, "w", encoding="utf-8") as f:
        f.write(create_readme_card(repo_id))

    print(f"Uploading files from {base_dir} to Hugging Face repository https://huggingface.co/{repo_id}...")
    
    # 1. Upload README.md
    api.upload_file(
        path_or_fileobj=readme_path,
        path_in_repo="README.md",
        repo_id=repo_id,
        token=token
    )
    print("  -> Uploaded README.md")

    # 2. Upload Docs Folder
    docs_dir = os.path.join(base_dir, "docs")
    if os.path.exists(docs_dir):
        for fname in os.listdir(docs_dir):
            fpath = os.path.join(docs_dir, fname)
            if os.path.isfile(fpath):
                api.upload_file(
                    path_or_fileobj=fpath,
                    path_in_repo=f"docs/{fname}",
                    repo_id=repo_id,
                    token=token
                )
                print(f"  -> Uploaded docs/{fname}")

    # 3. Upload Src Folder
    src_dir = os.path.join(base_dir, "src")
    if os.path.exists(src_dir):
        for fname in os.listdir(src_dir):
            fpath = os.path.join(src_dir, fname)
            if os.path.isfile(fpath):
                api.upload_file(
                    path_or_fileobj=fpath,
                    path_in_repo=f"src/{fname}",
                    repo_id=repo_id,
                    token=token
                )
                print(f"  -> Uploaded src/{fname}")

    # 4. Upload Data Folder
    data_dir = os.path.join(base_dir, "data")
    if os.path.exists(data_dir):
        for fname in os.listdir(data_dir):
            fpath = os.path.join(data_dir, fname)
            if os.path.isfile(fpath):
                api.upload_file(
                    path_or_fileobj=fpath,
                    path_in_repo=f"data/{fname}",
                    repo_id=repo_id,
                    token=token
                )
                print(f"  -> Uploaded data/{fname}")

    print("==========================================================================")
    print(f" Successfully published MAMBA_7B to Hugging Face: https://huggingface.co/{repo_id} ")
    print("==========================================================================")

if __name__ == "__main__":
    main()