Repository navigation
Tensor Metrics 2: Expose MCore tensors through observation hooks - #6648
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test |
8ba5c3f to
81a2fd3
Compare
38d36bb to
0293b82
Compare
|
/ok to test |
0293b82 to
74ac9b3
Compare
81a2fd3 to
4799b2f
Compare
|
/ok to test |
| with shape [num_tokens, num_experts]. | ||
| """ | ||
| seq_length, bsz = logits.shape[:2] | ||
| observe_router_diagnostics = is_observing_tensor("router_diagnostics") |
There was a problem hiding this comment.
when we do THD / no inter document masking, i wonder if the metrics we capture here needs to take into account per-sequence
There was a problem hiding this comment.
Yes, right now all of these are per-sample not per-document. At some point it would be nice to support THD, but I think it's fine to defer for now?
a806c2f to
b7a87c9
Compare
4799b2f to
338e656
Compare
Signed-off-by: Philip Monk <pmonk@nvidia.com>
Signed-off-by: Philip Monk <pmonk@nvidia.com>
Signed-off-by: Philip Monk <pmonk@nvidia.com>
Signed-off-by: Philip Monk <pmonk@nvidia.com>
Signed-off-by: Philip Monk <pmonk@nvidia.com>
Signed-off-by: Philip Monk <pmonk@nvidia.com>
Signed-off-by: Philip Monk <pmonk@nvidia.com>
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/35283924913 |
|
Ran CI as part of an aggregated branch that included multiple PRs in the queue. CI passed Will fast merge this |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/35302211621 |
Adds dormant, scoped MCore hooks that expose selected short-lived tensors to an external observer without depending on the training tensor-metric implementation. These will be used in a later training-focused PR.
This is part 2 of a four-PR stack. However, this and PR 1 are completely independent and can be reviewed/merged in either order (just rebase this onto main if this is to be merged first).
Some useful training diagnostics require tensors that do not survive until the optimizer step, including residual streams and router or output logits.
MCore should expose these values with minimal instrumentation while leaving metric selection, distributed reduction, scheduling, and logging outside
megatron/core.Design
megatron.core.tensor_observationprovides a scoped callback mechanism based on a context variable. Outside an active observation scope, every hook is a cheap no-op.The callback receives:
The source hook does not import or understand TensorMetric classes.
Observation sites
This PR exposes:
We will later want to expose more observation sites, but this is the list of sites that we have so far used for metrics. More can be added when needed.
Canonical parameter names
This PR also adds
CanonicalParameterNameMap, which creates stable logical names across:The logic included here is replicated ad hoc in several places in the codebase, so it seems worth centralizing it here. However, this could be moved into training/tensor_metrics if needed.