{
  "$schema": "http://json-schema.org/draft-07/schema",
  "title": "AccelMark Result",
  "type": "object",
  "required": [
    "schema_version", "suite_id", "chip", "software",
    "model", "task", "metrics", "accuracy", "meta"
  ],
  "additionalProperties": false,
  "properties": {

    "schema_version": { "type": "string", "const": "1.0" },

    "suite_id": {
      "type": "string",
      "description": "Suite identifier. Standard suites: suite_A through suite_G. Mini suites: mini-nano, mini-mini, mini-standard, mini-pro. Custom: 'custom'."
    },

    "implementation_id": {
      "type": ["string", "null"],
      "description": "ID of the runner used to produce this result. Matches a folder name in runners/. Null or absent for results submitted before this feature was introduced.",
      "pattern": "^[a-z][a-z0-9]*_[a-z][a-z0-9_]*_[0-9a-f]{8}$"
    },

    "environment": {
        "type": ["object", "null"],
        "description": "Full hardware/software environment snapshot from collect_env.py"
    },

    "chip": {
      "type": "object",
      "required": ["name", "vendor", "count", "memory_gb", "interconnect_intra_node"],
      "additionalProperties": true,
      "properties": {
        "name": { "type": "string" },
        "vendor": {
          "type": "string",
          "enum": ["NVIDIA","AMD","Intel","Google","Huawei","Cambricon","Biren",
                   "Enflame","MetaX","Moore Threads","Iluvatar","Apple","Qualcomm","Other"]
        },
        "count": { "type": "integer", "minimum": 1 },
        "memory_gb": { "type": "number", "minimum": 0 },
        "interconnect_intra_node": { "type": ["string", "null"] },
        "interconnect_inter_node": { "type": ["string", "null"] },
        "_count_note": {
          "type": ["string", "null"],
          "description": "Human-readable note about the chip count field. Only present for Suite E."
        }
      }
    },

    "software": {
      "type": "object",
      "required": ["framework","framework_version","driver_version","runtime_version","os","python_version"],
      "additionalProperties": true,
      "properties": {
        "framework": { "type": "string" },
        "framework_version": { "type": "string" },
        "driver_version": { "type": "string" },
        "runtime_version": { "type": "string" },
        "os": { "type": "string" },
        "python_version": { "type": "string" }
      }
    },

    "model": {
      "type": "object",
      "required": ["model_id","model_revision","architecture","parameter_count_b","precision","model_format"],
      "additionalProperties": true,
      "properties": {
        "model_id": { "type": "string" },
        "model_revision": { "type": "string" },
        "architecture": {
          "type": ["string", "null"],
          "enum": ["dense", "moe", null],
          "description": "Model architecture family. 'dense' for standard transformer, 'moe' for mixture-of-experts models."
        },
        "parameter_count_b": { "type": "number", "minimum": 0 },
        "precision": {
          "type": "string",
          "description": "Effective compute precision used during this run. BF16 is standard; FP16 is used on hardware that does not support BF16 (e.g. V100, T4).",
          "enum": ["FP32","BF16","FP16","FP8","W8A8","W8A16","W4A16","INT8","INT4","mixed"]
        },
        "effective_dtype": {
          "type": ["string", "null"],
          "description": "Actual compute dtype used by the framework during inference. May differ from 'precision' — e.g. FP8 weights computed in bfloat16 on hardware without native FP8 tensor cores. Uses PyTorch dtype naming: 'bfloat16', 'float16', 'float32', 'float8_e4m3fn', 'int8'."
        },
        "quantization_method": {
          "type": ["string", "null"],
          "description": "Weight quantization method used. Describes how weights are stored in memory: 'fp8', 'awq', 'gptq', 'w8a8', 'w8a16', 'bitsandbytes', or null for full-precision runs."
        },
        "model_format": {
          "type": ["string", "null"],
          "description": "Weight file format used by the runner. 'HuggingFace original' for standard .safetensors/.bin weights. Other values: 'TensorRT engine', 'MindIR', 'MLX', 'GGUF', 'ONNX'."
        },
        "model_source": {
          "type": ["string", "null"],
          "enum": ["huggingface", "local", null],
          "description": "Whether the canonical HuggingFace weights were used directly, or a local path override from models_local.yaml was applied."
        },
        "model_name": {
          "type": ["string", "null"],
          "description": "Actual model identifier used if different from model_id. Null means the canonical model_id weights were used. Set via model_name in models_local.yaml when substituting a different model variant."
        },
        "model_note": {
          "type": ["string", "null"],
          "description": "Free-text note from contributor explaining model substitution or local variant. Set via 'note' field in models_local.yaml."
        },
        "_note": {
          "type": ["string", "null"],
          "description": "Human-readable note about the model field. Only present for Suite C."
        }
      }
    },

    "task": {
      "type": "object",
      "required": ["num_runs"],
      "additionalProperties": false,
      "oneOf": [
        {"required": ["scenario"]},
        {"required": ["scenarios_run"]}
      ],
      "properties": {
        "scenario": {
          "type": "string",
          "enum": ["offline","online","interactive","multiturn","sustained","speculative","burst","all"],
          "description": "Single scenario run. Required for single-scenario submissions."
        },
        "scenarios_run": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["offline","online","interactive","multiturn","sustained","accuracy","speculative","burst"]
          },
          "description": "List of scenarios run. Used for suite-level submissions (--scenario all)."
        },
        "chip_counts_run": {
          "type": "array",
          "items": {"type": "integer"},
          "description": "Chip counts tested. Only present for Suite E submissions."
        },
        "precision_levels_run": {
          "type": "array",
          "items": {"type": "string"},
          "description": "Precision levels tested. Only present for Suite C submissions."
        },
        "precision_levels_skipped": {
          "type": "array",
          "items": {"type": "string"},
          "description": "Precision levels skipped (e.g. not supported). Only present for Suite C submissions."
        },
        "parallelism_note": {
          "type": ["string", "null"],
          "description": "Human-readable note about parallelism strategy. Only present for Suite E submissions."
        },
        "num_runs": { "type": "integer", "minimum": 1 },
        "warmup_runs": {
          "type": "integer",
          "minimum": 0,
          "description": "Number of warmup runs. Optional for suite-level submissions."
        },
        "parallelism": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "tensor_parallel_size": { "type": ["integer","null"] },
            "pipeline_parallel_size": { "type": ["integer","null"] },
            "data_parallel_size": { "type": ["integer","null"] },
            "expert_parallel_size": { "type": ["integer","null"] }
          }
        },
        "extra_config": { "type": ["object","null"] },
        "runtime_metrics": {
          "type": ["object", "null"],
          "description": "Framework-specific runtime metrics collected during inference. Keys are scenario-dependent and optional. See get_runtime_metrics() in benchmark_runner.py.",
          "additionalProperties": true
        }
      }
    },

    "metrics": {
      "type": "object",
      "properties": {
        "offline": {
          "type": ["object","null"],
          "required": ["results_by_concurrency"],
          "properties": {
            "results_by_concurrency": {
              "type": "array",
              "description": "Offline throughput results at each client concurrency level.",
              "items": {
                "type": "object",
                "required": ["client_concurrency", "oom"],
                "additionalProperties": true,
                "properties": {
                  "client_concurrency": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Number of requests sent simultaneously. The inference engine handles internal batching automatically."
                  },
                  "throughput_tokens_per_sec": {
                    "type": ["number","null"],
                    "minimum": 0,
                    "description": "Total tokens per second including both input (prompt) and output tokens. Matches vLLM internal throughput metric."
                  },
                  "throughput_tokens_per_sec_per_chip": { "type": ["number","null"], "minimum": 0 },
                  "throughput_tokens_per_sec_total": {
                    "type": ["number","null"],
                    "minimum": 0,
                    "description": "Throughput in tokens/sec counting both input and output tokens. Useful for cost modeling and MFU estimation. Null for results produced before this field was added."
                  },
                  "elapsed_seconds_median": {
                    "type": ["number","null"],
                    "description": "Median wall-clock time in seconds for one complete run at this client concurrency level."
                  },
                  "peak_memory_gb": { "type": ["number","null"], "minimum": 0 },
                  "power_watts_avg": { "type": ["number","null"] },
                  "power_watts_peak": { "type": ["number","null"] },
                  "oom": { "type": "boolean", "default": false },
                  "_concurrency_note": { "type": ["string","null"] }
                }
              }
            }
          }
        },
        "online": {
          "type": ["object","null"],
          "required": ["max_valid_qps","results_by_qps"],
          "properties": {
            "max_valid_qps": { "type": "number", "minimum": 0 },
            "results_by_qps": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "target_qps","achieved_qps",
                  "ttft_ms_p50","ttft_ms_p90","ttft_ms_p99",
                  "tpot_ms_p50","tpot_ms_p90","tpot_ms_p99",
                  "sla_met"
                ],
                "additionalProperties": true,
                "properties": {
                  "target_qps": { "type": "number" },
                  "achieved_qps": { "type": ["number","null"] },
                  "ttft_ms_p50": { "type": "number" },
                  "ttft_ms_p90": { "type": "number" },
                  "ttft_ms_p99": { "type": "number" },
                  "tpot_ms_p50": { "type": "number" },
                  "tpot_ms_p90": { "type": "number" },
                  "tpot_ms_p99": { "type": "number" },
                  "elapsed_seconds_median": {
                    "type": ["number","null"],
                    "description": "Median wall-clock time in seconds for one complete run at this QPS level."
                  },
                  "sla_met": { "type": "boolean" }
                }
              }
            }
          }
        },
        "interactive": {
          "type": ["object","null"],
          "required": [
            "ttft_ms_p50","ttft_ms_p90","ttft_ms_p99",
            "tpot_ms_p50","tpot_ms_p90","tpot_ms_p99"
          ],
          "additionalProperties": true,
          "properties": {
            "ttft_ms_p50": { "type": "number" },
            "ttft_ms_p90": { "type": "number" },
            "ttft_ms_p99": { "type": "number" },
            "tpot_ms_p50": { "type": "number" },
            "tpot_ms_p90": { "type": "number" },
            "tpot_ms_p99": { "type": "number" },
            "peak_memory_gb": {
              "type": ["number","null"],
              "description": "Peak GPU memory in GB. Null if not measured."
            },
            "elapsed_seconds_median": {
              "type": ["number","null"],
              "description": "Median wall-clock time in seconds for one complete interactive run."
            }
          }
        },
        "training": {
          "type": ["object","null"],
          "required": ["tokens_per_sec","tokens_per_sec_per_chip","peak_memory_gb_per_chip"],
          "additionalProperties": true,
          "properties": {
            "tokens_per_sec": { "type": "number" },
            "tokens_per_sec_per_chip": { "type": "number" },
            "peak_memory_gb_per_chip": { "type": "number" },
            "power_watts_avg_per_chip": { "type": ["number","null"] },
            "mfu": { "type": ["number","null"], "minimum": 0, "maximum": 1 }
          }
        },
        "derived": {
          "type": "object",
          "description": "Auto-computed by validate_submission.py. Do not fill manually.",
          "additionalProperties": true,
          "properties": {
            "tokens_per_sec_per_watt": { "type": ["number","null"] },
            "tokens_per_sec_per_chip": { "type": ["number","null"] }
          }
        },
        "scaling": {
          "type": "object",
          "description": "Suite E scaling efficiency metrics",
          "properties": {
            "base_throughput_1x": {
              "type": ["number", "null"],
              "description": "Best throughput at 1x chip count (tok/s). Used as denominator for scaling efficiency."
            },
            "results_by_chip_count": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": true,
                "properties": {
                  "chip_count": {"type": "integer"},
                  "best_throughput_tokens_per_sec": {"type": ["number", "null"]},
                  "throughput_tokens_per_sec_per_chip": {"type": ["number", "null"]},
                  "scaling_efficiency": {
                    "type": ["number", "null"],
                    "description": "N-chip throughput / (1-chip throughput × N). 1.0 = perfect linear scaling."
                  },
                  "results_by_concurrency": {"type": "array"},
                  "result_dir": {"type": "string"}
                }
              }
            }
          }
        },
        "quantization": {
          "type": "object",
          "description": "Suite C quantization efficiency metrics",
          "properties": {
            "results_by_precision": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "additionalProperties": true,
                  "precision": {
                    "type": "string",
                    "enum": ["BF16", "FP16", "FP8", "W8A8", "W8A16", "W4A16", "INT8", "INT4"]
                  },
                  "model_id": {
                    "type": ["string", "null"],
                    "description": "Model checkpoint used for this precision level."
                  },
                  "best_throughput_tokens_per_sec": {
                    "type": ["number", "null"]
                  },
                  "accuracy_score": {
                    "type": ["number", "null"]
                  },
                  "accuracy_baseline_delta": {
                    "type": ["number", "null"],
                    "description": "accuracy_score minus the baseline score for this format."
                  },
                  "accuracy_valid": {
                    "type": ["boolean", "null"],
                    "description": "True if accuracy is within threshold of baseline. Null if baseline not set."
                  },
                  "quality_efficiency": {
                    "type": ["number", "null"],
                    "description": "throughput × accuracy_score. Higher = better speed/quality tradeoff."
                  },
                  "speedup_vs_bf16": {
                    "type": ["number", "null"],
                    "description": "Throughput ratio vs BF16 baseline. 1.5 = 50% faster than BF16."
                  },
                  "effective_dtype": {
                    "type": ["string", "null"],
                    "description": "Actual compute dtype used by the framework for this precision level."
                  },
                  "quantization_method": {
                    "type": ["string", "null"],
                    "description": "Weight quantization method used for this precision level."
                  },
                  "results_by_concurrency": {"type": "array"},
                  "result_dir": {"type": "string"}
                }
              }
            }
          }
        },
        "sustained": {
          "type": ["object", "null"],
          "description": "Time-based sustained load test metrics",
          "properties": {
            "sustained_concurrency":  {
              "type": ["integer", "null"],
              "description": "Number of requests kept in-flight simultaneously throughout the sustained run."
            },
            "duration_minutes":       { "type": ["number", "null"] },
            "sample_interval_seconds":{ "type": ["number", "null"] },
            "warmup_minutes":         { "type": ["number", "null"] },
            "sustained_throughput_tokens_per_sec": { "type": ["number", "null"] },
            "throttle_ratio":         { "type": ["number", "null"] },
            "throttle_onset_minute":  { "type": ["number", "null"] },
            "ttft_p99_drift_ms":      { "type": ["number", "null"] },
            "samples": {
              "type": ["array", "null"],
              "items": {
                "type": "object",
                "additionalProperties": true,
                "properties": {
                  "minute":                      { "type": ["number", "null"] },
                  "is_warmup":                   { "type": ["boolean", "null"] },
                  "throughput_tokens_per_sec":   { "type": ["number", "null"] },
                  "tokens_out":                  { "type": ["integer", "null"] },
                  "tokens_in":                   { "type": ["integer", "null"] },
                  "requests_completed":          { "type": ["integer", "null"] },
                  "ttft_ms_p50":                 { "type": ["number", "null"] },
                  "ttft_ms_p99":                 { "type": ["number", "null"] }
                }
              }
            }
          }
        },
        "burst": {
          "type": ["object", "null"],
          "description": "Two-state bursty load test metrics",
          "properties": {
            "sla_ttft_ms":                  { "type": ["number", "null"] },
            "burst_steady_qps":             { "type": ["number", "null"] },
            "burst_peak_qps":               { "type": ["number", "null"] },
            "burst_duration_seconds":       { "type": ["number", "null"] },
            "burst_interval_seconds":       { "type": ["number", "null"] },
            "steady_ttft_p50_ms":           { "type": ["number", "null"] },
            "steady_ttft_p99_ms":           { "type": ["number", "null"] },
            "burst_ttft_p50_ms":            { "type": ["number", "null"] },
            "burst_ttft_p99_ms":            { "type": ["number", "null"] },
            "steady_requests_total":        { "type": ["integer", "null"] },
            "burst_requests_total":         { "type": ["integer", "null"] },
            "sla_met_during_burst":         { "type": ["boolean", "null"] },
            "burst_degradation_ratio":      { "type": ["number", "null"] },
            "results_by_cycle":             { "type": ["array", "null"] }
          }
        }
      }
    },

    "accuracy": {
      "description": "Top-level accuracy summary. Null for Suite C (per-format accuracy is in metrics.quantization.results_by_precision).",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "required": ["subset_score","baseline_delta","valid"],
          "additionalProperties": true,
          "properties": {
            "subset_score": { "type": ["number","null"], "minimum": 0, "maximum": 1 },
            "baseline_delta": { "type": ["number","null"] },
            "valid": { "type": "boolean" },
            "framework": {
              "type": ["string","null"],
              "description": "Framework used for accuracy check."
            },
            "precision": {
              "type": ["string","null"],
              "description": "Precision used for accuracy check."
            },
            "notes": { "type": ["string","null"] }
          }
        }
      ]
    },

    "meta": {
      "type": "object",
      "required": ["submitted_by","submission_type","date","reproduce_script","env_info_file","log_file"],
      "additionalProperties": true,
      "properties": {
        "submitted_by": { "type": "string" },
        "submission_type": { "type": "string", "enum": ["individual","vendor","research"] },
        "date": { "type": "string", "format": "date" },
        "time": {
          "type": ["string", "null"],
          "description": "Benchmark start time HH:MM:SS"
        },
        "run_id": {
          "type": ["string", "null"],
          "pattern": "^[0-9a-f]{8}$",
          "description": "8-char hex hash of hardware+software+suite+submitter config. Deterministic."
        },
        "run_name": {
          "type": ["string", "null"],
          "description": "Directory name: {chip}x{count}_{suite_id}_{runner_id}_{run_id}"
        },
        "flagged": {
          "type": ["string", "null"],
          "description": "Null for valid results. Maintainer sets to reason string if result is suspicious."
        },
        "reproduce_script": { "type": "string" },
        "env_info_file": { "type": "string" },
        "log_file": { "type": ["string","null"] },
        "samples_file": { "type": ["string","null"] },
        "notes": { "type": ["string","null"] },
        "benchmark_start_time": {
          "type": ["string","null"],
          "description": "ISO 8601 timestamp when benchmark started (after model load)."
        },
        "benchmark_end_time": {
          "type": ["string","null"],
          "description": "ISO 8601 timestamp when benchmark completed."
        },
        "benchmark_elapsed_minutes": {
          "type": ["number","null"],
          "description": "Total benchmark duration in minutes, excluding model load time."
        },
        "model_load_seconds": {
          "type": ["number","null"],
          "description": "Time in seconds to load model weights into GPU memory."
        },
        "scenario_dirs": {
          "type": ["object","null"],
          "description": "Paths to individual scenario output directories. Only present for suite-level submissions.",
          "additionalProperties": {"type": "string"}
        },
        "benchmark_elapsed_minutes_note": {
          "type": ["string","null"]
        },
        "chip_count_dirs": {
          "type": ["object","null"],
          "description": "Paths to per-chip-count output directories. Only present for Suite E submissions.",
          "additionalProperties": {"type": "string"}
        },
        "precision_dirs": {
          "type": ["object","null"],
          "description": "Paths to per-precision output directories. Only present for Suite C submissions.",
          "additionalProperties": {"type": "string"}
        },
        "precision_model_map": {
          "type": ["object","null"],
          "description": "Map of precision level to checkpoint info. Only present for Suite C submissions.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "model_id":       { "type": "string" },
              "model_revision": { "type": ["string","null"] }
            }
          }
        }
      }
    }

  }
}
