Skip to content

Add latent novelty query strategy using OODGuard#1678

Merged
ktangsali merged 6 commits into
NVIDIA:mainfrom
ktangsali:ln-al
Jun 3, 2026
Merged

Add latent novelty query strategy using OODGuard#1678
ktangsali merged 6 commits into
NVIDIA:mainfrom
ktangsali:ln-al

Conversation

@ktangsali

Copy link
Copy Markdown
Collaborator

PhysicsNeMo Pull Request

Description

Checklist

Dependencies

Review Process

All PRs are reviewed by the PhysicsNeMo team before merging.

Depending on which files are changed, GitHub may automatically assign a maintainer for review.

We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.

AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.

@copy-pr-bot

copy-pr-bot Bot commented May 27, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ktangsali ktangsali marked this pull request as ready for review May 27, 2026 22:19
@ktangsali ktangsali requested a review from mnabian May 27, 2026 22:20
@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces LatentNoveltyQueryStrategy, a third acquisition strategy for the active-learning aero example that ranks unlabeled samples by their average kNN cosine distance in the encoder's geometry latent space, reusing the existing OODGuard infrastructure. It also adds the public OODGuard.score_geometry() method that exposes the raw continuous kNN distance signal needed by the strategy.

  • OODGuard.score_geometry() (ood_guard.py): clean addition with proper input validation, AMP upcasting, k-clamping, and 7 new tests covering all documented error paths and edge cases.
  • LatentNoveltyQueryStrategy (strategies.py): calibrates a fresh OODGuard on the labeled pool each round, scores the unlabeled pool shard-parallel across DDP ranks, and falls back to class-balanced random on cold start. The unlabeled scoring phase has a shape bug when the unlabeled pool is smaller than world-size.
  • Documentation, CHANGELOG, and config are updated to reflect the new strategy and benchmark results.

Important Files Changed

Filename Overview
physicsnemo/experimental/guardrails/embedded/ood_guard.py Adds public score_geometry() method that returns raw per-sample kNN cosine distances without thresholding; well-structured with proper input validation, AMP upcasting, and k-clamping consistent with _check_geometry.
examples/cfd/external_aerodynamics/active_learning_aero/src/strategies.py Adds LatentNoveltyQueryStrategy with calibrate-then-score pipeline; the unlabeled scoring phase has a tensor-shape bug when len(unlabeled) < world_size that produces (1, 0) instead of (0, 2), breaking padded_all_gather.
test/experimental/guardrails/embedded/test_ood_guard.py Adds 7 tests for score_geometry() covering shape contract, OOD monotonicity, error cases, k-clamping, AMP inputs, and silent logging.
examples/cfd/external_aerodynamics/active_learning_aero/src/run_al.py Wires LatentNoveltyQueryStrategy into the acquisition strategy selector; reads latent_novelty_knn_k from config with a safe default of 10.
examples/cfd/external_aerodynamics/active_learning_aero/src/conf/al_config.yaml Adds latent_novelty_knn_k: 10 config key and updates the acquisition comment to include latent_novelty.

Reviews (1): Last reviewed commit: "Merge branch 'main' into ln-al" | Re-trigger Greptile

Comment thread examples/cfd/external_aerodynamics/active_learning_aero/src/strategies.py Outdated
Comment thread physicsnemo/experimental/guardrails/embedded/ood_guard.py

@mnabian mnabian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the ODD guard look good to me.

Comment thread examples/cfd/external_aerodynamics/active_learning_aero/src/run_al.py Outdated
Comment thread examples/cfd/external_aerodynamics/active_learning_aero/src/strategies.py Outdated

@laserkelvin laserkelvin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

Comment thread examples/cfd/external_aerodynamics/active_learning_aero/src/strategies.py Outdated
Comment thread physicsnemo/experimental/guardrails/embedded/ood_guard.py Outdated
@ktangsali ktangsali requested a review from laserkelvin June 3, 2026 00:19

@laserkelvin laserkelvin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ktangsali

Copy link
Copy Markdown
Collaborator Author

/ok to test 62f7fed

@ktangsali

Copy link
Copy Markdown
Collaborator Author

/blossom-ci

@ktangsali ktangsali enabled auto-merge June 3, 2026 00:44
@ktangsali ktangsali added this pull request to the merge queue Jun 3, 2026
Merged via the queue into NVIDIA:main with commit 651c626 Jun 3, 2026
6 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.

3 participants