Skip to content

fix(causal): stabilize Colab causal intervention reproduction#2

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

fix(causal): stabilize Colab causal intervention reproduction#2
DaviBonetto merged 1 commit intomainfrom
codex/fix/colab-causal-repro-notebook

Conversation

@DaviBonetto
Copy link
Copy Markdown
Owner

@DaviBonetto DaviBonetto commented Mar 17, 2026

Adds a Colab-friendly reproduction notebook that clones the repository automatically and runs the causal intervention sweep from the published branch.

Also fixes the hook shadowing bug in scripts/run_causal_intervention.py that caused the first all_layer sample to abort with UnboundLocalError inside the clamp path.

This keeps the reproduction runnable from a fresh Colab runtime without manual repository upload.

Summary by CodeRabbit

  • Bug Fixes
    • Improved internal calculation handling in the causal intervention script to ensure reliable computation of temporal parameters without unintended side effects on intermediate values.

Keep the trimmed clamp tensor in a distinct local variable so the closure can read the captured min_dt value before slicing it.

This removes the UnboundLocalError that stopped the Colab reproduction on the first all_layer sample.
@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: 3a5af537-f73a-459b-9311-f0c499946585

📥 Commits

Reviewing files that changed from the base of the PR and between 5833a28 and 31edba9.

📒 Files selected for processing (1)
  • scripts/run_causal_intervention.py

📝 Walkthrough

Walkthrough

Modified scripts/run_causal_intervention.py to introduce a new min_dt_effective variable computed from a dimensionally-constrained slice of min_dt_local, ensuring the original slice remains unmodified while downstream operations use the derived value for shaping, clamping, and logging.

Changes

Cohort / File(s) Summary
Variable Extraction
scripts/run_causal_intervention.py
Introduced min_dt_effective computed as min_dt_local[:dt_dim].to(...) and updated all downstream references (shaping, torch.maximum clamping, and diagnostic prints) to use the new variable instead of mutating min_dt_local directly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A slice once mutated, now sits pristine and still,
While min_dt_effective hops up the hill,
Correct dimensions flow where they're meant to go,
No side effects whisper—just a cleaner, safer flow! ✨

✨ 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.

@DaviBonetto DaviBonetto merged commit de532db into main Mar 17, 2026
1 of 2 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.

1 participant