Repository navigation
First changes for faster ntfield planning - #12
Merged
Merged
Conversation
- TravelTimeModel.encode_goal / travel_time_from_encoded_goal: T(·, q_g) from a goal encoded once. TD-NTFields keeps the goal embedding, P-NTFields [q_g, f(q_g)]; other models fall back to forward with the goal expanded. - TrainedField.towards(goal) returns a GoalField with travel_time(q) and gradient(q). MPPI plans with it. - check_method checks travel_time_from_encoded_goal against forward. On the UR5e benchmark MPPI goes from 92 to 42 ms per plan (scenarios) and from 195 to 113 ms (random pairs), with the same paths up to float32 rounding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… backends - ntfields.inference: InferenceModel, the tensor-only functions backends build (encode_goal, travel_time, pair_travel_time and the optional gradient, pair_gradient), and autograd_inference for any model, which TrainedField.towards now uses. TravelTimeModel.inference_model returns a model's own form (None by default). - TD-NTFields' inference form, from fast-ntfields: LipschitzLinear rescales, the duplicated sin(lin1(x)) and the block gates folded into constants, instance norm written out, and gradients in forward mode. It matches autograd through the model to ~1e-15 in float64; check_method checks this for any model that has an inference form. - accelerate(field, "eager" | "compile", cuda_graphs) returns an AcceleratedField, with CUDA graphs per batch size around each function. Gradients the inference form leaves out are absent and raise. - A Field protocol for the planners, benchmark_ur5e and travel_time_error, which now take either field. - On the UR5e benchmark (RTX 3090), compile + CUDA graphs plans MPPI in 9 ms instead of 41 (scenarios) and 20 ms instead of 110 (random pairs), with the same success counts, and the bidirectional gradient planner in 1.4 ms instead of 36. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The goal is encoded once as [q_g, f(q_g)], and gradients are first-order forward-mode jets through the encoder and the generator (tau_jet without its second derivatives), then T = ‖q_g - q_s‖ / τ. At q_s = q_g the norm's derivative is taken as 0, as autograd does. All five functions match autograd to ~1e-15 in float64. - With the pntfields_arm preset on the UR5e problem (random weights, RTX 3090), compile + CUDA graphs takes MPPI from 0.58 to 0.25 ms per step and the bidirectional gradient planner from 0.67 to 0.08 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A [tensorrt] extra (torch-tensorrt 2.14, Python 3.12+ by a marker, so the core stays on 3.11). - accelerate(field, "tensorrt", precision, batch): one engine per inference function, built on its first call with a dynamic batch, inside the CUDA graphs. fp16 applies to travel_time and pair_travel_time of models with float16-capable inference forms (TD-NTFields); encode_goal and the gradients stay fp32, and fp32 builds disable TF32. On the UR5e field at B = 1024, fp32 is within 1e-6 of the original model on T and 3e-5 on dT/dq, fp16 within 4e-3 on T. - ntfields export: serialized engines with named bindings, the original model's reference inputs and outputs, and a versioned meta.json, for runtimes outside Python. A test runs them through the bare TensorRT runtime. - On the UR5e benchmark (RTX 3090), TensorRT plans MPPI in 6.0-6.8 ms (scenarios) and 16-19 ms (random pairs), against compile's 7.7 and 19, and the gradient planner in 2.2 ms against 1.2: in Python, compile stays the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Importing torch_tensorrt on CPU torch raises AssertionError, which pytest.importorskip doesn't catch, so check for CUDA first. Drop torch-tensorrt from the dev group and exclude the tensorrt extra in install-cpu.sh: the runners can't use it, and its NVIDIA stub wheel failed to build on 3.14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the test jobs exclude it; pyright needs torch_tensorrt to check ntfields.accel.tensorrt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Also modify the CI workflow to skip installing the new TensorRT extra. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an interface for encoding the goal once and planning with that fixed goal.
Add an "accel" submodule with a function using some backend to produce an accelerated field that supports faster inference. Define the inference-form model for for TD-NTFields method.
Add the inference-form model for the P-NTFields method.
Add a TensorRT backend for the acceleration submodule.