tokitai-operator 0.1.0

Verified DL kernel compiler: formally-checked GEMM, p-adic, sheaf, contract-carrying ops. Paper-artifact grade.
Documentation
//! Quick-fix regression tests for the 3 bounded synth_data bugs.
//!
//! Bug 1: make_quality_decision_dataset(0, _) returns empty Vec (no panic).
//! Bug 2: numerical features are in [0, 1] (normalized to match real data).
//! Bug 3: outcome target has noise (empirical entropy > 1.5 nats).

#![cfg(feature = "rocm-hip")]

use tokitai_operator::synth_data::make_quality_decision_dataset;

const OUTCOME_DIMS: usize = 12;

#[test]
fn zero_samples_returns_empty() {
    let data = make_quality_decision_dataset(0, 42);
    assert_eq!(data.len(), 0);
}

#[test]
fn numerical_features_are_in_unit_range() {
    let data = make_quality_decision_dataset(16, 0xDEAD_BEEF_CAFE_F00Du64);
    assert_eq!(data.len(), 16);
    for (i, s) in data.iter().enumerate() {
        for (j, &v) in s.input.iter().enumerate() {
            assert!(
                (0.0..=1.0).contains(&v),
                "sample {} input[{}] = {} out of [0, 1]",
                i,
                j,
                v
            );
        }
    }
    if let Some(s) = data.first() {
        eprintln!(
            "[synth_data_quickfix] sample 0 num features (last 22): {:?}",
            &s.input[74..]
        );
    }
}

#[test]
fn outcome_target_has_label_noise() {
    let n = 1000;
    let data = make_quality_decision_dataset(n, 0xCAFE_F00D_BABE_0001u64);
    assert_eq!(data.len(), n);

    let mut counts = [0usize; OUTCOME_DIMS];
    for s in &data {
        let mut best = 0usize;
        let mut best_v = f32::NEG_INFINITY;
        for (k, &v) in s.target[..OUTCOME_DIMS].iter().enumerate() {
            if v > best_v {
                best_v = v;
                best = k;
            }
        }
        counts[best] += 1;
    }

    let mut h = 0.0f64;
    for &c in &counts {
        if c > 0 {
            let p = c as f64 / n as f64;
            h -= p * p.ln();
        }
    }
    eprintln!(
        "[synth_data_quickfix] outcome argmax distribution: {:?} (entropy = {:.3} nats, threshold > 1.5)",
        counts, h
    );
    assert!(
        h > 1.5,
        "outcome argmax distribution collapsed: counts={:?} entropy={:.3}",
        counts,
        h
    );
}