Expose num_ns_steps - #283
Conversation
It can be useful to obtain the `num_ns_steps` in certain cases, e.g., to balance compute around existing instances' `num_ns_steps`. Could also refactor this to allow people to set `num_ns_steps` post-init by either (a) creating a new `scaled_orthogonalize_fn` when setting `num_ns_steps` or (b) simply passing `self` into the `scaled_orthogonalize_fn` closure, so that the instance's current `num_ns_steps` are always accessed. Signed-off-by: janEbert <janpabloe@nvidia.com>
Greptile SummaryExposes Muon’s construction-time
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The new property is initialized from the same validated constructor argument used by the orthogonalization closure, and current subclass and serialization paths preserve that value consistently. Important Files Changed
Reviews (1): Last reviewed commit: "Expose `num_ns_steps`" | Re-trigger Greptile |
It is very dangerous to modify Having said that, we designed for relatively simple customization, like QKV split. If more complex customization is needed, we should revisit the entire design of OrthogonalizedOptimizer. |
Enabling also setting For getting The value is necessary to balance parallel work around the compute cost of the optimizer. I'm currently using this formula to approximate NS orthogonalization work: |
The design was against post initialization change of orthogonalization method, which would open too many doors and needs to be carefully guarded and tested. I don't have any case that we need to change that inflight yet. Caller has all the information and cam maintain them if necessary. We can revisit when we have a case that Muon optimizer itself needs it. Alternative is storing and exposing all arguments to orthogonalization, which can be justified. |
|
It's fair to not allow post-initialization changes. As for the What's the issue with adding the read-only attribute? Can I address it somehow? |
It's weird to have only I'd say do one of the following for short term:
Long term, there is a pending item on my end to make orthogonalizer class that should store those attribute. We started with very simple function but the level of customization we later added has beyond originally designed for . |
It can be useful to obtain the
num_ns_stepsin certain cases, e.g., to balance compute around existing instances'num_ns_steps.Could also refactor this to allow people to set
num_ns_stepspost-init by either (a) creating a newscaled_orthogonalize_fnwhen settingnum_ns_stepsor (b) simply passingselfinto thescaled_orthogonalize_fnclosure, so that the instance's currentnum_ns_stepsare always accessed.