Skip to content

Don't populate f_locals to check guards #93753

@jansel

Description

@jansel

Currently, TorchDynamo calls PyFrame_FastToLocalsWithError (docs).

Internally in cpython, this converts between the "frame fast variables" (a flat C array of PyObject*) and frame->f_locals (a python dictionary).

frame->f_locals starts as NULL, and is only populated by this function.

This works, but is higher overhead than it needs to be.

We should rewrite the generated guards to use the "fast variables" data structure directly.

cc @ezyang @bdhirsh @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @msaroufim @zou3519 @aakhundov @soumith @wconstab @ngimel @yanboliang @Xia-Weiwen @desertfire

Metadata

Metadata

Assignees

Labels

dynamo-perfImpacts dynamo perfdynamo-triage-june2024enhancementNot as big of a feature, but technically not a bug. Should be easy to fixmodule: dynamomodule: guardsoncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions