Skip to content

Avoid warning contexts for verified native tensor method bindings - #162

Merged
Essoz merged 6 commits into
mainfrom
codex/metadata-method-fastpath
Oct 30, 2026
Merged

Essoz merged 6 commits into
mainfrom
codex/metadata-method-fastpath

Conversation

@Essoz

@Essoz Essoz commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Tensor metadata conversion repeatedly enters a warning-suppression context to read methods whose native binding cannot emit application warnings. This PR bypasses that guarded getter for verified native Tensor/Parameter methods, reducing metadata-conversion and traced-training time while retaining real bound objects and the original metadata classifier.

The shortcut requires exact receiver types, ordinary lookup, native descriptor ownership, unchanged inheritance and empty native instance storage. Properties, custom lookup, subclasses, shadowed state and unsupported descriptors keep the original path. It reads live namespaces/storage, caches no mutable values, and uses the descriptor type’s native __get__. Required contracts and assertions remain explicit. Native allocation failure retains NOT_FOUND/backoff; internal assertion failures propagate. No global warning suppression, hashing change, serialization change or checker change is introduced.

Fresh ordinary measurements of signed implementation 37f22e58954da403105c2c5510b7c7b6b3162ee6:

Workload / scope Baseline → candidate Less time
CPU MNIST, three-step API-traced body 286.400 → 222.665 ms 22.25%
CPU small Transformer, three-step API-traced body 682.324 → 527.587 ms 22.68%
CPU, 2,000 complete metadata conversions 1.607038 → 1.190048 s 25.95%
H100 Llama, steady-step run medians 999.855 → 842.885 ms 15.699%
H100 Llama, complete ten-step body 12.579847 → 10.990844 s 12.631%

CPU figures use four fresh processes per variant in ABBA order twice. H100 has three AB/BA/AB pairs; its median paired steady-step reduction is 15.738% (1.1868x). All percentages use baseline time as denominator. H100 is a single GPU, native FSDP, 6.2M-parameter TorchTitan Llama debug model, batch 1 / sequence 256, selective API collection from the same frozen policy. No model tracker or concurrent online checker runs. The single plain-control comparison remains expensive: 22.49x→18.96x; these small workloads do not establish generally low overhead or multi-GPU scaling. Component timing is separate from training and excludes hashing.

A separate H100 diagnostic finds 1,698,000/1,940,048 native bindings (87.52%) bypass the guarded getter, leaving 242,048 guarded reads over steps 3–10. Binding and classification still execute. Its timing is perturbed 1.39489x and excluded from performance estimates. Counts are not runtime attribution percentages.

Validation:

  • 335 tests pass, with two failures independently reproduced on the measured main baseline: test_traincheck_internal_attr_hidden and test_inject_eval_loop. Pinned changed-file pre-commit, explicit test lint/format and strict scoped mypy pass. Documented pre-existing all-files Black whitespace failures remain excluded.
  • All 26 focused metadata tests pass on Python 3.10/3.12; exact composed-source 33 metadata/classification tests pass on both, and 33 pass on labmach’s matched runtime. Four lifetime regressions fail on the earlier skip implementation on both Python versions and pass here. Additional regressions cover a function-instance __get__ shadow, allocation-failure backoff and assertion propagation.
  • All 16 CPU training runs and all 9 H100 phases match complete recorded state/loss/configuration evidence under the documented controls. Every selective H100 trace passes raw/parser integrity checks. Full field comparisons cover the first seed 42 pair plus seed 43 holdout; no structural/type/shape/array/exception differences. Raw IDs/timestamps, constructor IDs and CUDA handles remain different and explicitly reported, not normalized away.
  • All four checked corpora execute the same 722 rules: 718 active passes, one shared violation, three dormant, no errors/unknown coverage or variable-check skips. Observed and independent direct checking match all 722 complete checker results within each corpus. Cross-variant rule outcomes and decision counts match; complete results match 721/722, with fresh failure IDs/timestamps retained for the violating rule. The violation requires a frozen CUDA stream handle; two dormant rules require a reference thread ID, and one requires unequal threads. Rules were neither filtered nor reinferred. No variable preconditions are requested by this frozen set.

The PR targets main directly and has no production dependency on other open PRs. CPU baseline is 6dccb47; H100 separately composes study baseline 8cc73ab and changes only the two metadata production files. CUDA hashing/policy/workload remain identical across H100 variants. No isolated memory saving is claimed. Large traces, frozen packages and all 98 validation report files are saved outside Git with verified hashes.

Full methods, exact revisions, environments, commands, timing scope, checksums and limitations: final measurement report. Earlier skip-based measurement reports are explicitly historical; none of their numbers is relabeled as a result for this final implementation.

@Essoz Essoz changed the title Skip discarded tensor methods during metadata conversion Avoid warning contexts for verified native tensor method bindings Oct 27, 2026
@Essoz
Essoz marked this pull request as ready for review October 27, 2026 11:12
@Essoz
Essoz merged commit a9f3cdf into main Oct 30, 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