Commit Graph
52 Commits
Author SHA1 Message Date
Chamath Wijesekera 96914d2425 Enable Pyrefly for deeplearning/projects
Summary:
Enables Pyrefly for `deeplearning/projects` by setting `python.set_pyrefly(True)` in the subdirectory PACKAGE file and adding targeted `# pyrefly: ignore` annotations. Part of splitting D113608658 into a per-subdirectory stack; the final diff performs the directory-level flip.

#buildall

Reviewed By: shugurov

Differential Revision: D113962590

fbshipit-source-id: 2c69a82e5f862fa2fcdfbecba9668814df931026
2026-07-30 17:21:37 -07:00
generatedunixname89002005307016 6dbb02bd38 Suppress type errors for Pyre upgrade
Summary:
This diff was automatically generated by the Pyre per-target upgrade tool.

It adds `# pyre-fixme` or `pyrefly: ignore` comments to suppress type errors that will be introduced by an upcoming Pyre or Pyrefly release. These suppressions allow the upgrade to proceed without breaking existing code.

Upgrading to new pyrefly Version. Without landing this diff your type checking tests may break. If assigned as a reviewer please help us get these diffs across the finish line. Thank you!

#pyreupgrade

Differential Revision: D113834959

fbshipit-source-id: 63169c3df9d594b58d39a33ab51c8866629dd1fa
2026-07-27 19:25:12 -07:00
Jaime Rodriguez Sanchez 46957e4780 SAM3: production-faithful torch.compile A/B benchmark
Summary:
scripts/bench_compile.py + :bench_compile target. Builds Sam3VideoPredictorMultiGPU with the exact scene_service constructor args + sam3_v4.pt, toggling compile, and measures the real per-frame served sequence (start_session on a single image + K add_prompt, mirroring Sam3Client.getMasksStream) plus optional propagate. --native-warmup mirrors prod Sam3DenseTrackingModel.warmup (_compile_model() direct + single-image warm) to verify 0 serve-time recompiles under TORCH_LOGS=recompiles.

Needs -c fbcode.enable_gpu_sections=true (else cudaErrorInvalidKernelImage on H100). Reuses measure_speed.py synth+timing helpers.

Reviewed By: flanggut

Differential Revision: D111922692

fbshipit-source-id: b2c96da965ce67e76e5e8837d3b08e020d138eea
2026-07-15 04:05:53 -07:00
generatedunixname2333890303787380 5dd401d1c5 Remove F401 unused imports in fbcode//deeplearning/projects/sam3_release:_sam3
Reviewed By: brittanyrey

Differential Revision: D108589523

fbshipit-source-id: 6e56192d205566bd3cc393839b15a3e921849fa8
2026-06-15 12:12:38 -07:00
generatedunixname1401739305002972 8e451d5eb4 Fix PYRE_MISSING_ANNOTATIONS issues in fbcode/deeplearning/projects/sam3_release/sam3/model/sam3_image.py
Differential Revision: D105340230

fbshipit-source-id: ecb32f6146dcff7e16dd184f2e54c57897923bc3
2026-05-23 08:49:56 -07:00
generatedunixname1401739305002972 2814fa6194 Fix PYRE_MISSING_ANNOTATIONS issues in fbcode/deeplearning/projects/sam3_release/sam3/model/io_utils.py
Differential Revision: D104793065

fbshipit-source-id: 1e6d98ee42fb51acfa4b0ce4b9bbe1251363b3e0
2026-05-16 01:56:52 -07:00
generatedunixname2094418054467506 32f5f81ab9 Fix python_unnecessary_generator_set_comprehension issues in deeplearning/.../silver/extract_frames.py
Differential Revision: D105295334

fbshipit-source-id: 3166b2df09bd7af1cea4dbd8dd7ba525a25bf9dd
2026-05-15 04:42:36 -07:00
generatedunixname2094418054467506 f66a2514df Fix python_unnecessary_generator_set_comprehension issues in deeplearning/.../transforms/filter_query_transforms.py
Differential Revision: D104956511

fbshipit-source-id: f15651e5407d543887ddff7e6bb0d5b494936443
2026-05-13 03:17:47 -07:00
generatedunixname1401739305002972 4cbac146c1 Fix PYRE_MISSING_ANNOTATIONS issues in fbcode/deeplearning/projects/sam3_release/sam3/model/io_utils.py
Differential Revision: D104644929

fbshipit-source-id: 53867910385982e0620979b9a46049fe4d02224d
2026-05-11 07:06:53 -07:00
Minh Vu 2530a8a7af Drop per-session dict refs in close_session to fix monotonic GPU climb
Summary:
SAM3 IPNext replicas serving long-running session workloads exhibit a
monotonic climb in PyTorch's *allocated* GPU memory bucket (not the
cache bucket), to the point of OOM-ing single-call transients at
concurrency=1. Two recent client observations from the
video_product_highlight pipeline:

  jiid 37154706936429064 (2026-05-09): 4 SAM3 OOMs in the first 41
    seconds, AIMD shrunk concurrency 4→1, run failed at lifespan with
    3,332 stranded checkpoints and 0 final detection rows.
  jiid 41658306563594281 (2026-05-10): same fingerprint within 90s of
    startup; 474 OOM-retry events over 8h, run averaged 3 ads/min
    (vs ~7.5 ads/min on a fresh replica).

The OOM messages from these runs all show the same memory state:

  this process has 94.99 GiB memory in use.
  93.54 GiB allocated by PyTorch.
  577.70 MiB reserved by PyTorch but unallocated.

i.e., ``empty_cache`` *was* firing (reserved-but-unallocated is tiny),
but the *allocated* bucket — backed by live tensor objects — is sitting
at ~93 GiB. That's the signature of dict-keyed references staying
alive: every closed session's tensors are still in the allocated pool
because the dict that keys them is being held by something the close
path doesn't reach.

D103081459 (2026-04-29) added ``empty_cache`` after ``gc.collect()``,
which fixed the *cache*-side leak. D103602738 (2026-05-03) gated it on
device memory pressure. Neither addressed the allocated-side leak
because they relied on ``del session`` triggering refcount-zero on the
inference_state dict — which, in practice, doesn't happen reliably
across long-lived workers (closure capture, asyncio task references,
metrics buffers, or simple cycles can keep the wrapper dict alive past
the local ``del``).

Fix: explicitly call ``.clear()`` on both ``session["state"]`` and
``session`` before ``del session``. ``.clear()`` immediately drops
every dict-keyed reference, releasing the per-session tensors
regardless of whether the wrapper dict itself survives. ``init_state``
populates ``state`` with these heavy GPU-resident keys:

  - ``input_batch`` (BatchedDatapoint with ``img_batch`` = video frames
    on device, plus per-frame find_inputs)
  - ``constants["empty_geometric_prompt"]`` (zeroed device tensors)
  - ``feature_cache`` (per-frame feature maps, populated during
    propagation)
  - ``cached_frame_outputs`` (per-frame outputs, populated during
    propagation)
  - ``tracker_inference_states``, ``tracker_metadata`` (per-track
    state, populated during add_prompt + propagation)

A single ``state.clear()`` covers all of them and any future heavy
keys, so the fix doesn't need to enumerate them. Lists in the dict
hold ``None``s for per-frame slots and don't need separate handling.

___

overriding_review_checks_triggers_an_audit_and_retroactive_review
Oncall Short Name: creative_sticker_model

Differential Revision: D104607919

fbshipit-source-id: 6022802f07f51ee72c77ad008acdf94afe763433
2026-05-10 20:18:53 -07:00