frink-cli 0.59.0

llama.cpp-style CLI for the Frink inference engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
use crate::argv::rewrite_llama_style_argv;

fn rewrite(argv: &[&str]) -> Vec<String> {
    rewrite_llama_style_argv(argv.iter().copied().map(String::from).collect())
        .unwrap_or_else(|e| panic!("{argv:?}: {e}"))
}

/// `try_parse_from`, not `parse_from`: clap's non-`try` parser exits
/// the *process* on a parse error, which takes the whole test binary
/// down with it and reports as "test exited abnormally" instead of
/// naming the test that broke.
fn parse_cli(argv: Vec<String>) -> super::Cli {
    use clap::Parser;
    super::Cli::try_parse_from(&argv)
        .unwrap_or_else(|e| panic!("`{}` did not parse: {e}", argv.join(" ")))
}

/// Every subcommand clap knows about has to reach clap as itself, or
/// the rewriter turns it into an implicit `run` and the user gets a
/// completion instead of the command they typed. This is a silent
/// failure -- no error, no clue. The rewriter reads the subcommand
/// names from clap now rather than from a list beside it, and this
/// holds it to that for every one, aliases included.
#[test]
fn every_clap_subcommand_survives_the_argv_rewriter() {
    use clap::CommandFactory;
    for sub in super::Cli::command().get_subcommands() {
        for name in std::iter::once(sub.get_name()).chain(sub.get_all_aliases()) {
            let rewritten = rewrite(&["frink", name, "--help"]);
            assert_eq!(
                rewritten[1], name,
                "`frink {name}` must reach clap as `{name}`, not as `{}`",
                rewritten[1]
            );
        }
    }
}

/// `frink quantize --help` and `Target::ALL` are two structures that
/// must agree about which targets write, and for three PRs they did
/// not: the help said "Q8_0, plus Q4_K_S / Q4_K_M with --pure" while
/// the code wrote six targets, mixes included. So the help is checked
/// against the table: every target the policy accepts is named in
/// the subcommand's long help, and `--imatrix` is mentioned because
/// the encoders take one.
#[test]
fn the_quantize_help_names_every_target_the_policy_accepts() {
    use clap::CommandFactory;
    let cmd = super::Cli::command();
    let quantize = cmd
        .get_subcommands()
        .find(|c| c.get_name() == "quantize")
        .expect("quantize subcommand");
    let help = quantize
        .get_long_about()
        .map(|s| s.to_string())
        .expect("quantize has a long help");
    for target in crate::quantize::policy::Target::ALL {
        assert!(
            help.contains(target.name()),
            "quantize's help does not mention {}, which `--type` accepts",
            target.name()
        );
    }
    assert!(
        help.contains("--imatrix"),
        "quantize's help does not mention --imatrix"
    );
    assert!(
        !help.contains("with `--pure`"),
        "quantize's help still ties the K-quants to --pure"
    );
}

/// The named case of the above, kept explicit because `serve` is the
/// one that would start a *completion* while the user waited for an
/// HTTP server: it prints tokens and exits 0, so a supervisor
/// watching for the `frink.server.ready` line just hangs.
#[test]
fn serve_is_not_rewritten_into_an_implicit_run() {
    assert_eq!(
        rewrite(&["frink", "serve", "-m", "model.gguf", "--port", "0"]),
        ["frink", "serve", "-m", "model.gguf", "--port", "0"]
    );
}

/// The rewriter still has to translate llama.cpp's multi-character
/// short options *inside* a `serve` invocation -- `frink-server`
/// accepted `-ngl`/`-dev`, so `frink serve` has to as well. Without the
/// feature the stub takes its arguments verbatim and only explains.
#[cfg(feature = "serve")]
#[test]
fn serve_keeps_the_llama_style_short_options() {
    assert_eq!(
        rewrite(&["frink", "serve", "-ngl", "all", "-dev", "metal"]),
        [
            "frink",
            "serve",
            "--n-gpu-layers",
            "all",
            "--device",
            "metal"
        ]
    );
}

/// `serve` must not claim a registry slot from here: the server
/// claims its own as `"server"`, and a second guard on the same pid
/// would deregister the live server when it dropped.
#[test]
fn serve_does_not_claim_the_instance_registry_from_the_cli_side() {
    let cli = parse_cli(rewrite(&["frink", "serve", "-m", "model.gguf"]));
    assert!(
        super::instance_target(&cli.command).is_none(),
        "`frink serve` must leave the registry to frink_server::run_server"
    );

    // The other half of the invariant: a completion run still
    // registers, so this test fails if `instance_target` were
    // "fixed" by making it return None for everything.
    let cli = parse_cli(rewrite(&["frink", "-m", "model.gguf"]));
    assert_eq!(
        super::instance_target(&cli.command).map(|(c, _)| c),
        Some("run")
    );
}

