Skip to content

MAGIC implementation#135

Merged
luciaquirke merged 14 commits intomainfrom
magic
Mar 13, 2026
Merged

MAGIC implementation#135
luciaquirke merged 14 commits intomainfrom
magic

Conversation

@norabelrose
Copy link
Member

No description provided.

return sorted(checkpoints, key=lambda x: x[0])


class DataStream:
Copy link
Collaborator

Choose a reason for hiding this comment

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

so aesthetic

Copy link

Choose a reason for hiding this comment

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

agreed

@norabelrose norabelrose marked this pull request as ready for review February 20, 2026 00:59
@luciaquirke
Copy link
Collaborator

I am keen to merge this alongside an idempotent script to patch pytorch nightly (like this: https://github.com/EleutherAI/unlearn/blob/main/unlearn/magic/magic_wmdp_setup.sh) and a README and/or CLAUDE.md skill about how to set it up, thoughts?

@norabelrose
Copy link
Member Author

I am keen to merge this alongside an idempotent script to patch pytorch nightly (like this: https://github.com/EleutherAI/unlearn/blob/main/unlearn/magic/magic_wmdp_setup.sh) and a README and/or CLAUDE.md skill about how to set it up, thoughts?

This seems reasonable. The PyTorch patch will hopefully be merged next week but I'm not sure how much longer it will take for the next release of PyTorch to come out with the patch in it.

@CLAassistant
Copy link

CLAassistant commented Mar 6, 2026

CLA assistant check
All committers have signed the CLA.

@luciaquirke
Copy link
Collaborator

luciaquirke commented Mar 13, 2026

I'm going to merge this to unblock Will's work wanted to note that there's an alternative second launch_distributed thing in here that's only used by MAGIC + an accompanying image experiment that I wasn't sure what to do with so I let them be. Would be cool to properly support images though, plz do add that!

@luciaquirke luciaquirke force-pushed the magic branch 3 times, most recently from 64596e9 to 16851d2 Compare March 13, 2026 11:45
…ight support

- Add bergson/magic_patch.py: runtime monkey-patch for twice-differentiable
  DTensor redistribution (pytorch/pytorch#160509), replacing the old
  magic_wmdp_setup.sh that modified torch source files on disk
- Add per_token mode to DataStream for [n_examples, max_length] weight tensors
- Support 2D [B, T] per-token weights in weighted_causal_lm_ce
- Fix backward weight_grads accumulation when autograd returns None
@luciaquirke luciaquirke merged commit da87898 into main Mar 13, 2026
6 of 7 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.

4 participants