Skip to content

Commit df6dbc8

Browse files
committed
recapitalize
1 parent c65b6a8 commit df6dbc8

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

tests/nki/test_nki_beta2.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def test_tensor_copy_gpsimd_rejects_psum_tiles(patched_scope, src_buffer, dst_bu
445445
del patched_scope
446446
src = _nd(np.arange(8, dtype=np.float32).reshape(2, 4), buffer=src_buffer)
447447
dst = b2.NDArray(shape=src.shape, dtype=nl.float32, buffer=dst_buffer)
448-
with pytest.raises(ValueError, match="GpSimd|gpsimd|PSUM|psum"):
448+
with pytest.raises(ValueError, match="GpSimd tensor_copy cannot access PSUM"):
449449
nisa.tensor_copy(dst, src, engine=nisa.gpsimd_engine)
450450

451451

@@ -457,7 +457,10 @@ def test_tensor_copy_scalar_engine_requires_nc_v3_or_newer(patched_scope):
457457
try:
458458
src = _nd(np.arange(8, dtype=np.float32).reshape(2, 4), buffer="sbuf")
459459
dst = b2.NDArray(shape=src.shape, dtype=nl.float32, buffer="sbuf")
460-
with pytest.raises(ValueError, match="Scalar|scalar|v2|gen2"):
460+
with pytest.raises(
461+
ValueError,
462+
match="Scalar Engine tensor_copy is unsupported on NeuronCore-v2",
463+
):
461464
nisa.tensor_copy(dst, src, engine=nisa.scalar_engine)
462465
finally:
463466
b2.nki_builder.nc_version = prev
@@ -548,16 +551,16 @@ def test_nc_matmul_requires_psum_dst_and_sbuf_inputs(patched_scope):
548551
stationary = _nd(np.arange(12, dtype=float).reshape(4, 3), buffer="sbuf")
549552
moving = _nd(np.arange(8, dtype=float).reshape(4, 2), buffer="sbuf")
550553
bad_dst = _zeros((3, 2), buffer="sbuf")
551-
with pytest.raises(ValueError, match="nc_matmul requires dst in psum"):
554+
with pytest.raises(ValueError, match="nc_matmul requires dst in PSUM"):
552555
nisa.nc_matmul(bad_dst, stationary, moving)
553556

554557
dst = _zeros((3, 2), buffer="psum")
555558
bad_stationary = _nd(np.arange(12, dtype=float).reshape(4, 3), buffer="hbm")
556-
with pytest.raises(ValueError, match="nc_matmul requires stationary in sbuf"):
559+
with pytest.raises(ValueError, match="nc_matmul requires stationary in SBUF"):
557560
nisa.nc_matmul(dst, bad_stationary, moving)
558561

559562
bad_moving = _nd(np.arange(8, dtype=float).reshape(4, 2), buffer="hbm")
560-
with pytest.raises(ValueError, match="nc_matmul requires moving in sbuf"):
563+
with pytest.raises(ValueError, match="nc_matmul requires moving in SBUF"):
561564
nisa.nc_matmul(dst, stationary, bad_moving)
562565

563566

@@ -618,7 +621,7 @@ def test_nc_transpose_rejects_documented_engine_buffer_failures(
618621
del patched_scope
619622
src = _typed_ndarray((4, 3), "float32", buffer=src_buffer)
620623
dst = b2.NDArray(shape=(3, 4), dtype=nl.float32, buffer=dst_buffer)
621-
with pytest.raises(ValueError, match="buffer|engine|sbuf|psum|hbm"):
624+
with pytest.raises(ValueError, match="buffer|Engine|SBUF|PSUM|HBM"):
622625
nisa.nc_transpose(dst, src, engine=engine)
623626

624627

@@ -813,7 +816,7 @@ def test_tensor_tensor_rejects_documented_gpsimd_psum_case(patched_scope):
813816
lhs = _typed_ndarray((2, 4), "float32", buffer="psum")
814817
rhs = _typed_ndarray((2, 4), "float32", buffer="sbuf", seed=1)
815818
dst = b2.NDArray(shape=(2, 4), dtype=nl.float32, buffer="sbuf")
816-
with pytest.raises(ValueError, match="GpSimd|gpsimd|PSUM|psum"):
819+
with pytest.raises(ValueError, match="GpSimd|PSUM"):
817820
nisa.tensor_tensor(dst, lhs, rhs, nl.power, engine=nisa.gpsimd_engine)
818821

819822

@@ -823,7 +826,7 @@ def test_tensor_tensor_rejects_documented_psum_power_dst(patched_scope):
823826
lhs = _typed_ndarray((2, 4), "float32", buffer="sbuf")
824827
rhs = _typed_ndarray((2, 4), "float32", buffer="sbuf", seed=1)
825828
dst = b2.NDArray(shape=(2, 4), dtype=nl.float32, buffer="psum")
826-
with pytest.raises(ValueError, match="GpSimd|gpsimd|PSUM|psum|power"):
829+
with pytest.raises(ValueError, match="GpSimd|PSUM|power"):
827830
nisa.tensor_tensor(dst, lhs, rhs, nl.power, engine=nisa.gpsimd_engine)
828831

829832

@@ -1009,7 +1012,9 @@ def test_tensor_scalar_rejects_documented_engine_failures(patched_scope, op0, en
10091012
del patched_scope
10101013
data = _typed_ndarray((2, 4), "float32", buffer="sbuf")
10111014
dst = b2.NDArray(shape=(2, 4), dtype=nl.float32, buffer="sbuf")
1012-
with pytest.raises(ValueError, match="vector|scalar|GpSimd|gpsimd|bitvec|rsqrt"):
1015+
with pytest.raises(
1016+
ValueError, match="Vector Engine|Scalar Engine|GpSimd|bitvec|rsqrt"
1017+
):
10131018
nisa.tensor_scalar(
10141019
dst, data, getattr(nl, op0), 1.0, engine=getattr(nisa, engine)
10151020
)
@@ -1463,7 +1468,7 @@ def test_dma_copy_buffer_dtype_rmw_matrix(patched_scope):
14631468
)
14641469
_assert_tensor_equal(dst.data, expected_rmw)
14651470

1466-
with pytest.raises(ValueError, match="dma_copy only supports hbm/sbuf"):
1471+
with pytest.raises(ValueError, match="dma_copy only supports HBM/SBUF"):
14671472
nisa.dma_copy(
14681473
b2.NDArray(shape=(4, 4), dtype=_dtype_token("float32"), buffer="sbuf"),
14691474
b2.NDArray(shape=(4, 4), dtype=_dtype_token("float32"), buffer="psum"),

triton_viz/core/nki_beta2.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ def nc_transpose(dst, data, engine=nisa.engine.unknown, name=None):
378378
dst_buffer = _buffer_name(dst)
379379
if engine == nisa.vector_engine:
380380
if src_buffer not in ("sbuf", "psum") or dst_buffer not in ("sbuf", "psum"):
381-
raise ValueError("vector engine nc_transpose only supports sbuf/psum")
381+
raise ValueError("Vector Engine nc_transpose only supports SBUF/PSUM")
382382
elif engine == nisa.tensor_engine:
383383
if src_buffer != "sbuf" or dst_buffer != "psum":
384-
raise ValueError("tensor engine nc_transpose requires sbuf -> psum")
384+
raise ValueError("Tensor Engine nc_transpose requires SBUF -> PSUM")
385385
data_dtype = getattr(data, "dtype", np.asarray(_tensor_value(data)).dtype)
386386
dst_dtype = getattr(dst, "dtype", dst.data.dtype)
387387
if _dtype_str(dst_dtype) != _dtype_str(data_dtype) and not (
@@ -414,11 +414,11 @@ def nc_matmul(
414414
name,
415415
)
416416
if getattr(dst, "buffer", None) != "psum":
417-
raise ValueError("nc_matmul requires dst in psum")
417+
raise ValueError("nc_matmul requires dst in PSUM")
418418
if getattr(stationary, "buffer", None) != "sbuf":
419-
raise ValueError("nc_matmul requires stationary in sbuf")
419+
raise ValueError("nc_matmul requires stationary in SBUF")
420420
if getattr(moving, "buffer", None) != "sbuf":
421-
raise ValueError("nc_matmul requires moving in sbuf")
421+
raise ValueError("nc_matmul requires moving in SBUF")
422422
stationary_value = np.asarray(_tensor_value(stationary))
423423
moving_value = np.asarray(_tensor_value(moving))
424424
if stationary_value.shape[0] != moving_value.shape[0]:
@@ -599,7 +599,7 @@ def dma_copy(
599599
dst_buffer = dst.buffer or "sbuf"
600600
src_buffer = src.buffer or "sbuf"
601601
if dst_buffer not in ("hbm", "sbuf") or src_buffer not in ("hbm", "sbuf"):
602-
raise ValueError("dma_copy only supports hbm/sbuf source and destination")
602+
raise ValueError("dma_copy only supports HBM/SBUF source and destination")
603603
src_value = np.asarray(_tensor_value(src))
604604
if isinstance(dst, NDArray) and isinstance(src, NDArray):
605605
if dst.data.size != src.data.size:
@@ -628,9 +628,9 @@ def tensor_copy(dst, src, engine=nisa.engine.unknown, name=None):
628628
current_nc = getattr(nki_builder.nc_version, "value", nki_builder.nc_version)
629629
gen2 = getattr(nisa.nc_version.gen2, "value", nisa.nc_version.gen2)
630630
if engine == nisa.scalar_engine and current_nc <= gen2:
631-
raise ValueError("scalar engine tensor_copy is unsupported on nc-v2")
631+
raise ValueError("Scalar Engine tensor_copy is unsupported on NeuronCore-v2")
632632
if engine == nisa.gpsimd_engine and "psum" in (dst_buffer, src_buffer):
633-
raise ValueError("gpsimd tensor_copy cannot access psum")
633+
raise ValueError("GpSimd tensor_copy cannot access PSUM")
634634
src_value = np.asarray(_tensor_value(src))
635635
if src_value.size != dst.data.size:
636636
raise ValueError(_ERR_AP_MISMATCH)
@@ -653,7 +653,7 @@ def tensor_tensor(
653653
lhs_buffer = _buffer_name(data1)
654654
rhs_buffer = _buffer_name(data2)
655655
if lhs_buffer == "psum" and rhs_buffer == "psum":
656-
raise ValueError("tensor_tensor cannot read both inputs from psum")
656+
raise ValueError("tensor_tensor cannot read both inputs from PSUM")
657657
if op.name == "power" and (
658658
engine == nisa.gpsimd_engine
659659
and "psum" in (dst_buffer, lhs_buffer, rhs_buffer)
@@ -793,7 +793,7 @@ def tensor_scalar(
793793
if op1 is not None and op0_bitwise != op1_bitwise:
794794
raise ValueError("bitvec and arithmetic ops can't be mixed")
795795
if op0_bitwise and engine in (nisa.scalar_engine, nisa.gpsimd_engine):
796-
raise ValueError("bitvec ops must run on vector engine")
796+
raise ValueError("bitvec ops must run on Vector Engine")
797797
if op0.name == "rsqrt" and engine == nisa.vector_engine:
798798
raise ValueError("rsqrt can only run on GpSimd/Scalar Engine")
799799
dst_dtype = getattr(dst, "dtype", dst.data.dtype)
@@ -838,7 +838,7 @@ def activation(
838838
"sbuf",
839839
"psum",
840840
):
841-
raise ValueError("activation only supports sbuf/psum")
841+
raise ValueError("activation only supports SBUF/PSUM")
842842
data_value = np.asarray(_tensor_value(data), dtype=np.float32)
843843
data_par, data_free = _partition_and_free(data_value.shape)
844844
dst_par, dst_free = _partition_and_free(dst.shape)

0 commit comments

Comments
 (0)