qa: fix ty caching and align CI with local run (#46278)
* Guard DeviceMesh import in continuous batching (#46205)
Cherry of danyalahmed1995:fix/46170-device-mesh-import-guard, applied as a
base so this branch can be rebased onto main once #46205 lands (it will then
drop out as a duplicate).
* fix ty caching and align CI with local run
* make sure we handle type/ignore correctly when torch is installed