/// Flag parity with the standalone binary, asserted against
/// `ServerArgs` itself rather than against the documented subset:
/// `docs/CLI.md` lists eight of the eleven flags and reads as
/// exhaustive, so a `serve` written from the docs would ship a
/// downgrade nobody noticed.
#[cfg(feature = "serve")]
#[test]
fn serve_exposes_every_flag_frink_server_has() {
    use clap::CommandFactory;
    let ids = |cmd: &clap::Command| -> std::collections::BTreeSet<String> {
        cmd.get_arguments()
            .map(|a| a.get_id().to_string())
            .filter(|id| id != "help" && id != "version")
            .collect()
    };
    let standalone = ids(&frink_server::ServerArgs::command());
    let root = super::Cli::command();
    let serve = ids(root.find_subcommand("serve").expect("serve subcommand"));
    assert!(
        standalone.is_subset(&serve),
        "`frink serve` is missing flags `frink-server` accepts: {:?}",
        standalone.difference(&serve).collect::<Vec<_>>()
    );
}

/// Parity of *values*, not just of flag names: every flag has to
/// land in the same field with the same value it would have reached
/// through `frink-server`'s own argv path. `--port 0` is in here on
/// purpose -- it is a request for a kernel-assigned port, and a
/// front end that dropped it would silently serve on 8383.
#[cfg(feature = "serve")]
#[test]
fn serve_parses_the_same_command_line_as_frink_server() {
    use clap::Parser;
    let flags = [
        "-m",
        "model.gguf",
        "--host",
        "0.0.0.0",
        "--port",
        "0",
        "-t",
        "4",
        "--device",
        "metal",
        "--n-gpu-layers",
        "all",
        "--mcp-config",
        "mcp.json",
        "--exit-on-stdin-close",
        "--allow-multiple-instances",
    ];

    let standalone =
        frink_server::ServerArgs::try_parse_from(std::iter::once("frink-server").chain(flags))
            .expect("frink-server accepts this command line");

    let mut argv = vec!["frink".to_string(), "serve".to_string()];
    argv.extend(flags.iter().map(|f| f.to_string()));
    let cli = parse_cli(rewrite_llama_style_argv(argv).unwrap());
    let super::Commands::Serve(via_cli) = cli.command else {
        panic!("`frink serve …` did not parse as the serve subcommand");
    };

    assert_eq!(via_cli, standalone);
}

/// `--allow-multiple-instances` is declared `global = true`, so both
/// sides of the subcommand are legal places to type it and both have
/// to reach the server -- if the leading form silently did nothing,
/// the server would refuse to start on a host where the operator
/// had already said a second instance was fine.
///
/// Two mechanisms make it work, one of them not ours: the argv
/// rewriter must not mistake the leading flag for llama.cpp-style
/// argv (it used to, see the test below), and clap propagates the
/// root global's *value* into the subcommand's own flag because both
/// carry the id `allow_multiple_instances`. That second half is
/// clap's behaviour, not a guarantee we wrote, which is exactly why
/// it is pinned here: rename either side and this test fails while
/// nothing else would.
#[cfg(feature = "serve")]
#[test]
fn allow_multiple_instances_reaches_serve_from_either_side_of_the_subcommand() {
    use clap::Parser;
    let expected = frink_server::ServerArgs::try_parse_from([
        "frink-server",
        "-m",
        "model.gguf",
        "--allow-multiple-instances",
    ])
    .unwrap();

    for argv in [
        &[
            "frink",
            "serve",
            "-m",
            "model.gguf",
            "--allow-multiple-instances",
        ][..],
        &[
            "frink",
            "--allow-multiple-instances",
            "serve",
            "-m",
            "model.gguf",
        ][..],
    ] {
        let cli = parse_cli(rewrite(argv));
        assert!(
            cli.allow_multiple_instances,
            "`{}` did not set the root flag",
            argv.join(" ")
        );
        let super::Commands::Serve(args) = cli.command else {
            panic!("`{}` did not parse as the serve subcommand", argv.join(" "));
        };
        assert_eq!(
            args,
            expected,
            "`{}` did not reach the server as an opt-in",
            argv.join(" ")
        );
    }
}

/// The rewriter half of the above, stated on its own: a global flag
/// before the subcommand must not turn the subcommand into an
/// argument of an implicit `run`.
#[test]
fn a_global_flag_before_a_subcommand_does_not_trigger_the_run_rewrite() {
    assert_eq!(
        rewrite(&[
            "frink",
            "--allow-multiple-instances",
            "serve",
            "-m",
            "x.gguf"
        ]),
        [
            "frink",
            "--allow-multiple-instances",
            "serve",
            "-m",
            "x.gguf"
        ]
    );
    // …and llama.cpp-style argv behind the same flag still gets it.
    assert_eq!(
        rewrite(&["frink", "--allow-multiple-instances", "-m", "x.gguf"]),
        ["frink", "run", "--allow-multiple-instances", "-m", "x.gguf"]
    );
}

/// `--list-devices` is the flag that is easiest to lose, because it
/// exits before anything is served and so no smoke test covers it.
#[cfg(feature = "serve")]
#[test]
fn serve_accepts_list_devices_on_its_own() {
    use clap::Parser;
    let cli = parse_cli(rewrite(&["frink", "serve", "--list-devices"]));
    let super::Commands::Serve(args) = cli.command else {
        panic!("not the serve subcommand");
    };
    assert_eq!(
        args,
        frink_server::ServerArgs::try_parse_from(["frink-server", "--list-devices"]).unwrap()
    );
}

/// Without the feature the subcommand still exists and still
/// swallows the server's flags, so the user gets the sentence that
/// names the fix instead of clap's "unrecognized subcommand".
#[cfg(not(feature = "serve"))]
#[test]
fn serve_without_the_feature_explains_itself_instead_of_erroring_out_of_clap() {
    let cli = parse_cli(rewrite(&["frink", "serve", "-m", "model.gguf"]));
    let super::Commands::Serve { args } = cli.command else {
        panic!("`frink serve …` did not parse as the serve subcommand");
    };
    assert_eq!(args, ["-m", "model.gguf"]);
    assert!(super::SERVE_FEATURE_MISSING.contains("serve is on by default"));
}

#[test]
fn rewrites_llama_multi_character_short_options() {
    let args = ["frink", "-m", "model.gguf", "-dev", "none", "-ngl", "0"]
        .into_iter()
        .map(String::from)
        .collect();
    assert_eq!(
        rewrite_llama_style_argv(args).unwrap(),
        [
            "frink",
            "run",
            "-m",
            "model.gguf",
            "--device",
            "none",
            "--n-gpu-layers",
            "0"
        ]
    );
}

/// **`-st` is not `--no-cnv`.**
///
/// llama.cpp 0.4 dropped `--no-cnv` and offers `-st` /
/// `--single-turn`, and the two are easy to read as synonyms.
/// They are not: `-st` runs the CONVERSATION for one turn, with
/// the chat template applied, where `--no-cnv` skips the template
/// entirely.
///
/// An early version of that rewriter row mapped them together,
/// and it changed the answer -- measured on the same prompt and
/// the same file, the templated reply is "The capital of France
/// is Paris." and the raw one continues " Paris\nThe capital city
/// of France is...". Nothing would have caught that but reading
/// two outputs side by side, which is why it is a test now.
#[test]
fn single_turn_keeps_the_chat_template() {
    let out = rewrite(&["frink", "-m", "model.gguf", "-p", "hi", "-st"]);
    assert!(
        out.contains(&"--single-turn".to_string()),
        "-st must reach the single-turn flag: {out:?}"
    );
    assert!(
        !out.contains(&"--no-cnv".to_string()),
        "-st must NOT become --no-cnv: it keeps the chat template, \
         and mapping the two together changes the generated text: {out:?}"
    );
}

/// And the two flags stay distinct at the clap layer, so neither
/// is an alias of the other.
#[test]
fn single_turn_and_no_cnv_are_separate_flags() {
    use clap::CommandFactory;
    let run = crate::Cli::command();
    let run = run
        .get_subcommands()
        .find(|c| c.get_name() == "run")
        .expect("run subcommand");
    let names: Vec<&str> = run
        .get_arguments()
        .filter_map(|a| a.get_long())
        .filter(|l| *l == "no-cnv" || *l == "single-turn")
        .collect();
    assert_eq!(
        names.len(),
        2,
        "both flags must exist independently, found {names:?}"
    );
}

