Skip to content

Handle dynamic non-string type-name metadata - #146

Merged
Essoz merged 7 commits into
codex/torchscript-builtin-identityfrom
codex/dynamic-type-names
Oct 26, 2026
Merged

Essoz merged 7 commits into
codex/torchscript-builtin-identityfrom
codex/dynamic-type-names

Conversation

@Essoz

@Essoz Essoz commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

PyTorch's dynamic OpsWrapper returns functions for __qualname__ and __name__. TrainCheck rejected the former but accepted the latter, then failed its string assertion; this blocked fresh MNIST trace collection before the first training step.

Validate the fallback __name__ as a nonempty string before using it. Preserve valid name precedence and the existing reported __class__ fallback, and avoid truth-testing non-string metadata. This is a one-line production change stacked on #143.

Validation:

  • The same seven-test suite against the exact parent function and candidate changes from 4 passed / 3 failed to 7 passed / 0 failed, including the actual PyTorch OpsWrapper.
  • 23 combined type-name, tracing-integrity, and TorchScript tests pass on Python 3.10.16 / PyTorch 2.2.2 / macOS arm64; pinned Ruff, Mypy, Black, and isort hooks pass.
  • Matching Linux runtime (Python 3.11.4 / PyTorch 2.16.0.dev20261012+cpu): all seven type-name regressions pass within 29 integration tests, plus 11 checker-observer tests. The exact signed utility source and runtime module path were verified; the real OpsWrapper returns the expected name in both modes.
  • A fresh 10-step MNIST collection succeeds with the exact narrow fix in the explicitly composed tracing/TorchScript/cache/state-fix stack, with unchanged source hashes and model-state shapes. The earlier broader-workaround pilot is retained separately. This is composed-stack compatibility evidence, with no fix-isolated training or performance claim.
  • Independent review found no blocker.

Reproduction and compact before/after evidence: docs/experiments/dynamic-type-names.md and docs/experiments/dynamic-type-names-results.json.

Engineering hardening

Typed typename(object, bool) -> str and its test helpers, preserving the fallback guards and final assertions (b64023b). Two added negative tests verify invalid fallback metadata still fails and metadata access exceptions propagate. All 37 combined tracing/TorchScript/type-name tests pass, as do pinned hooks and stronger scoped Mypy 1.9 checks. utils.py retains its one pre-existing stronger-check stub diagnostic; no new ignores, casts, or relaxed assertions were introduced.

Separately composed updated production sources pass 140 affected Linux regression tests, whole-source Mypy (77 files), Ruff, and isort. Whole-source Black still reports three unchanged legacy files, down from six in the original base; changed-file hooks pass. Strict checks are scoped and do not establish repository-wide strict typing. Historical performance numbers above retain their original measured revisions; this hardening pass does not re-estimate them.

Integration with current main

Based on #143 (codex/torchscript-builtin-identity), with signed merge checkpoint 43fe5065656e. The shared base is #150, which reconciles Daniel's parallel-inference tip 122e769 with main ed54c7d. History is preserved; no force push or GitHub PR merge was used. All nine PR heads merge cleanly with their declared bases and current main, and the full stack composes without conflicts.

The resolved composition passes 140 production + 28 harness tests locally (Python 3.10.16 / Torch 2.2.2), pinned Mypy over 77 production files, and stricter Mypy over 9 harness/test files. Conflict-file commit hooks pass. Full-stack Ruff/Mypy/isort pass; Black retains the same three pre-existing formatting failures (config.py, proxy_wrapper/hash.py, proxy_wrapper/subclass.py). Remote CI is ignored because the self-hosted runner is unavailable. These checks validate integration; existing performance measurements retain their original revisions and are not remeasured here.

Land the parent in main first, then retarget this PR to main before merging it. Repeat for its children. Use merge commits to preserve stack ancestry, or refresh descendants after a squash/rebase merge. Exact heads and local logs are retained in outputs/conflict-resolution-20261026/.

@Essoz
Essoz merged commit dc677be into codex/torchscript-builtin-identity Oct 26, 2026
0 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