Organisationsahrefsocannlcc9523 ()(lint-fmt)

(lint-fmt)

Link Copied
Code Copied

Logs

2025-10-07 16:49.47: New job: test ahrefs/ocannl https://github.com/ahrefs/ocannl.git#refs/heads/master (cc95235b4dfb75d66e45e5829405f627078fc66a) (linux-x86_64:(lint-fmt))
Base: ocaml/opam:debian-13-ocaml-4.08@sha256:b9828be178417e3bc607ef229c00d658316b130c027775f6069f6a7c473de176
ocamlformat version: version 0.27.0 (from opam)


To reproduce locally:


git clone --recursive "https://github.com/ahrefs/ocannl.git" -b "master" && cd "ocannl" && git reset --hard cc95235b
cat > Dockerfile <<'END-OF-DOCKERFILE'
FROM ocaml/opam:debian-13-ocaml-4.08@sha256:b9828be178417e3bc607ef229c00d658316b130c027775f6069f6a7c473de176
USER 1000:1000
RUN cd ~/opam-repository && (git cat-file -e f0e79555a122d396c3443ee754a7ea05991c000d || git fetch origin master) && git reset -q --hard f0e79555a122d396c3443ee754a7ea05991c000d && git log --no-decorate -n1 --oneline && opam update -u
RUN opam depext -i dune
WORKDIR /src
RUN opam depext -i ocamlformat=0.27.0
COPY --chown=1000:1000 . /src/
RUN opam exec -- dune build @fmt --ignore-promoted-rules || (echo "dune build @fmt failed"; exit 2)


END-OF-DOCKERFILE
docker build .
END-REPRO-BLOCK


2025-10-07 16:49.47: Using cache hint "ahrefs/ocannl-ocaml/opam:debian-13-ocaml-4.08@sha256:b9828be178417e3bc607ef229c00d658316b130c027775f6069f6a7c473de176-debian-13-4.08_opam-2.4-ocamlformat-f0e79555a122d396c3443ee754a7ea05991c000d"
2025-10-07 16:49.47: Using OBuilder spec:
((from ocaml/opam:debian-13-ocaml-4.08@sha256:b9828be178417e3bc607ef229c00d658316b130c027775f6069f6a7c473de176)
(user (uid 1000) (gid 1000))
(run (cache (opam-archives (target /home/opam/.opam/download-cache)))
(network host)
(shell "cd ~/opam-repository && (git cat-file -e f0e79555a122d396c3443ee754a7ea05991c000d || git fetch origin master) && git reset -q --hard f0e79555a122d396c3443ee754a7ea05991c000d && git log --no-decorate -n1 --oneline && opam update -u"))
(run (cache (opam-archives (target /home/opam/.opam/download-cache)))
(network host)
(shell "opam depext -i dune"))
(workdir /src)
(run (cache (opam-archives (target /home/opam/.opam/download-cache)))
(network host)
(shell "opam depext -i ocamlformat=0.27.0"))
(copy (src .) (dst /src/))
(run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)"))
)


2025-10-07 16:49.47: Waiting for resource in pool OCluster
2025-10-07 17:07.27: Waiting for worker…
2025-10-07 17:08.55: Got resource from pool OCluster
Building on odawa.caelum.ci.dev
All commits already cached
HEAD is now at cc95235b Merge pull request #408 from ahrefs/claude/issue-396-20250924-1048


(from ocaml/opam:debian-13-ocaml-4.08@sha256:b9828be178417e3bc607ef229c00d658316b130c027775f6069f6a7c473de176)
2025-10-07 17:08.56 ---> using "4f143e25e7620fadf6d4819085e998cd063e4132d1bf4b7e768f2c9645e2385a" from cache


/: (user (uid 1000) (gid 1000))


/: (run (cache (opam-archives (target /home/opam/.opam/download-cache)))
(network host)
(shell "cd ~/opam-repository && (git cat-file -e f0e79555a122d396c3443ee754a7ea05991c000d || git fetch origin master) && git reset -q --hard f0e79555a122d396c3443ee754a7ea05991c000d && git log --no-decorate -n1 --oneline && opam update -u"))
From https://github.com/ocaml/opam-repository
* branch                  master     -> FETCH_HEAD
bcac5d1731..98696b94e2  master     -> origin/master
f0e79555a1 Merge pull request #28630 from NathanReb/release-ocp-indent-1.9.0


<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised
default (at git+file:///home/opam/opam-repository):
[INFO] opam 2.1 and 2.2 include many performance and security improvements over 2.0; please consider upgrading (https://opam.ocaml.org/doc/Install.html)


The following actions will be performed:
- recompile opam-depext 1.2.3 [upstream changes]


<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[opam-depext.1.2.3] found in cache


<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed   opam-depext.1.2.3
-> installed opam-depext.1.2.3
Done.
# Run eval $(opam env) to update the current shell environment
2025-10-07 17:08.56 ---> using "c72483f169ab82d3d84c8f29314466f9e29cab66319dfdc663ab59b76bfea5e1" from cache


/: (run (cache (opam-archives (target /home/opam/.opam/download-cache)))
(network host)
(shell "opam depext -i dune"))
# Detecting depexts using vars: arch=x86_64, os=linux, os-distribution=debian, os-family=debian
# No extra OS packages requirements found.
# All required OS packages found.
# Now letting opam install the packages
The following actions will be performed:
- install dune 3.20.2


<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[dune.3.20.2] found in cache


<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed dune.3.20.2
Done.
# Run eval $(opam env) to update the current shell environment
2025-10-07 17:08.56 ---> using "f76d4f011d3e17c1ddd90d09fb924e60979f30cfb350df2ac4caf461b96f4386" from cache


/: (workdir /src)


/src: (run (cache (opam-archives (target /home/opam/.opam/download-cache)))
(network host)
(shell "opam depext -i ocamlformat=0.27.0"))
# Detecting depexts using vars: arch=x86_64, os=linux, os-distribution=debian, os-family=debian
# No extra OS packages requirements found.
# All required OS packages found.
# Now letting opam install the packages
The following actions will be performed:
- install sexplib0          v0.14.0  [required by base]
- install ocamlbuild        0.16.1   [required by fpath, astring, uuseg]
- install cmdliner          1.3.0    [required by ocamlformat]
- install either            1.0.0    [required by ocamlformat-lib]
- install menhirLib         20250912 [required by ocamlformat-lib]
- install csexp             1.5.2    [required by ocamlformat]
- install camlp-streams     5.0.1    [required by ocamlformat-lib]
- install seq               base     [required by re]
- install menhirSdk         20250912 [required by ocamlformat-lib]
- install fix               20250919 [required by ocamlformat-lib]
- install menhirCST         20250912 [required by menhir]
- install ocaml-version     4.0.1    [required by ocamlformat-lib]
- install ocamlfind         1.9.8    [required by ocp-indent, astring, fpath, uuseg]
- install dune-build-info   3.20.2   [required by ocamlformat-lib]
- install dune-configurator 3.20.2   [required by base]
- install re                1.11.0   [required by ocamlformat]
- install menhir            20250912 [required by ocamlformat-lib]
- install topkg             1.1.0    [required by fpath, astring, uuseg]
- install ocp-indent        1.9.0    [required by ocamlformat-lib]
- install base              v0.14.3  [required by ocamlformat-lib]
- install uutf              1.0.4    [required by ocamlformat-lib]
- install astring           0.8.5    [required by ocamlformat-lib]
- install stdio             v0.14.0  [required by ocamlformat-lib]
- install uucp              15.0.0   [required by uuseg]
- install fpath             0.7.3    [required by ocamlformat-lib]
- install uuseg             15.0.0   [required by ocamlformat-lib]
- install ocamlformat-lib   0.27.0   [required by ocamlformat]
- install ocamlformat       0.27.0
===== 28 to install =====


<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[astring.0.8.5] found in cache
[base.v0.14.3] found in cache
[camlp-streams.5.0.1] found in cache
[cmdliner.1.3.0] found in cache
[csexp.1.5.2] found in cache
[dune-build-info.3.20.2] found in cache
[dune-configurator.3.20.2] found in cache
[either.1.0.0] found in cache
[fix.20250919] found in cache
[fpath.0.7.3] found in cache
[menhir.20250912] found in cache
[menhirCST.20250912] found in cache
[menhirLib.20250912] found in cache
[menhirSdk.20250912] found in cache
[ocaml-version.4.0.1] found in cache
[ocamlbuild.0.16.1] found in cache
[ocamlfind.1.9.8] found in cache
[ocamlformat.0.27.0] found in cache
[ocamlformat-lib.0.27.0] found in cache
[ocp-indent.1.9.0] found in cache
[re.1.11.0] found in cache
[sexplib0.v0.14.0] found in cache
[stdio.v0.14.0] found in cache
[topkg.1.1.0] found in cache
[uucp.15.0.0] found in cache
[uuseg.15.0.0] found in cache
[uutf.1.0.4] found in cache


<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed seq.base
-> installed camlp-streams.5.0.1
-> installed cmdliner.1.3.0
-> installed csexp.1.5.2
-> installed either.1.0.0
-> installed fix.20250919
-> installed menhirCST.20250912
-> installed menhirLib.20250912
-> installed menhirSdk.20250912
-> installed ocaml-version.4.0.1
-> installed sexplib0.v0.14.0
-> installed re.1.11.0
-> installed dune-build-info.3.20.2
-> installed ocamlfind.1.9.8
-> installed dune-configurator.3.20.2
-> installed ocamlbuild.0.16.1
-> installed ocp-indent.1.9.0
-> installed base.v0.14.3
-> installed topkg.1.1.0
-> installed stdio.v0.14.0
-> installed menhir.20250912
-> installed uutf.1.0.4
-> installed astring.0.8.5
-> installed fpath.0.7.3
-> installed uucp.15.0.0
-> installed uuseg.15.0.0
-> installed ocamlformat-lib.0.27.0
-> installed ocamlformat.0.27.0
Done.


<><> ocp-indent.1.9.0 installed successfully ><><><><><><><><><><><><><><><><><>
=> This package requires additional configuration for use in editors. Install package 'user-setup', or manually:


* for Emacs, add these lines to ~/.emacs:
(add-to-list 'load-path "/home/opam/.opam/4.08/share/emacs/site-lisp")
(require 'ocp-indent)


* for Vim, add this line to ~/.vimrc:
set rtp^="/home/opam/.opam/4.08/share/ocp-indent/vim"
# Run eval $(opam env) to update the current shell environment
2025-10-07 17:08.56 ---> using "2524ad67a7f6147eb10d56f160848a96c6e255fb4f321e47b98a6852ce73760e" from cache


/src: (copy (src .) (dst /src/))
2025-10-07 17:08.56 ---> saved as "79f2725486ce1f6561b229d2e9b3214df9cb8db8d7eff75cc5bb74c506439abc"


/src: (run (shell "opam exec -- dune build @fmt --ignore-promoted-rules || (echo \"dune build @fmt failed\"; exit 2)"))
File "tensor/shape.mli", line 1, characters 0-0:
diff --git a/_build/default/tensor/shape.mli b/_build/default/tensor/.formatted/shape.mli
index 75ff71a..a68d82e 100644
--- a/_build/default/tensor/shape.mli
+++ b/_build/default/tensor/.formatted/shape.mli
@@ -195,8 +195,8 @@ type logic =
[s1], hence the name. *)
| Broadcast_tern of ternary_type * t * t * t  (** Matches the shapes for a ternary operation. *)
| Terminal of { is_param : bool; logic : terminal_type }
-      (** Extracts any available shape information from the initialization.
-          The [is_param] field indicates if this is a parameter tensor that requires gradients. *)
+      (** Extracts any available shape information from the initialization. The [is_param] field
+          indicates if this is a parameter tensor that requires gradients. *)
[@@deriving equal, sexp_of]


type update_id [@@deriving equal, compare, hash, sexp]
File "arrayjit/lib/context.ml", line 1, characters 0-0:
diff --git a/_build/default/arrayjit/lib/context.ml b/_build/default/arrayjit/lib/.formatted/context.ml
index 9752637..d1edcba 100644
--- a/_build/default/arrayjit/lib/context.ml
+++ b/_build/default/arrayjit/lib/.formatted/context.ml
@@ -24,7 +24,7 @@ type backend_wrapper =
-> backend_wrapper


type t = {
-  backend_wrapper : (backend_wrapper [@sexp.opaque]);
+  backend_wrapper : (backend_wrapper[@sexp.opaque]);
device_id : int;
backend_name : string;
initialized_nodes : Set.M(Tn).t; (* Track which nodes have been initialized *)
File "test/operations/attention_test.ml", line 1, characters 0-0:
diff --git a/_build/default/test/operations/attention_test.ml b/_build/default/test/operations/.formatted/attention_test.ml
index cf36028..3a2670a 100644
--- a/_build/default/test/operations/attention_test.ml
+++ b/_build/default/test/operations/.formatted/attention_test.ml
@@ -19,7 +19,6 @@ let () =
in


(* Create input tensors *)
-
let seq =
TDSL.range_of_shape ~label:[ "tgt" ] ~batch_dims:[ batch_size; tgt_seq_len ] ~input_dims:[]
~output_dims:[ tgt_vocab_size ] ()
File "test/operations/test_where_simple.ml", line 1, characters 0-0:
diff --git a/_build/default/test/operations/test_where_simple.ml b/_build/default/test/operations/.formatted/test_where_simple.ml
index 3a1f08c..9940f2a 100644
--- a/_build/default/test/operations/test_where_simple.ml
+++ b/_build/default/test/operations/.formatted/test_where_simple.ml
@@ -7,7 +7,7 @@ let () =
Tensor.unsafe_reinitialize ();
let ctx = Context.auto () in
(* Simple test: where(true, x, y) should have gradient flow to x only *)
-  let x = Tensor.number  ~grad_spec:Require_grad 2.0 in
+  let x = Tensor.number ~grad_spec:Require_grad 2.0 in
let y = Tensor.number ~grad_spec:Require_grad 3.0 in
let cond = Tensor.number 1.0 in
(* true *)
File "test/operations/transformer_test.ml", line 1, characters 0-0:
diff --git a/_build/default/test/operations/transformer_test.ml b/_build/default/test/operations/.formatted/transformer_test.ml
index 9918279..62d98b1 100644
--- a/_build/default/test/operations/transformer_test.ml
+++ b/_build/default/test/operations/.formatted/transformer_test.ml
@@ -33,30 +33,32 @@ let () =
(* For teacher forcing: create shifted versions of target sequence *)
(* tgt_input: positions 0 to tgt_seq_len-2 (all but last) *)
let tgt_input =
-    TDSL.range_of_shape ~label:[ "tgt_input" ] ~batch_dims:[ batch_size; tgt_seq_len - 1 ]
+    TDSL.range_of_shape ~label:[ "tgt_input" ]
+      ~batch_dims:[ batch_size; tgt_seq_len - 1 ]
~input_dims:[] ~output_dims:[ tgt_vocab_size ] ()
in


(* tgt_target: positions 1 to tgt_seq_len-1 (all but first) *)
(* In practice, this would be shifted token IDs, here we use one-hot for simplicity *)
let tgt_target =
-    NTDSL.init ~l:"tgt_target" ~prec:Ir.Ops.single ~b:[ batch_size; tgt_seq_len - 1 ] ~i:[]
-      ~o:[ tgt_vocab_size ]
+    NTDSL.init ~l:"tgt_target" ~prec:Ir.Ops.single
+      ~b:[ batch_size; tgt_seq_len - 1 ]
+      ~i:[] ~o:[ tgt_vocab_size ]
~f:(function
| [| _b; s; v |] ->
(* Create a simple one-hot pattern for testing *)
if v = Int.((s + 1) % tgt_vocab_size) then 1. else 0.
-        | idcs ->
-            failwith @@ "Invalid indices: "
-            ^ Sexp.to_string_hum ([%sexp_of: int array] idcs))
+        | idcs -> failwith @@ "Invalid indices: " ^ Sexp.to_string_hum ([%sexp_of: int array] idcs))
()
in


(* Create a causal mask for the decoder input (shifted target sequence) *)
(* Mask should be 0 for positions to mask out, 1 for positions to keep *)
let mask =
-    NTDSL.init ~l:"mask" ~prec:Ir.Ops.single ~b:[ batch_size; tgt_seq_len - 1 ]
-      ~i:[ tgt_seq_len - 1 ] ~o:[ 1 ]
+    NTDSL.init ~l:"mask" ~prec:Ir.Ops.single
+      ~b:[ batch_size; tgt_seq_len - 1 ]
+      ~i:[ tgt_seq_len - 1 ]
+      ~o:[ 1 ]
~f:(function
| [| _; s; _; t |] -> if s >= t then 1. else 0.
| idcs ->
@@ -79,7 +81,6 @@ let () =
let _ctx = Ocannl.Train.forward_once ctx loss in


(* Verify shapes *)
-  Stdio.printf "Loss shape:\n%s\n"
-    (Sexp.to_string_hum ([%sexp_of: Shape.t] loss.Tensor.shape));
+  Stdio.printf "Loss shape:\n%s\n" (Sexp.to_string_hum ([%sexp_of: Shape.t] loss.Tensor.shape));
Stdio.printf "Logits shape:\n%s\n%!"
(Sexp.to_string_hum ([%sexp_of: Shape.t] logits.Tensor.shape))
Warning: Invalid documentation comment:
File "tensor/shape.ml", line 24, characters 0-0:
End of text is not allowed in '[...]' (code).
File "test/operations/test_random_histograms.ml", line 1, characters 0-0:
diff --git a/_build/default/test/operations/test_random_histograms.ml b/_build/default/test/operations/.formatted/test_random_histograms.ml
index 7d0e22d..558b282 100644
--- a/_build/default/test/operations/test_random_histograms.ml
+++ b/_build/default/test/operations/.formatted/test_random_histograms.ml
@@ -18,16 +18,15 @@ let print_histogram bins ~title ~max_width =
let max_count = Array.max_elt bins ~compare:Int.compare |> Option.value ~default:0 in
let total = Array.fold bins ~init:0 ~f:( + ) in
Array.iteri bins ~f:(fun i count ->
-      let bar_width = (count * max_width) / max_count in
+      let bar_width = count * max_width / max_count in
let bar = String.make bar_width '#' in
-      let percentage = (Float.of_int count /. Float.of_int total) *. 100.0 in
+      let percentage = Float.of_int count /. Float.of_int total *. 100.0 in
printf "Bin %2d: %s %4d (%.1f%%)\n" i bar count percentage)


let test_uniform_at_histogram () =
Tensor.unsafe_reinitialize ();
let ctx = Context.auto () in
let module O = TDSL.O in
-
(* Generate a large batch of random numbers using uniform_at *)
(* Note: uniform_at produces 4 values per counter input (from uint4x32) *)
let num_counters = 2500 in
@@ -42,8 +41,8 @@ let test_uniform_at_histogram () =
ignore (Ocannl.Train.forward_once ctx uniform_values);
let result = Ir.Tnode.get_values uniform_values.value in


-  printf "Generated %d values from %d counters (%.1fx expansion)\n"
-    (Array.length result) num_counters
+  printf "Generated %d values from %d counters (%.1fx expansion)\n" (Array.length result)
+    num_counters
(Float.of_int (Array.length result) /. Float.of_int num_counters);


(* Create and print histogram *)
@@ -52,10 +51,9 @@ let test_uniform_at_histogram () =
print_histogram bins ~title:"Uniform Distribution [0, 1) Histogram" ~max_width:40;


(* Statistical tests *)
-  let mean = Array.fold result ~init:0.0 ~f:(+.) /. Float.of_int (Array.length result) in
+  let mean = Array.fold result ~init:0.0 ~f:( +. ) /. Float.of_int (Array.length result) in
let variance =
-    Array.fold result ~init:0.0 ~f:(fun acc x ->
-        acc +. ((x -. mean) *. (x -. mean)))
+    Array.fold result ~init:0.0 ~f:(fun acc x -> acc +. ((x -. mean) *. (x -. mean)))
/. Float.of_int (Array.length result)
in
let std_dev = Float.sqrt variance in
@@ -73,8 +71,8 @@ let test_uniform_at_histogram () =
let diff = Float.of_int observed -. expected_per_bin in
acc +. (diff *. diff /. expected_per_bin))
in
-  printf "  Chi-square statistic: %.2f (df=%d, critical value at 0.05: ~%.2f)\n"
-    chi_square (num_bins - 1) 30.14;
+  printf "  Chi-square statistic: %.2f (df=%d, critical value at 0.05: ~%.2f)\n" chi_square
+    (num_bins - 1) 30.14;


(* Check if all values are in range *)
let all_in_range = Array.for_all result ~f:(fun x -> Float.(x >= 0.0 && x < 1.0)) in
@@ -84,7 +82,6 @@ let test_normal_at_histogram () =
Tensor.unsafe_reinitialize ();
let ctx = Context.auto () in
let module O = TDSL.O in
-
(* Generate a large batch of random numbers using normal_at *)
(* Note: normal_at also produces 4 values per counter input *)
let num_counters = 2500 in
@@ -100,10 +97,9 @@ let test_normal_at_histogram () =
let result = Ir.Tnode.get_values normal_values.value in


(* Calculate statistics *)
-  let mean = Array.fold result ~init:0.0 ~f:(+.) /. Float.of_int (Array.length result) in
+  let mean = Array.fold result ~init:0.0 ~f:( +. ) /. Float.of_int (Array.length result) in
let variance =
-    Array.fold result ~init:0.0 ~f:(fun acc x ->
-        acc +. ((x -. mean) *. (x -. mean)))
+    Array.fold result ~init:0.0 ~f:(fun acc x -> acc +. ((x -. mean) *. (x -. mean)))
/. Float.of_int (Array.length result)
in
let std_dev = Float.sqrt variance in
@@ -124,15 +120,9 @@ let test_normal_at_histogram () =
printf "  Max: %.4f\n" max_val;


(* Check what percentage falls within standard deviations *)
-  let within_1_std =
-    Array.count result ~f:(fun x -> Float.(abs x <= 1.0))
-  in
-  let within_2_std =
-    Array.count result ~f:(fun x -> Float.(abs x <= 2.0))
-  in
-  let within_3_std =
-    Array.count result ~f:(fun x -> Float.(abs x <= 3.0))
-  in
+  let within_1_std = Array.count result ~f:(fun x -> Float.(abs x <= 1.0)) in
+  let within_2_std = Array.count result ~f:(fun x -> Float.(abs x <= 2.0)) in
+  let within_3_std = Array.count result ~f:(fun x -> Float.(abs x <= 3.0)) in


printf "  Within 1 std dev: %.1f%% (expected: ~68.3%%)\n"
(Float.of_int within_1_std /. Float.of_int (Array.length result) *. 100.0);
@@ -143,20 +133,23 @@ let test_normal_at_histogram () =


(* Normality test using skewness and kurtosis *)
let skewness =
-    let sum_cubed = Array.fold result ~init:0.0 ~f:(fun acc x ->
-        let diff = x -. mean in
-        acc +. (diff *. diff *. diff))
+    let sum_cubed =
+      Array.fold result ~init:0.0 ~f:(fun acc x ->
+          let diff = x -. mean in
+          acc +. (diff *. diff *. diff))
in
sum_cubed /. (Float.of_int (Array.length result) *. std_dev *. std_dev *. std_dev)
in


let kurtosis =
-    let sum_fourth = Array.fold result ~init:0.0 ~f:(fun acc x ->
-        let diff = x -. mean in
-        let diff2 = diff *. diff in
-        acc +. (diff2 *. diff2))
+    let sum_fourth =
+      Array.fold result ~init:0.0 ~f:(fun acc x ->
+          let diff = x -. mean in
+          let diff2 = diff *. diff in
+          acc +. (diff2 *. diff2))
in
-    (sum_fourth /. (Float.of_int (Array.length result) *. std_dev *. std_dev *. std_dev *. std_dev)) -. 3.0
+    (sum_fourth /. (Float.of_int (Array.length result) *. std_dev *. std_dev *. std_dev *. std_dev))
+    -. 3.0
in


printf "  Skewness: %.4f (expected: ~0.0)\n" skewness;
@@ -166,7 +159,6 @@ let test_batched_generation_consistency () =
Tensor.unsafe_reinitialize ();
let ctx = Context.auto () in
let module O = TDSL.O in
-
(* Test that batched generation gives consistent results *)
let batch_size = 100 in
let num_batches = 10 in
@@ -205,9 +197,8 @@ let test_batched_generation_consistency () =
Array.sort sorted ~compare:Float.compare;
let unique = ref 1 in
for i = 1 to Array.length sorted - 1 do
-      let diff = Float.abs (sorted.(i) -. sorted.(i-1)) in
-      if Float.(diff > 1e-7) then
-        unique := !unique + 1
+      let diff = Float.abs (sorted.(i) -. sorted.(i - 1)) in
+      if Float.(diff > 1e-7) then unique := !unique + 1
done;
!unique
in
@@ -217,11 +208,9 @@ let test_batched_generation_consistency () =
let unique_normal = count_unique !all_normal_values in


printf "Generated %d values in %d batches of %d\n" total_values num_batches batch_size;
-  printf "Uniform values: %d unique out of %d (%.1f%%)\n"
-    unique_uniform total_values
+  printf "Uniform values: %d unique out of %d (%.1f%%)\n" unique_uniform total_values
(Float.of_int unique_uniform /. Float.of_int total_values *. 100.0);
-  printf "Normal values: %d unique out of %d (%.1f%%)\n"
-    unique_normal total_values
+  printf "Normal values: %d unique out of %d (%.1f%%)\n" unique_normal total_values
(Float.of_int unique_normal /. Float.of_int total_values *. 100.0);


(* Verify batch consistency of statistical properties *)
@@ -234,40 +223,44 @@ let test_batched_generation_consistency () =
let normal_batch = Array.sub !all_normal_values ~pos:start_idx ~len:batch_size in


batch_means_uniform.(batch) <-
-      Array.fold uniform_batch ~init:0.0 ~f:(+.) /. Float.of_int batch_size;
+      Array.fold uniform_batch ~init:0.0 ~f:( +. ) /. Float.of_int batch_size;
batch_means_normal.(batch) <-
-      Array.fold normal_batch ~init:0.0 ~f:(+.) /. Float.of_int batch_size
+      Array.fold normal_batch ~init:0.0 ~f:( +. ) /. Float.of_int batch_size
done;


let mean_of_means_uniform =
-    Array.fold batch_means_uniform ~init:0.0 ~f:(+.) /. Float.of_int num_batches
+    Array.fold batch_means_uniform ~init:0.0 ~f:( +. ) /. Float.of_int num_batches
in
let mean_of_means_normal =
-    Array.fold batch_means_normal ~init:0.0 ~f:(+.) /. Float.of_int num_batches
+    Array.fold batch_means_normal ~init:0.0 ~f:( +. ) /. Float.of_int num_batches
in


let std_of_means_uniform =
-    let diff_sum = Array.fold batch_means_uniform ~init:0.0 ~f:(fun acc x ->
-        let diff = x -. mean_of_means_uniform in
-        acc +. (diff *. diff)) in
+    let diff_sum =
+      Array.fold batch_means_uniform ~init:0.0 ~f:(fun acc x ->
+          let diff = x -. mean_of_means_uniform in
+          acc +. (diff *. diff))
+    in
Float.sqrt (diff_sum /. Float.of_int num_batches)
in
let std_of_means_normal =
-    let diff_sum = Array.fold batch_means_normal ~init:0.0 ~f:(fun acc x ->
-        let diff = x -. mean_of_means_normal in
-        acc +. (diff *. diff)) in
+    let diff_sum =
+      Array.fold batch_means_normal ~init:0.0 ~f:(fun acc x ->
+          let diff = x -. mean_of_means_normal in
+          acc +. (diff *. diff))
+    in
Float.sqrt (diff_sum /. Float.of_int num_batches)
in


printf "\nBatch means consistency:\n";
-  printf "  Uniform: mean of batch means = %.4f, std = %.4f\n"
-    mean_of_means_uniform std_of_means_uniform;
-  printf "  Normal: mean of batch means = %.4f, std = %.4f\n"
-    mean_of_means_normal std_of_means_normal
+  printf "  Uniform: mean of batch means = %.4f, std = %.4f\n" mean_of_means_uniform
+    std_of_means_uniform;
+  printf "  Normal: mean of batch means = %.4f, std = %.4f\n" mean_of_means_normal
+    std_of_means_normal


let () =
test_uniform_at_histogram ();
printf "\n";
test_normal_at_histogram ();
printf "\n";
-  test_batched_generation_consistency ()
\ No newline at end of file
+  test_batched_generation_consistency ()
dune build @fmt failed
"/usr/bin/env" "bash" "-c" "opam exec -- dune build @fmt --ignore-promoted-rules || (echo "dune build @fmt failed"; exit 2)" failed with exit status 2
2025-10-07 17:08.57: Job failed: Failed: Build failed