/// `-md` is llama.cpp's draft-model flag. Before the spellings were
/// derived from clap, clap read it as the cluster `-m d`: the MODEL
/// path silently became the letter `d`.
#[test]
fn md_is_the_draft_model_and_not_a_model_named_d() {
    let cli = parse_cli(rewrite(&["frink", "-m", "t.gguf", "-md", "d.gguf"]));
    let super::Commands::Run(args) = cli.command else {
        panic!("not run");
    };
    assert_eq!(args.model.as_deref(), Some("t.gguf"));
    assert_eq!(args.model_draft.as_deref(), Some("d.gguf"));
}

/// An unknown single-dash name is an error naming the token, not a
/// cluster of short options clap guesses at.
#[test]
fn an_unknown_single_dash_name_is_refused_by_the_rewriter() {
    let err = rewrite_llama_style_argv(
        ["frink", "-m", "t.gguf", "-zzz"]
            .into_iter()
            .map(String::from)
            .collect(),
    )
    .unwrap_err();
    assert!(err.contains("`-zzz`"), "{err}");
}

/// `frink-server -np 4` worked and `frink serve -np 4` did not: the two
/// front ends had separate rewrite tables and only the server's had
/// `-np`, `-cb` and `-b`. They read one set of spellings now.
#[cfg(feature = "serve")]
#[test]
fn serve_reads_the_same_single_dash_names_as_frink_server() {
    use clap::Parser;
    let cli = parse_cli(rewrite(&[
        "frink", "serve", "-np", "4", "-cb", "-b", "256", "-ub", "128", "-hf", "r", "-hff",
        "x.gguf",
    ]));
    let super::Commands::Serve(via_cli) = cli.command else {
        panic!("not serve");
    };
    let standalone = frink_server::ServerArgs::try_parse_from([
        "frink-server",
        "--parallel",
        "4",
        "--cont-batching",
        "--batch-size",
        "256",
        "--ubatch-size",
        "128",
        "--hf-repo",
        "r",
        "--hf-file",
        "x.gguf",
    ])
    .unwrap();
    assert_eq!(via_cli, standalone);
}

/// `--version` on a subcommand names the binary that exists (`frink`,
/// or `frink-server` for `serve`), not clap's `frink-run`; `--usage` is
/// help, as it is in llama.cpp, before and after the run rewrite.
///
/// Sabotage: drop the `display_name("frink")` loop in `built_cli`; the
/// `run` row prints `frink-run` and goes red.
#[test]
fn version_and_usage_work_on_every_front_end_spelling() {
    let mut cases = vec![
        (vec!["frink", "--version"], "frink "),
        (vec!["frink", "run", "--version"], "frink "),
    ];
    if cfg!(feature = "serve") {
        cases.push((vec!["frink", "serve", "--version"], "frink-server "));
    }
    for (argv, want) in cases {
        let argv: Vec<String> = argv.into_iter().map(String::from).collect();
        let err = crate::argv::parse(argv.clone())
            .err()
            .expect("--version must exit");
        assert_eq!(
            err.kind(),
            clap::error::ErrorKind::DisplayVersion,
            "{argv:?}"
        );
        assert!(err.to_string().starts_with(want), "{argv:?}: {err}");
    }
    for argv in [
        &["frink", "--usage"][..],
        &["frink", "run", "--usage"],
        &["frink", "-m", "x.gguf", "--usage"],
    ] {
        let err = crate::argv::parse(rewrite(argv))
            .err()
            .expect("--usage must exit");
        assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp, "{argv:?}");
    }
}

/// llama-bench's `--prio -1` is a negative number, not a flag, and the
/// rewriter and clap must both read it that way; `--no-warmup`,
/// `--delay` and `--progress` reach `BenchCmd` as themselves.
#[test]
fn bench_takes_llama_benchs_run_flags() {
    let cli = parse_cli(rewrite(&[
        "frink",
        "bench",
        "-m",
        "m.gguf",
        "--prio",
        "-1",
        "--no-warmup",
        "--delay",
        "5",
        "--progress",
    ]));
    let super::Commands::Bench(b) = cli.command else {
        panic!("not bench");
    };
    assert_eq!(
        (b.prio, b.no_warmup, b.delay, b.progress),
        (-1, true, 5, true)
    );
}

/// llama-bench's `-o json -oe md`: `-o` is clap's short flag and `-oe`
/// a two-letter single-dash spelling the argv rewriter must hand to
/// `--output-err`, not read as `-o e`.
#[test]
fn bench_takes_llama_benchs_output_flags() {
    let cli = parse_cli(rewrite(&[
        "frink", "bench", "-m", "m.gguf", "-o", "json", "-oe", "md",
    ]));
    let super::Commands::Bench(b) = cli.command else {
        panic!("not bench");
    };
    assert_eq!((b.output.as_str(), b.output_err.as_str()), ("json", "md"));
}

/// llama-bench's `-hf` / `-hff` / `-hft` and `-ctk` / `-ctv` reach
/// `BenchCmd` through the rewriter, and `-hf` conflicts with `-m` as it
/// does in `frink run`.
#[test]
fn bench_takes_llama_benchs_hub_and_cache_type_flags() {
    let cli = parse_cli(rewrite(&[
        "frink",
        "bench",
        "-hf",
        "org/repo:Q4_K_M",
        "-hff",
        "x.gguf",
        "-hft",
        "tok",
        "-ctk",
        "f32",
        "-ctv",
        "f32",
    ]));
    let super::Commands::Bench(b) = cli.command else {
        panic!("not bench");
    };
    assert_eq!(b.hf_repo.as_deref(), Some("org/repo:Q4_K_M"));
    assert_eq!(b.hf_file.as_deref(), Some("x.gguf"));
    assert_eq!(b.hf_token.as_deref(), Some("tok"));
    assert_eq!(b.cache_type_k.as_deref(), Some("f32"));
    assert_eq!(b.cache_type_v.as_deref(), Some("f32"));
    use clap::Parser;
    assert!(
        super::Cli::try_parse_from(rewrite(&["frink", "bench", "-m", "a", "-hf", "b/c"])).is_err()
    );
}

/// A V type other than K's, and llama-bench's sweep, are refused before
/// anything is downloaded or loaded.
#[test]
fn bench_refuses_a_split_kv_type_and_a_cache_type_sweep() {
    let mut b = match parse_cli(rewrite(&[
        "frink", "bench", "-m", "m.gguf", "-ctk", "f32", "-ctv", "f16",
    ]))
    .command
    {
        super::Commands::Bench(b) => b,
        _ => panic!("not bench"),
    };
    let err = b.apply_llama_flags().unwrap_err().to_string();
    assert!(err.contains("one type"), "{err}");
    let mut b = match parse_cli(rewrite(&[
        "frink", "bench", "-m", "m.gguf", "-ctk", "f16,q8_0",
    ]))
    .command
    {
        super::Commands::Bench(b) => b,
        _ => panic!("not bench"),
    };
    let err = b.apply_llama_flags().unwrap_err().to_string();
    assert!(err.contains("sweep"), "{err}");
}

/// llama.cpp's `--offline` reaches `run` and `bench` as itself.
#[test]
fn run_and_bench_take_llama_cpps_offline_switch() {
    let cli = parse_cli(rewrite(&[
        "frink",
        "run",
        "-hf",
        "org/repo:Q4_K_M",
        "--offline",
        "-p",
        "x",
    ]));
    let super::Commands::Run(r) = cli.command else {
        panic!("not run");
    };
    assert!(r.offline);
    let cli = parse_cli(rewrite(&["frink", "bench", "-hf", "org/repo", "--offline"]));
    let super::Commands::Bench(b) = cli.command else {
        panic!("not bench");
    };
    assert!(b.offline);
}

/// llama-bench's `-pg pp,tg` reaches `BenchCmd` through the rewriter as
/// one pair; a malformed or all-zero pair is refused at parse time.
#[test]
fn bench_takes_llama_benchs_pg_pair() {
    let cli = parse_cli(rewrite(&[
        "frink", "bench", "-m", "m.gguf", "-pg", "512,128",
    ]));
    let super::Commands::Bench(b) = cli.command else {
        panic!("not bench");
    };
    assert_eq!(b.pg, Some((512, 128)));
    use clap::Parser;
    for bad in ["512", "0,0", "a,1", "1,2,3"] {
        assert!(
            super::Cli::try_parse_from(rewrite(&["frink", "bench", "-m", "m", "-pg", bad]))
                .is_err(),
            "-pg {bad} parsed"
        );
    }
}

/// llama-bench's `-b` / `-ub` reach `BenchCmd` through the rewriter
/// (`-b` is a single letter, `-ub` two), and zero is refused.
#[test]
fn bench_takes_llama_benchs_batch_sizes() {
    let cli = parse_cli(rewrite(&[
        "frink", "bench", "-m", "m.gguf", "-b", "2048", "-ub", "512",
    ]));
    let super::Commands::Bench(b) = cli.command else {
        panic!("not bench");
    };
    assert_eq!((b.batch_size, b.ubatch_size), (Some(2048), Some(512)));
    use clap::Parser;
    assert!(
        super::Cli::try_parse_from(rewrite(&["frink", "bench", "-m", "m", "-ub", "0"])).is_err()
    );
}