Skip to content

[trainer] add model config to Trainer to_dict - #3919

Merged
tianyu-l merged 2 commits into
pytorch:mainfrom
YassineYousfi:YassineYousfi-patch-1
Jul 19, 2026
Merged

tianyu-l merged 2 commits into
pytorch:mainfrom
YassineYousfi:YassineYousfi-patch-1

Conversation

@YassineYousfi

@YassineYousfi YassineYousfi commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Useful for book keeping

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 14, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@tianyu-l

Copy link
Copy Markdown
Contributor

could you show an example output?

@YassineYousfi

Copy link
Copy Markdown
Contributor Author

Sure:

before:

"model_spec": {
  "flavor": "debugmodel",
  "name": "llama3"
}

before-to_dict.json

after:

"model_spec": {
  "flavor": "debugmodel",
  "name": "llama3",
  "model": {
    "dim": 256,
    "enable_weight_tying": false,
    "vocab_size": 2048,
    "tok_embeddings": {
      "embedding_dim": 256,
      "num_embeddings": 2048,
      "param_init": {
        "weight": "functools.partial(<function normal_ at 0x...>, std=1.0)"
      },
      "sharding_config": null
    },
    "norm": {
      "elementwise_affine": true,
      "eps": 1e-05,
      "normalized_shape": 256,
      "param_init": {
        "weight": "<function ones_ at 0x...>"
      },
      "sharding_config": null
    },
    "lm_head": {
      "bias": false,
      "in_features": 256,
      "out_features": 2048,
      "param_init": {
        "bias": "<function zeros_ at 0x...>",
        "weight": "functools.partial(<function trunc_normal_ at 0x...>, std=0.0625, a=-0.1875, b=0.1875)"
      },
      "sharding_config": null
    },
    "layers": [
      "... transformer layer configs ..."
    ],
    "param_init": null,
    "sharding_config": null
  }
}

after-to_dict.json

@tianyu-l
tianyu-l merged commit 7e3f2eb into pytorch:main Jul 19, 2026
23 of 25 checks passed
mreso added a commit to mreso/torchtitan that referenced this pull request Jul 20, 2026
Absorbs 4 upstream commits (mxfp8 MoE ep=1 pytorch#3935, deepseek mxfp8 debug config
pytorch#3934, model config in Trainer to_dict pytorch#3919, GPU-agnostic AutoParallel tests
pytorch#3805). No conflicts; pytorch#3935 touches common MoE but the HF backend imports and
MoE EP=2 training verified clean (12.35 -> 7.23).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants