Skip to content

Commit 8e0c667

Browse files
author
morelos
committed
Update on "[ET-VK][testing] Q/DQ/CQP op comprehensive delegate dynamic quantization testing"
# Context We need to ensure that most of the operators that were created work in tandem with each other for dynamic quantization. # Changes This creates two test cases to test the per_token and per_tensor pipeline to ensure that the whole full quantization workflow works as intended. Differential Revision: [D77746139](https://our.internmc.facebook.com/intern/diff/D77746139/) [ghstack-poisoned]
2 parents a09b54d + bbeba68 commit 8e0c667

File tree

3 files changed

+36
-127
lines changed

3 files changed

+36
-127
lines changed

backends/vulkan/test/op_tests/dequantize_test.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,6 @@ at::Tensor dequantize_per_channel_reference_impl(
587587
}
588588

589589
// Forward declaration of implementation functions
590-
void test_vulkan_dequantize_per_tensor_impl(
591-
const std::vector<int>& input_sizes,
592-
float scale,
593-
int zero_point,
594-
int64_t quant_min,
595-
int64_t quant_max,
596-
at::ScalarType dtype,
597-
at::ScalarType out_dtype,
598-
const vkcompute::utils::StorageType in_storage,
599-
const vkcompute::utils::StorageType out_storage);
600-
601590
void test_vulkan_dequantize_per_token_impl(
602591
const std::vector<int>& input_sizes,
603592
const std::vector<float>& scales,
@@ -632,46 +621,6 @@ void test_vulkan_dequantize_per_tensor_tensor_impl(
632621
const vkcompute::utils::StorageType in_storage,
633622
const vkcompute::utils::StorageType out_storage);
634623

635-
// Wrapper function to test both buffer and texture storage types
636-
void test_vulkan_dequantize_per_tensor(
637-
const std::vector<int>& input_sizes,
638-
float scale,
639-
int zero_point,
640-
int64_t quant_min,
641-
int64_t quant_max,
642-
at::ScalarType dtype,
643-
at::ScalarType out_dtype) {
644-
// Test with buffer storage
645-
test_vulkan_dequantize_per_tensor_impl(
646-
input_sizes,
647-
scale,
648-
zero_point,
649-
quant_min,
650-
quant_max,
651-
dtype,
652-
out_dtype,
653-
vkcompute::utils::kBuffer,
654-
vkcompute::utils::kBuffer);
655-
656-
// Telling the system to expect a float instead of a double
657-
// since the shader can only return 32bit anyways
658-
if (out_dtype == at::kDouble) {
659-
out_dtype = at::kFloat;
660-
}
661-
662-
// Test with texture storage
663-
test_vulkan_dequantize_per_tensor_impl(
664-
input_sizes,
665-
scale,
666-
zero_point,
667-
quant_min,
668-
quant_max,
669-
dtype,
670-
out_dtype,
671-
vkcompute::utils::kTexture3D,
672-
vkcompute::utils::kTexture3D);
673-
}
674-
675624
// Wrapper function to test both buffer and texture storage types
676625
void test_vulkan_dequantize_per_token(
677626
const std::vector<int>& input_sizes,

backends/vulkan/test/op_tests/quantize_test.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -489,17 +489,6 @@ at::Tensor quantize_per_channel_reference_impl(
489489
}
490490

491491
// Forward declaration of implementation functions
492-
void test_vulkan_quantize_per_tensor_impl(
493-
const std::vector<int>& input_sizes,
494-
float scale,
495-
int zero_point,
496-
int64_t quant_min,
497-
int64_t quant_max,
498-
at::ScalarType in_dtype,
499-
at::ScalarType dtype,
500-
const vkcompute::utils::StorageType in_storage,
501-
const vkcompute::utils::StorageType out_storage);
502-
503492
void test_vulkan_quantize_per_token_impl(
504493
const std::vector<int>& input_sizes,
505494
const std::vector<float>& scales,
@@ -534,46 +523,6 @@ void test_vulkan_quantize_per_tensor_tensor_impl(
534523
const vkcompute::utils::StorageType in_storage,
535524
const vkcompute::utils::StorageType out_storage);
536525

537-
// Wrapper function to test both buffer and texture storage types
538-
void test_vulkan_quantize_per_tensor(
539-
const std::vector<int>& input_sizes,
540-
float scale,
541-
int zero_point,
542-
int64_t quant_min,
543-
int64_t quant_max,
544-
at::ScalarType in_dtype = at::kFloat,
545-
at::ScalarType dtype = at::kInt) {
546-
// Test with buffer storage
547-
test_vulkan_quantize_per_tensor_impl(
548-
input_sizes,
549-
scale,
550-
zero_point,
551-
quant_min,
552-
quant_max,
553-
in_dtype,
554-
dtype,
555-
vkcompute::utils::kBuffer,
556-
vkcompute::utils::kBuffer);
557-
558-
// If the in_dtype is a double, convert to float for texture implementation
559-
// since they don't support 64bit as inputs
560-
if (in_dtype == at::kDouble) {
561-
in_dtype = at::kFloat;
562-
}
563-
564-
// Test with texture storage
565-
test_vulkan_quantize_per_tensor_impl(
566-
input_sizes,
567-
scale,
568-
zero_point,
569-
quant_min,
570-
quant_max,
571-
in_dtype,
572-
dtype,
573-
vkcompute::utils::kTexture3D,
574-
vkcompute::utils::kTexture3D);
575-
}
576-
577526
// Wrapper function to test both buffer and texture storage types
578527
void test_vulkan_quantize_per_token(
579528
const std::vector<int>& input_sizes,

extension/aten_util/test/make_aten_functor_from_et_functor_test.cpp

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,12 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestWrap_ArrayRefOptional) {
424424

425425
TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) {
426426
// Test const optional scalar conversion
427-
const std::optional<int64_t> const_optional_at_in = std::optional<int64_t>(42);
427+
const std::optional<int64_t> const_optional_at_in =
428+
std::optional<int64_t>(42);
428429
auto const_optional_et =
429-
type_convert<const std::optional<int64_t>, torch::executor::optional<int64_t>>(
430-
const_optional_at_in)
430+
type_convert<
431+
const std::optional<int64_t>,
432+
torch::executor::optional<int64_t>>(const_optional_at_in)
431433
.call();
432434
EXPECT_TRUE(const_optional_et.has_value());
433435
EXPECT_EQ(const_optional_et.value(), 42);
@@ -442,60 +444,69 @@ TEST_F(MakeATenFunctorFromETFunctorTest, TestConvert_ConstRefOptionals) {
442444
EXPECT_EQ(optional_et_from_ref.value(), 24);
443445

444446
// Test const optional scalar reference conversion
445-
const std::optional<int64_t> const_optional_at_ref_in = std::optional<int64_t>(84);
447+
const std::optional<int64_t> const_optional_at_ref_in =
448+
std::optional<int64_t>(84);
446449
auto const_optional_et_from_ref =
447-
type_convert<const std::optional<int64_t>&, torch::executor::optional<int64_t>>(
448-
const_optional_at_ref_in)
450+
type_convert<
451+
const std::optional<int64_t>&,
452+
torch::executor::optional<int64_t>>(const_optional_at_ref_in)
449453
.call();
450454
EXPECT_TRUE(const_optional_et_from_ref.has_value());
451455
EXPECT_EQ(const_optional_et_from_ref.value(), 84);
452456

453457
// Test const optional tensor conversion
454458
const std::optional<at::Tensor> const_optional_tensor_at_in =
455459
std::optional<at::Tensor>(torch::tensor({5}));
456-
auto const_optional_tensor_converter =
457-
type_convert<
458-
const std::optional<at::Tensor>,
459-
torch::executor::optional<torch::executor::Tensor>>(const_optional_tensor_at_in);
460+
auto const_optional_tensor_converter = type_convert<
461+
const std::optional<at::Tensor>,
462+
torch::executor::optional<torch::executor::Tensor>>(
463+
const_optional_tensor_at_in);
460464
auto const_optional_tensor_et = const_optional_tensor_converter.call();
461465
EXPECT_TRUE(const_optional_tensor_et.has_value());
462466
EXPECT_EQ(const_optional_tensor_et.value().const_data_ptr<int64_t>()[0], 5);
463467

464468
// Test optional tensor reference conversion
465469
std::optional<at::Tensor> optional_tensor_at_ref_in =
466470
std::optional<at::Tensor>(torch::tensor({7}));
467-
auto optional_tensor_converter_from_ref =
468-
type_convert<
469-
std::optional<at::Tensor>&,
470-
torch::executor::optional<torch::executor::Tensor>>(optional_tensor_at_ref_in);
471+
auto optional_tensor_converter_from_ref = type_convert<
472+
std::optional<at::Tensor>&,
473+
torch::executor::optional<torch::executor::Tensor>>(
474+
optional_tensor_at_ref_in);
471475
auto optional_tensor_et_from_ref = optional_tensor_converter_from_ref.call();
472476
EXPECT_TRUE(optional_tensor_et_from_ref.has_value());
473-
EXPECT_EQ(optional_tensor_et_from_ref.value().const_data_ptr<int64_t>()[0], 7);
477+
EXPECT_EQ(
478+
optional_tensor_et_from_ref.value().const_data_ptr<int64_t>()[0], 7);
474479

475480
// Test const optional tensor reference conversion
476481
const std::optional<at::Tensor> const_optional_tensor_at_ref_in =
477482
std::optional<at::Tensor>(torch::tensor({9}));
478-
auto const_optional_tensor_converter_from_ref =
479-
type_convert<
480-
const std::optional<at::Tensor>&,
481-
torch::executor::optional<torch::executor::Tensor>>(const_optional_tensor_at_ref_in);
482-
auto const_optional_tensor_et_from_ref = const_optional_tensor_converter_from_ref.call();
483+
auto const_optional_tensor_converter_from_ref = type_convert<
484+
const std::optional<at::Tensor>&,
485+
torch::executor::optional<torch::executor::Tensor>>(
486+
const_optional_tensor_at_ref_in);
487+
auto const_optional_tensor_et_from_ref =
488+
const_optional_tensor_converter_from_ref.call();
483489
EXPECT_TRUE(const_optional_tensor_et_from_ref.has_value());
484-
EXPECT_EQ(const_optional_tensor_et_from_ref.value().const_data_ptr<int64_t>()[0], 9);
490+
EXPECT_EQ(
491+
const_optional_tensor_et_from_ref.value().const_data_ptr<int64_t>()[0],
492+
9);
485493

486494
// Test empty const optional conversions
487495
const std::optional<int64_t> empty_const_optional_at_in = std::nullopt;
488496
auto empty_const_optional_et =
489-
type_convert<const std::optional<int64_t>, torch::executor::optional<int64_t>>(
490-
empty_const_optional_at_in)
497+
type_convert<
498+
const std::optional<int64_t>,
499+
torch::executor::optional<int64_t>>(empty_const_optional_at_in)
491500
.call();
492501
EXPECT_FALSE(empty_const_optional_et.has_value());
493502

494-
const std::optional<at::Tensor> empty_const_optional_tensor_at_in = std::nullopt;
503+
const std::optional<at::Tensor> empty_const_optional_tensor_at_in =
504+
std::nullopt;
495505
auto empty_const_optional_tensor_et =
496506
type_convert<
497507
const std::optional<at::Tensor>,
498-
torch::executor::optional<torch::executor::Tensor>>(empty_const_optional_tensor_at_in)
508+
torch::executor::optional<torch::executor::Tensor>>(
509+
empty_const_optional_tensor_at_in)
499510
.call();
500511
EXPECT_FALSE(empty_const_optional_tensor_et.has_value());
501512
}

0 commit comments

Comments
 (0)