Skip to content

Upgrade ty to 0.0.59#757

Merged
bradhilton merged 3 commits into
mainfrom
agent/ty-0.0.59-migration
Jul 15, 2026
Merged

Upgrade ty to 0.0.59#757
bradhilton merged 3 commits into
mainfrom
agent/ty-0.0.59-migration

Conversation

@bradhilton

@bradhilton bradhilton commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • upgrade the repository-wide type checker from ty 0.0.14 to 0.0.59
  • fix newly exposed annotation and narrowing defects where the runtime contract is expressible
  • keep intentional suppressions narrow and portable across mypy/pyright/ty where possible
  • keep local type checking usable without optional Megatron dependencies

Diagnostic inventory and treatment options

The CI-shaped Megatron environment initially reported 276 diagnostics. The largest rule buckets were 139 invalid-argument-type, 28 unresolved-attribute, 26 invalid-assignment, 18 missing-typed-dict-key, and 12 unknown-argument.

  1. Legacy suppression codes

    • Chosen: remove suppressions through better contracts and narrowing first; where an intentional escape hatch remains, use portable # type: ignore rather than paired mypy/ty comments.
    • Ty-specific directives remain only for six third-party bridge/DSL locations whose diagnostics are specific to ty's current stubs or static model.
    • Alternatives: retain paired checker-specific directives (more precise per checker, noisy), or disable affected rules globally (smallest diff, materially weakens checking).
  2. Intentional test doubles and negative tests

    • Chosen: type structural fakes at their construction boundary, add runtime narrowing, and use real protocols for the tokenizer surface.
    • Alternatives: construct heavyweight runtime classes in unit tests, or add per-file rule overrides that hide unrelated future mistakes.
  3. Real annotation/narrowing gaps

    • Chosen: fix them. This includes the structural backend contract, covariant eval results, optional packed-tensor fields, concrete accumulators, tokenizer capabilities, dynamic framework patch boundaries, subprocess environment typing, and numeric return normalization.
    • Alternatives: cast at every use site (less code movement, weaker evidence), or suppress each report (behavior-preserving but leaves inaccurate contracts).
  4. Dynamic framework-extension boundaries

    • Chosen: use getattr/setattr with runtime validation for deliberately installed methods, modules, tensor metadata, and test mutations.
    • Alternatives: local facade layers (cleaner but substantial), or broad module overrides.
  5. Triton/TileLang and Megatron Bridge APIs

    • Chosen: retain narrow ty-only directives for the two GDN kernel launch modules and four bridge registrations whose JIT/decorator interfaces are not represented correctly by static signatures.
    • Alternatives: maintain local/upstream stubs or a checker plugin (best long term), exclude kernel files entirely, or globally ignore argument diagnostics (both broader than warranted).
  6. Optional dependency environments

    • Chosen: allow unresolved optional imports in lightweight environments, while separately validating against the Megatron-populated environment.
    • Alternatives: require all heavyweight extras for every local type check, or maintain separate ty configuration files per CI lane.

No global type-error rule is disabled.

Validation

  • ty 0.0.59, lightweight backend/dev environment: all checks passed
  • ty 0.0.59, CI-shaped Megatron dependency environment: all checks passed
  • prek: ruff, ruff-format, ty, and lockfile hooks passed
  • non-Megatron unit suite: 376 passed, 11 skipped
  • focused changed-path suite: 176 passed
  • lockfile and diff integrity checks passed

Three Megatron-importing unit modules cannot collect on this CPU workstation because Transformer Engine cannot load its packaged CUDA runtime; the Megatron CI lane remains the runtime authority for those modules.

@bradhilton bradhilton had a problem deploying to trainer-rank-gpu-validation July 15, 2026 01:22 — with GitHub Actions Error
Comment thread src/art/local/backend.py Outdated
Comment thread src/art/local/backend.py Outdated
@bradhilton bradhilton marked this pull request as ready for review July 15, 2026 01:30
@bradhilton bradhilton had a problem deploying to trainer-rank-gpu-validation July 15, 2026 01:30 — with GitHub Actions Error
@bradhilton bradhilton had a problem deploying to trainer-rank-gpu-validation July 15, 2026 01:55 — with GitHub Actions Error
@bradhilton bradhilton deployed to trainer-rank-gpu-validation July 15, 2026 02:28 — with GitHub Actions Active
@bradhilton bradhilton merged commit a5abf2e into main Jul 15, 2026
8 checks passed
@bradhilton bradhilton deleted the agent/ty-0.0.59-migration branch July 15, 2026 03:23
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