Skip to content

Add Google Colab quick start notebook and package version#1

Merged
ErenAta16 merged 3 commits into
mainfrom
copilot/add-colab-quick-start-notebook
Jan 12, 2026
Merged

Add Google Colab quick start notebook and package version#1
ErenAta16 merged 3 commits into
mainfrom
copilot/add-colab-quick-start-notebook

Conversation

Copilot AI commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Adds production readiness for LayerLens: Google Colab integration for immediate user onboarding and package version tracking.

Changes

Package Version

  • Added __version__ = "0.1.0" to layerlens/__init__.py for version introspection

Colab Quick Start Notebook (notebooks/colab_quick_start.ipynb)

  • 6-cell notebook demonstrating LayerLens pipeline with BERT-base example
  • Installation, GPU verification, synthetic activation cache, and results visualization
  • Complete runnable example without requiring external model files

Documentation

  • Colab badge in README.md for one-click access
  • Restructured requirements.txt with clear dependency groups and Colab-specific guidance
  • Updated notebooks/README.md with usage instructions

Example Usage

import layerlens
print(layerlens.__version__)  # "0.1.0"

# Notebook demonstrates full pipeline:
model_spec = ModelSpec(
    model_name="bert-base-example",
    total_params=110_000_000,
    layers=[LayerSpec(name=f"encoder.layer.{i}", ...) for i in range(12)]
)
manifest_path = run_pipeline(model_spec, profiling_cfg, optimization_cfg, activation_cache, output_dir)

The notebook enables users to try LayerLens in <5 minutes without local setup.

Original prompt

Objective

Complete the professionalization of the LayerLens repository by adding a Google Colab notebook and making final improvements for production readiness.

Tasks

1. Create Colab Quick Start Notebook

Create notebooks/colab_quick_start.ipynb with the following structure:

Cell 1: Title and Description

# LayerLens Quick Start on Google Colab

This notebook demonstrates how to use LayerLens on Google Colab with GPU acceleration.

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ErenAta16/LayerLens/blob/main/notebooks/colab_quick_start.ipynb)

## What You'll Learn
- Install LayerLens on Colab
- Verify GPU availability
- Run a simple BERT profiling example
- Generate optimization manifest

Cell 2: Installation

# Install LayerLens
!git clone https://github.com/ErenAta16/LayerLens.git
%cd LayerLens
!pip install -e ".[demo]" -q

print("✅ LayerLens installed successfully!")

Cell 3: Verify Installation

# Verify installation and GPU
import torch
import layerlens

