From 35e85dbc67a839b498577b58e5ca299880cd1ac3 Mon Sep 17 00:00:00 2001 From: dylanyunlon Date: Fri, 7 Aug 2026 06:36:12 +0000 Subject: [PATCH] =?UTF-8?q?fix(verify):=20remove=20duplicate=20TC-22~30=20?= =?UTF-8?q?test=20definitions=20=E2=80=94=20CCCL=20test=5Fthen.cu=20audit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CCCL cudax/test/execution/test_then.cu teaches: each test case defined exactly once, each section independent, error signals don't silently pass. verify_functional.py had 9 functions defined twice. Python silently overwrites the first definition with the second. The second ALL_TESTS.extend also added duplicate entries causing tests to run twice. Removed the entire duplicate block. All 51 TCs now have exactly one definition and one registration in ALL_TESTS. --- qwen3_6_scripts/verify_functional.py | 141 +-------------------------- 1 file changed, 4 insertions(+), 137 deletions(-) diff --git a/qwen3_6_scripts/verify_functional.py b/qwen3_6_scripts/verify_functional.py index 71c08219..c9503b46 100644 --- a/qwen3_6_scripts/verify_functional.py +++ b/qwen3_6_scripts/verify_functional.py @@ -1076,141 +1076,8 @@ ALL_TESTS.extend([ # ================================================================ -# Tests TC-22 through TC-30: CCCL dispatch_segmented_reduce.cuh inspired -# Segmented reduce has 3 policy tiers: Large/Medium/Small segment. -# We test V1/V2 attention at analogous tier boundaries. +# NOTE: Duplicate TC-22~30 block removed (commit by CCCL test_then.cu audit). +# Each test function is now defined exactly once above. +# CCCL design rule: one definition per test, no silent overwrite. +# The first ALL_TESTS.extend (TC-14~51) already covers all 51 test cases. # ================================================================ - -def test_chinese_exact_repeat(endpoint: str) -> Tuple[bool, str]: - """TC-22: Chinese exact repeat (Unicode encoding fidelity).""" - target = "信创模盒ModelHub开源未来" - code, data = chat_completion(endpoint, [ - {"role": "system", "content": "你是一个复读机,请精确重复用户的输入,不要添加任何内容"}, - {"role": "user", "content": target} - ], max_tokens=50, temperature=0.0) - if code != 200: - return False, f"HTTP {code}" - content = data["choices"][0]["message"]["content"] - if target not in content: - return False, f"Exact repeat failed: '{content[:60]}'" - return True, f"OK: exact repeat verified" - - -def test_japanese_exact_repeat(endpoint: str) -> Tuple[bool, str]: - """TC-23: Japanese exact repeat.""" - target = "東京タワーは日本の象徴です" - code, data = chat_completion(endpoint, [ - {"role": "system", "content": "你是一个复读机,请精确重复用户的输入,不要添加任何内容"}, - {"role": "user", "content": target} - ], max_tokens=50, temperature=0.0) - if code != 200: - return False, f"HTTP {code}" - content = data["choices"][0]["message"]["content"] - if target not in content: - return False, f"Japanese repeat failed: '{content[:60]}'" - return True, f"OK: Japanese repeat verified" - - -def test_n_parameter(endpoint: str) -> Tuple[bool, str]: - """TC-24: n=2 returns 2 choices. - CCCL parallel: dispatch_segmented_reduce.cuh — each segment produces - one output. n=2 means 2 independent sampling runs = 2 segments. - """ - code, data = chat_completion(endpoint, [ - {"role": "user", "content": "hi"} - ], max_tokens=10, n=2, temperature=0.7) - if code != 200: - return False, f"HTTP {code}: {data}" - num_choices = len(data.get("choices", [])) - if num_choices != 2: - return False, f"Expected 2 choices, got {num_choices}" - return True, f"OK: {num_choices} choices returned" - - -def test_empty_body_error(endpoint: str) -> Tuple[bool, str]: - """TC-25: Empty JSON body returns 4xx.""" - url = f"{endpoint}/v1/chat/completions" - resp = requests.post(url, json={}, timeout=30) - if resp.status_code < 400: - return False, f"Expected 4xx, got {resp.status_code}" - return True, f"OK: HTTP {resp.status_code} for empty body" - - -def test_missing_role_error(endpoint: str) -> Tuple[bool, str]: - """TC-26: Message missing role returns 4xx.""" - url = f"{endpoint}/v1/chat/completions" - resp = requests.post(url, json={ - "model": "llm", - "messages": [{"content": "hello"}] - }, timeout=30) - if resp.status_code < 400: - return False, f"Expected 4xx, got {resp.status_code}" - return True, f"OK: HTTP {resp.status_code} for missing role" - - -def test_top_k_boundary(endpoint: str) -> Tuple[bool, str]: - """TC-27: top_k=1 (greedy-like via sampling) works. - CCCL: dispatch_topk.cuh k=1 → DeviceReduceArgMax fast path. - """ - code, data = chat_completion(endpoint, [ - {"role": "user", "content": "hi"} - ], max_tokens=10, extra_body={"top_k": 1}, temperature=0.7) - if code != 200: - # top_k may not be supported as extra_body, try without - code, data = chat_completion(endpoint, [ - {"role": "user", "content": "hi"} - ], max_tokens=10, temperature=0.01) - if code != 200: - return False, f"HTTP {code}" - return True, "OK: extreme low-temperature/top-k sampling works" - - -def test_temperature_2(endpoint: str) -> Tuple[bool, str]: - """TC-28: temperature=2.0 (high randomness) works. - CCCL: scale_mem_bound upper clamp = nominal*2 — tests boundary. - """ - code, data = chat_completion(endpoint, [ - {"role": "user", "content": "hi"} - ], max_tokens=10, temperature=2.0) - if code != 200: - return False, f"HTTP {code}: {data}" - content = data["choices"][0]["message"]["content"] - return True, f"OK: high-temp output '{content[:30]}'" - - -def test_models_endpoint(endpoint: str) -> Tuple[bool, str]: - """TC-29: /v1/models returns model list with 'llm'.""" - url = f"{endpoint}/v1/models" - resp = requests.get(url, timeout=30) - if resp.status_code != 200: - return False, f"HTTP {resp.status_code}" - data = resp.json() - model_ids = [m.get("id") for m in data.get("data", [])] - if "llm" not in model_ids: - return False, f"'llm' not in models: {model_ids}" - return True, f"OK: models={model_ids}" - - -def test_health_endpoint(endpoint: str) -> Tuple[bool, str]: - """TC-30: /health returns 200.""" - try: - resp = requests.get(f"{endpoint}/health", timeout=10) - if resp.status_code != 200: - return False, f"HTTP {resp.status_code}" - return True, "OK: health check passed" - except requests.ConnectionError: - return False, "Connection refused" - - -# Extend ALL_TESTS -ALL_TESTS.extend([ - ("TC-22 Chinese exact repeat", test_chinese_exact_repeat), - ("TC-23 Japanese exact repeat", test_japanese_exact_repeat), - ("TC-24 n=2 multiple choices", test_n_parameter), - ("TC-25 Empty body error", test_empty_body_error), - ("TC-26 Missing role error", test_missing_role_error), - ("TC-27 Top-k boundary", test_top_k_boundary), - ("TC-28 Temperature 2.0", test_temperature_2), - ("TC-29 /v1/models endpoint", test_models_endpoint), - ("TC-30 /health endpoint", test_health_endpoint), -])