Skip to content

autodiff: generate TypeTree metadata for extractvalue#158440

Draft
ZuseZ4 wants to merge 3 commits into
rust-lang:mainfrom
ZuseZ4:typetrees-for-enzyme4
Draft

autodiff: generate TypeTree metadata for extractvalue#158440
ZuseZ4 wants to merge 3 commits into
rust-lang:mainfrom
ZuseZ4:typetrees-for-enzyme4

Conversation

@ZuseZ4

@ZuseZ4 ZuseZ4 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Further improvements after #158333

This is the first time that we actually generate enough typetree information to make autodiff succed in compiling a previously failing build.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 26, 2026
@rust-bors

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the typetrees-for-enzyme4 branch from 1b673bf to d773c15 Compare June 27, 2026 07:33
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the typetrees-for-enzyme4 branch from d773c15 to e252e58 Compare June 29, 2026 02:13
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jun 29, 2026
@rust-log-analyzer

This comment has been minimized.

…r generation for memcpy.

This moves a TA failure in the testcase from memcpy to a later location.
@ZuseZ4 ZuseZ4 force-pushed the typetrees-for-enzyme4 branch from e252e58 to ab0cb6a Compare June 30, 2026 02:51
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the typetrees-for-enzyme4 branch from ab0cb6a to 5d683a6 Compare June 30, 2026 12:12
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the typetrees-for-enzyme4 branch from 5d683a6 to 9991c49 Compare June 30, 2026 12:22
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[TIMING:end] tool::ToolBuild { build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "tidy", path: "src/tools/tidy", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 57.637
[TIMING:end] tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
Diff in /checkout/compiler/rustc_codegen_ssa/src/mir/statement.rs:1:
+use rustc_ast::expand::typetree::{FncTree, TypeTree};
 use rustc_middle::mir::{self, NonDivergingIntrinsic, StmtDebugInfo};
+use rustc_middle::ty::typetree::typetree_from_ty;
 use rustc_middle::{bug, span_bug, ty};
 use tracing::instrument;
 
Diff in /checkout/compiler/rustc_codegen_ssa/src/mir/statement.rs:5:
-use rustc_ast::expand::typetree::{TypeTree, FncTree};
-use rustc_middle::ty::typetree::typetree_from_ty;
-
-
 use super::{FunctionCx, LocalRef};
 use crate::mir::retag;
 use crate::traits::*;
Diff in /checkout/compiler/rustc_codegen_ssa/src/mir/statement.rs:117:
 
                 let tt = typetree_from_ty(bx.tcx(), pointee).add_indirection();
                 dbg!(&tt);
-                let fnc_tree = FncTree {
-                    args: vec![tt.clone(), tt],
-                    ret: TypeTree::new(),
-                };
+                let fnc_tree = FncTree { args: vec![tt.clone(), tt], ret: TypeTree::new() };
 
                 bx.memcpy(dst, align, src, align, bytes, crate::MemFlags::empty(), Some(fnc_tree));
             }
Diff in /checkout/tests/run-make/autodiff/type-trees/iter2/asdf.rs:1:
 #![feature(autodiff)]
 use std::autodiff::*;
 use std::f64::consts::FRAC_PI_6;
+
 use ndarray::arr1;
 
 #[autodiff_forward(da_args, Dual, Dual)]
Diff in /checkout/tests/run-make/autodiff/type-trees/iter2/asdf.rs:13:
     let m = arr1(&[2.001829]);
     let sigma = arr1(&[3.618353]);
     let epsilon_k = arr1(&[208.1101]);
-    
+
     // ... as does this ...
     //let m = vec![2.001829];
     //let sigma = vec![3.618353];
Diff in /checkout/tests/run-make/autodiff/type-trees/iter2/asdf.rs:26:
 
     let n = moles.len();
     let t_inv = temperature.recip();
-    let diameter: Vec<f64> = (0..n)
-        .map(|i| -((t_inv * -3.0 * epsilon_k[i]).exp() * 0.12 - 1.0) * sigma[i])
-        .collect();
+    let diameter: Vec<f64> =
+        (0..n).map(|i| -((t_inv * -3.0 * epsilon_k[i]).exp() * 0.12 - 1.0) * sigma[i]).collect();
 
     //let partial_density: Vec<f64> = moles.iter().cloned().map(|n| n / volume).collect(); // <- works
     let partial_density: Vec<f64> = moles.iter().map(|&n| n / volume).collect(); // <- crashes
Diff in /checkout/tests/run-make/autodiff/type-trees/iter2/asdf.rs:56:
 fn main() {
     let t = 250.0;
     let v = 1000.0;
-        
+
     let seed = &[1.0, 0.0, 0.0]; // first entry is temperature
     let da_dt_enz_args = da_args(&[t, v, 1.0], seed);
     dbg!(&da_dt_enz_args);
fmt: checked 6972 files
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:01:34
  local time: Tue Jun 30 13:40:29 UTC 2026
  network time: Tue, 30 Jun 2026 13:40:29 GMT

ret: TypeTree::new(),
};

bx.memcpy(dst, align, src, align, bytes, crate::MemFlags::empty(), Some(fnc_tree));

@ZuseZ4 ZuseZ4 Jul 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

"Don't put a typetree in there" (quote @saethlin)

View changes since the review

@ZuseZ4 ZuseZ4 Jul 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Walk the stacktrace, figure out where it's coming from. Presumably RawVec and some slice functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs F-autodiff `#![feature(autodiff)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants