fix missing lock in profiling graph compilation (#29886)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29886
Fixes https://github.com/pytorch/pytorch/issues/29764
Test Plan: Imported from OSS
Differential Revision: D18523903
Pulled By: zdevito
fbshipit-source-id: 4e2b04102ee9f6312e4a7b48536392454e6c1b79