Skip to content

fix/colab causal repro notebook#1

Merged
DaviBonetto merged 2 commits intomainfrom
codex/fix/colab-causal-repro-notebook
Mar 17, 2026
Merged

fix/colab causal repro notebook#1
DaviBonetto merged 2 commits intomainfrom
codex/fix/colab-causal-repro-notebook

Conversation

@DaviBonetto
Copy link
Copy Markdown
Owner

@DaviBonetto DaviBonetto commented Mar 17, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • New automated reproduction notebook for causal intervention experiments in Colab environments with multi-protocol support
    • Added debug mode flag for enhanced logging and runtime validation during experiment execution
    • Experiment results automatically aggregated and exported to CSV format

Add a notebook-first workflow for the F1-01a mini reproduction so it can run in Colab without hitting the Jupyter kernel -f argument issue. Keep the causal intervention script and the notebook aligned for T4 execution.
Make the reproduction notebook self-contained when opened from GitHub in Colab. If the repository is not already present, clone the spectralguard branch into /content and import the local script from there.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b1af4d5-f09d-47ef-b9a1-f017b3761815

📥 Commits

Reviewing files that changed from the base of the PR and between 66d994a and 5ccf1b2.

📒 Files selected for processing (2)
  • notebooks/06_Causal_Intervention_Reproduction.ipynb
  • scripts/run_causal_intervention.py

📝 Walkthrough

Walkthrough

Introduces automated causal intervention experiment reproduction through a new Colab notebook that orchestrates model setup, validated prompt generation, and multi-layer protocol execution, supported by enhanced debugging capabilities and rho proxy-based clamping in the experimental script.

Changes

Cohort / File(s) Summary
Experiment Automation
notebooks/06_Causal_Intervention_Reproduction.ipynb
New notebook automating causal intervention reproduction workflow: environment setup, repository discovery, model loading with tokenizer and GPU support, validated prompt generation, and dual-protocol experiment execution (all-layer and single-layer) with results aggregation and CSV export.
Debug & Analysis Support
scripts/run_causal_intervention.py
Added helper functions (_inverse_softplus, _get_separate_dt_bias, _compute_rho_proxy, _tensor_stats), debug flag propagation through hook creation and accuracy evaluation, refactored clamping logic with rho proxy-based dt scaling and selective dimension handling, and extended CLI with --debug option.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Colab as Colab Environment
    participant Repo as Repository
    participant Model as Model Setup
    participant Prompts as Prompt Generation
    participant Protocol as Protocol Executor
    participant Results as Results Aggregation

    User->>Colab: Initiate notebook
    Colab->>Colab: Install dependencies
    Colab->>Repo: Locate/clone repository
    Repo-->>Colab: Repo ready
    Colab->>Model: Load tokenizer & LM
    Model-->>Colab: Model initialized
    Colab->>Prompts: Generate validated prompts
    Prompts-->>Colab: Prompts ready
    Colab->>Protocol: Execute all-layer protocol
    Protocol->>Protocol: Enumerate thresholds & layers
    Protocol->>Model: Evaluate accuracy per rho
    Model-->>Protocol: Results
    Protocol-->>Colab: all-layer results (CSV)
    Colab->>Protocol: Execute single-layer protocol
    Protocol->>Protocol: Enumerate thresholds & layers
    Protocol->>Model: Evaluate accuracy per rho
    Model-->>Protocol: Results
    Protocol-->>Colab: single-layer results (CSV)
    Colab->>Results: Concatenate & summarize
    Results-->>User: Display summary table
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A causal warren of experiments, we weave,
With hooks that clamp and rhos that cleave,
From prompt to protocol, layer by layer,
Our debug-blessed CSV makes results fairer,
Automation hops through the Colab night! 🌙✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix/colab-causal-repro-notebook
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

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.

1 participant