print(f"LayerLens version: {layerlens.__version__ if hasattr(layerlens, '__version__') else '0.1.0'}")
print(f"CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
    print(f"GPU: {torch.cuda.get_device_name(0)}")
    print(f"GPU Memory: {torch.cuda.get_device_properties(0).total_memory / 1e9:.2f} GB")
else:
    print("⚠️ No GPU detected. Using CPU (slower performance).")

Cell 4: Simple Example

from pathlib import Path
from layerlens.pipeline import run_pipeline
from layerlens.config import ProfilingConfig, OptimizationConfig, LatencyProfile
from layerlens.models import ModelSpec, LayerSpec

# Define a simple model (BERT-base structure)
model_spec = ModelSpec(
    model_name="bert-base-example",
    total_params=110_000_000,
    layers=[
        LayerSpec(
            name=f"encoder.layer.{i}",
            hidden_size=768,
            layer_type="transformer",
            supports_attention=True
        )
        for i in range(12)
    ]
)

# Configure profiling
profiling_cfg = ProfilingConfig(
    metric_weights={
        "gradient_energy": 0.4,
        "fisher": 0.4,
        "proxy_eval": 0.2
    }
)

# Configure optimization with GPU latency profile
latency_profile = LatencyProfile(
    device_type="gpu",
    model_family="llm",
    batch_size=4,
    sequence_length=512
)

optimization_cfg = OptimizationConfig(
    max_trainable_params=50_000,
    max_flops=1e9,
    max_vram_gb=15.0,  # Colab GPU limit
    latency_target_ms=100.0,
    latency_profile=latency_profile
)

# Create synthetic activation cache (in real use, compute from model)
activation_cache = {
    f"encoder.layer.{i}": {
        "grad_norm": 0.5 + i * 0.1,
        "fisher_trace": 0.3 + i * 0.05,
        "proxy_gain": 0.1 + i * 0.02
    }
    for i in range(12)
}

# Run pipeline
output_dir = Path("./output")
print("Running LayerLens pipeline...")
manifest_path = run_pipeline(
    model_spec=model_spec,
    profiling_cfg=profiling_cfg,
    optimization_cfg=optimization_cfg,
    activation_cache=activation_cache,
    output_dir=output_dir
)

print(f"\n✅ Optimization complete!")
print(f"📄 Manifest saved to: {manifest_path}")

Cell 5: View Results

import json

# Load and display the manifest
with open(manifest_path, 'r') as f:
    manifest = json.load(f)

print("=" * 60)
print("LAYERLENS OPTIMIZATION RESULTS")
print("=" * 60)

allocations = manifest['allocations']
print(f"\nTotal layers: {len(allocations)}")

# Summary statistics
lora_layers = sum(1 for a in allocations if a['method'] == 'lora')
adapter_layers = sum(1 for a in allocations if a['method'] == 'adapter')
prefix_layers = sum(1 for a in allocations if a['method'] == 'prefix')
none_layers = sum(1 for a in allocations if a['method'] == 'none')

print(f"\nMethod Distribution:")
print(f"  LoRA: {lora_layers} layers")
print(f"  Adapter: {adapter_layers} layers")
print(f"  Prefix: {prefix_layers} layers")
print(f"  None: {none_layers} layers")

# Show top 5 layers by utility
print(f"\nTop 5 Layers by Utility:")
sorted_allocs = sorted(allocations, key=lambda x: x['utility'], reverse=True)
for i, alloc in enumerate(sorted_allocs[:5], 1):
    print(f"  {i}. {alloc['layer']}: {alloc['method']} (rank={alloc['rank']}, utility={alloc['utility']:.4f})")

print("\n" + "=" * 60)

Cell 6: Next Steps

## 🎉 Success!

You've successfully run LayerLens on Google Colab!

### Next Steps
1. **Try with a real model**: See `demos/demo_bert.py` for loading actual BERT models
2. **Experiment with configurations**: Adjust `max_trainable_params`, `latency_target_ms`, etc.
3. **Explore YOLO demo**: Check `demos/demo_yolo.py` for vision model optimization

### Resources
- 📖 [Documentation](https://github.com/ErenAta16/LayerLens/tree/main/docs)
- 🐛 [Troubleshooting](https://github.com/ErenAta16/LayerLens/blob/main/COLAB_TROUBLESHOOT.md)
- 💬 [Issues]...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Copilot AI and others added 2 commits January 12, 2026 14:01
Co-authored-by: ErenAta16 <149434812+ErenAta16@users.noreply.github.com>
Co-authored-by: ErenAta16 <149434812+ErenAta16@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Google Colab quick start notebook for LayerLens Add Google Colab quick start notebook and package version Jan 12, 2026
Copilot AI requested a review from ErenAta16 January 12, 2026 14:09
@ErenAta16

Copy link
Copy Markdown
Owner

@copilot Test eder misin ?

Copilot AI commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Test eder misin ?

Evet, tüm testleri çalıştırdım! ✅

Test Sonuçları:

  • 15/15 unit/integration testleri başarılı
  • Package version erişilebilir (layerlens.__version__ = "0.1.0")
  • Colab notebook yapısı geçerli (6 hücre)
  • Notebook kodu başarıyla çalışıyor
  • Pipeline doğru manifest üretiyor
  • Tüm dokümantasyon güncel

Commit: fc73914

Tüm değişiklikler test edildi ve production için hazır! 🚀

@ErenAta16

Copy link
Copy Markdown
Owner

@copilot Hücreleri buradan da verir misin

Copilot AI commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Hücreleri buradan da verir misin

Tabii! İşte notebook hücreleri:

Hücre 1 (Markdown): Başlık ve Giriş

  • LayerLens Colab başlangıç rehberi
  • Colab badge
  • Öğrenilecekler listesi

Hücre 2 (Code): Kurulum

!git clone https://github.com/ErenAta16/LayerLens.git
%cd LayerLens
!pip install -e ".[demo]" -q

Hücre 3 (Code): GPU Doğrulama

import torch
import layerlens
# Version ve GPU bilgilerini gösterir

Hücre 4 (Code): BERT Pipeline Örneği (68 satır)

  • 12 katmanlı BERT-base model tanımı
  • Profiling ve optimization konfigürasyonları
  • Sentetik activation cache
  • Pipeline çalıştırma

Hücre 5 (Code): Sonuçları Gösterme (32 satır)

  • Manifest yükleme
  • Method dağılımı (LoRA, Adapter, Prefix, None)
  • Top 5 katman utility değerleri

Hücre 6 (Markdown): Sonraki Adımlar

  • Demo dosyaları referansları
  • Dokümantasyon linkleri

Toplam 6 hücre, tam çalışır durumda. Tüm kod test edildi ve başarıyla çalışıyor! ✅

@ErenAta16

Copy link
Copy Markdown
Owner

@copilot repoya commitler misin ?

@ErenAta16 ErenAta16 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made in Colab have been saved.

@ErenAta16

Copy link
Copy Markdown
Owner

Changes made in Colab have been saved.

@ErenAta16

Copy link
Copy Markdown
Owner

@copilot kontrol eder misin ben commitledim

Copilot AI commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot kontrol eder misin ben commitledim

Kontrol ettim! ✅

Mevcut Durum:

  • Branch: copilot/add-colab-quick-start-notebook
  • Son commit: fc73914
  • Working tree: Clean (temiz)

Doğrulamalar:

  • layerlens.__version__ = "0.1.0" erişilebilir
  • ✅ Notebook mevcut (6 hücre, format 4.4)
  • ✅ README.md Colab badge içeriyor
  • ✅ requirements.txt yapılandırılmış
  • ✅ notebooks/README.md güncel
  • ✅ 15/15 test başarılı

Repository'de şu an yeni commit görünmüyor. Eğer Colab'da değişiklik yaptıysanız, bu değişikliklerin GitHub'a push edilmesi gerekir. Şu anki 3 commit'teki tüm değişiklikler yerinde ve çalışıyor! 🚀

Copilot AI requested a review from ErenAta16 January 12, 2026 14:44
@ErenAta16 ErenAta16 merged commit fc73914 into main Jan 12, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants